Next: Global Variables Replaced By Macros, Previous: Declaring a Scanner As Reentrant, Up: The Reentrant API in Detail [Contents][Index]
All functions other than rule hooks take one additional argument: yyscanner.
Notice that the calls to yy_push_state and yy_pop_state
both have an argument, yyscanner , that is not present in a
non-reentrant scanner. Here are the declarations of
yy_push_state and yy_pop_state in the reentrant scanner:
static void yy_push_state ( int new_state , yyscan_t yyscanner ) ;
static void yy_pop_state ( yyscan_t yyscanner ) ;
Notice that the argument yyscanner appears in the declaration of
both functions. In fact, all flex functions in a reentrant
scanner have this additional argument, except for rule hooks which
get it supplied implicitly.
It is always the last argument
in the argument list, it is always of type yyscan_t (which is
typedef’d to void *) and it is
always named yyscanner. As you may have guessed,
yyscanner is a pointer to an opaque data structure encapsulating
the current state of the scanner. For a list of function declarations,
see Functions Available in Reentrant Scanners. Rule hooks, such as
yybegin(), yyecho(), yyreject(), and yystart(), do not take this
additional argument.
Rule hooks don’t need to take a scanner context argument because, under the hood, the context is supplied by the call location.
The type name yscan_t follows C conventions. It may differ in
other target languages.