help-flex
[Top][All Lists]
Advanced

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

flex++ generated source


From: Robert Wruck
Subject: flex++ generated source
Date: Wed, 7 Jan 2004 15:11:07 +0000
User-agent: Mutt/1.4i

Hello,

i wrote a lex input file for use in a C++ program.
I processed it with flex 2.5.4 flex++, so it generates C++ scanner classes.

However, when compiling the generated source, I noticed a few things:

- cin, cout and cerr are undefined, since they are now found in namespace std.

- if %option stack is used, the prototypes for the C functions,
    static void yy_push_state
    static void yy_pop_state
    static void yy_top_state
  are generated, but the functions are not (since those are part of yyFlexLexer)
  Also, the yy_start_stack_* static variables are declared but never used.

- neither the C scanner, nor the C++ scanner class provide support for a pure 
bison parser, which expects
  int yylex (YYSTYPE *lvalp)
  or int yylex (YYSTYPE *lvalp, YYLTYPE *llocp),
  so i have to provide a "global" yylval it can assign to.
  I worked around this by deriving my own class from yyFlexLexer, which holds a 
YYSTYPE* plval and faked the yylval 
  by inserting
  YYSTYPE& yylval = *plval;
  above the rules.


cheers,
robert




reply via email to

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