Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* lexing__get_next_char ?
@ 1996-10-18  3:40 Ian T Zimmerman
  1996-10-21 14:30 ` Xavier Leroy
  0 siblings, 1 reply; 3+ messages in thread
From: Ian T Zimmerman @ 1996-10-18  3:40 UTC (permalink / raw)
  To: caml-list



Hello camellers --- this is a hacker question.
In the caml-light sources, in src/runtime/lexing.c, the primitive
get_next_char is defined as follows:

struct lexer_buffer {
  value refill_buff;
  value lex_buffer;
  value lex_abs_pos;
  value lex_start_pos;
  value lex_curr_pos;
  value lex_last_pos;
  value lex_last_action;
};

value get_next_char(lexbuf)     /* ML */
     struct lexer_buffer * lexbuf;
{
  mlsize_t buffer_len, curr_pos;
  
  buffer_len = string_length(lexbuf->lex_buffer);
     ...

How can this work, when lexer buffers are ML records on the heap, as
the following piece of src/lib/lexing.ml seems to show:

let create_lexer f =
  { refill_buff = lex_refill f;
    lex_buffer = create_string 2048;
    lex_abs_pos = - 2048;
    lex_start_pos = 2048;
    lex_curr_pos = 2048;
    lex_last_pos = 2048;
    lex_last_action = dummy_action }
    ...

Shouldn't get_next_char be something like

value get_next_char(lexbuf)     /* ML */
     value lexbuf;
{
	mlsize_t buffer_len, curr_pos;
	assert(Is_block(lexbuf));
	buffer_len = string_length(Field(lexbuf,1));
	...

Thanks for your explanation!

-- 
Ian T Zimmerman                        <itz@rahul.net>
Days spent working only for oneself are twice wasted; 
it would have been better not to work at all.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-10-22 14:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-10-18  3:40 lexing__get_next_char ? Ian T Zimmerman
1996-10-21 14:30 ` Xavier Leroy
1996-10-21 16:55   ` Ian T Zimmerman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox