Re: lexing__get_next_char ?

Ian T Zimmerman (itz@rahul.net)
Mon, 21 Oct 1996 09:55:53 -0700

Date: Mon, 21 Oct 1996 09:55:53 -0700
Message-Id: <199610211655.JAA26218@kronstadt.rahul.net>
From: Ian T Zimmerman <itz@rahul.net>
To: caml-list@inria.fr
Subject: Re: lexing__get_next_char ?

In article <199610211430.QAA11843@pauillac.inria.fr> Xavier Leroy
<Xavier.Leroy@inria.fr> writes:

>
> > 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
>
> Viewed from C, Caml records are arrays of elements of type "value".
> So, we're basically casting a pointer to a "value" array to a pointer
> to a struct with all fields having type "value".

But don't they have the header word in front??

-- 
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.