So i’m writing this reentrant scanner with flex and i’m using the stack option to track state. According to the documentation, it seems that
yy_push_state(SCRIPT, yyscanner);
//now yy_top_state(yyscanner) == SCRIPT; should eval true right?
but when i put the following printf() immediately after yy_push_state()
printf("SCRIPT=%d; DQUOTE=%d; CURRENT=%d\n", SCRIPT, DQUOTE,
yy_top_state(yyscanner));
I get this in return for output
SCRIPT=2; DQUOTE=3; CURRENT=1
Please point out what i’m doing wrong if anything at all.
Thanks in advance
No, I don’t think so. Based on the code I’ve seen, it’s the current state that gets pushed on the stack, then the state is then changed to the new state.
After expanding the stack if necessary,
yy_push_state(new_state)executes:where
YY_STARTis a macro based on the current state andBEGINis what sets the new state.