I am trying to make a reentrant scanner that relies on start conditions.
I was following along something similar to this guys question:
Writing re-entrant lexer with Flex
And as the one poster mentioned, the scanner will work if you explicitly create the yyscan_t
and pass it as an extra argument. However, I still get the yyg undeclared
error message when using BEGIN <sc>
, etc to manipulate the start condition.
Is this a bug? Should I explicity use the yy_push_state
and yy_pop_state
state functions instead?
Looks like when you use
%option reentrant
you can only useBEGIN
andYY_START
in the actions section of your lexer, and not in the code section. Makes sense as manipulating the parser state requires access to the parser state, butBEGIN
doesn't take any arguments, so there's no way to provide it. Using%option stack
andyy_push
/pop_state
seems like a reasonable workaround.