Browse thread
lexing__get_next_char ?
- Ian T Zimmerman
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Ian T Zimmerman <itz@r...> |
| Subject: | lexing__get_next_char ? |
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.