help-flex
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: using flex internals outside the scanner.l file


From: Bruce Lilly
Subject: Re: using flex internals outside the scanner.l file
Date: Wed, 3 Aug 2005 18:47:25 -0400
User-agent: KMail/1.8.2

On Wed August 3 2005 18:15, Henrik Sorensen wrote:

> I had a problem with some of the functions since they use the YY_BUFFER_STATE 
> structure, and YY_BUFFER_STATE uses yy_buffer_state and yy_site_t.
> 
> I have created a separate header file where I copied the necessary pieces 
> from 
> the generated lex.yy.c file.
> Obviously this is not really portable between versions of flex.
> 
> Is there anyway to get flex to export the necessary definitions to a file ?

The beta versions of flex (http://sourceforge.net/projects/lex/) provide ways
to generate a header file (%option header-file and command-line --header-file)
containing definitions which can be #included by other C files.  Depending on
your code structure, you may need to edit (e.g. via sed, grep, awk, etc.) the
generated header file.

> Are there any other way to do this ?

You could (and must in some cases, e.g. to access YYSTATE or yy_start_stack_ptr
in a reentrant lexical analyzer) put stub code in the .l file and call that
from an external file which contains detailed code.

Neither of these methods is going to work absolutely portably between flex
versions (older versions have no header-file option, generated header file
content and internal name changes vary with versions).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]