2
votes

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?

1

1 Answers

2
votes

Looks like when you use %option reentrant you can only use BEGIN and YY_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, but BEGIN doesn't take any arguments, so there's no way to provide it. Using %option stack and yy_push/pop_state seems like a reasonable workaround.