The manual clearly says:
YYSETSTATE (s)
[...]
The parameter to YYSETSTATE is a signed integer that uniquely identifies
the specific instance of YYFILL (n) that is about to be called.
[...]
The problem is, I'm calling my YYSETSTATE defined macro from a bison parser. How can I begin a state without knowing the integer UI? In other words, how can I get the identifier of a state I want to begin.
On lexer:
<MY_STATE>{NAME} {
return FN_NAME;
}
On parser:
expr: { push_state( ? ) } /* what's the identifier of MY_STATE? */
'(' FN_NAME VALUE VALUE ')' { compile_expr($2, $3, $4); }
;
I don't think you should ever invoke the
YYSETSTATEmacro. It's used as part ofre2c's control-inversion mechanism, enabled with the-fcommand-line flag, which turns the scanner into a "push" scanner. That's a handy feature, but it has nothing to do with start conditions, and it's hard to imagine a circumstance in which you could break through the abstraction to directly set the state.re2cdoes have a feature similar toflex's start conditions, which is enabled with the-ccommand-line flag. To set the current condition, you useYYSETCONDITION, which takes a value from an enumeration of start conditions. If you also supply the-tcommand-line flag,re2cwill create a header file with this enumeration, so that you can performYYSETCONDITIONfrom other translation units.