|Reentrant Flex and Bison email@example.com (2000-06-03)|
|Re: Reentrant Flex and Bison firstname.lastname@example.org (Randall Hyde) (2000-06-06)|
|Reentrant Flex and Bison email@example.com (1999-11-16)|
|Re: Reentrant Flex and Bison firstname.lastname@example.org (Burkhard Perkens-Golomb) (1999-12-07)|
|From:||"Randall Hyde" <email@example.com>|
|Date:||6 Jun 2000 23:18:48 -0400|
<firstname.lastname@example.org> wrote in message news:email@example.com...
> I'm trying to create a reentrant scanner/parser using Flex and Bison
> (to create a simple scripting language for a Windows app). Bison has
> the %pure_parser directive to support creating a reentrant parser. The
> problem with this is it changes the interface to yylex to look like
> int yylex (YYSTYPE* yyval);
> Flex doesn't seem to have the corresponding support this feature. In
> other words, Flex is still going to expect yylex to look like "int yylex
> Am I missing something?
> Eric Tetz
> [No, flex doesn't easily make reentrant lexers. -John]
It's been years since I wrote that portion of the HLA compiler, but
I suspect that all that you need is the following:
** Allow for a recursive version of Bison parser.
#define YY_DECL int yylex( YYSTYPE *yylval, YYLTYPE *yylloc)
/* Other C Decls */
I stuck this stuff at the (very) top of the FLEX file.
Whenever I had to make a recursive FLEX call, I just used
the prototype above.
I've been using the recursive parser quite a bit.
Flex itself must also work recursively because the recursive
parser calls wind up calling the scanner.
If you have any further questions, you can always download
the HLA (High Level Assembler) sources from
http://webster.cs.ucr.edu. The recursive entry into the
parser is somewhat kludgy, but it does work.
[That'll probably work for recursive calls to the lexer, but it's no
good for a reentrant lexer because yylex() is still full of static
variables. If you use the C++ option, the generated C++ class should
be reentrant. -John]
Return to the
Search the comp.compilers archives again.