Next: Decl Summary Prev: Start Decl Up: Declarations
A Pure (Reentrant) Parser
A "reentrant" program is one which does not alter in the course of
execution; in other words, it consists entirely of "pure" (read-only)
code. Reentrancy is important whenever asynchronous execution is
possible; for example, a nonreentrant program may not be safe to call
from a signal handler. In systems with multiple threads of control, a
nonreentrant program must be called only within interlocks.
The Bison parser is not normally a reentrant program, because it uses
statically allocated variables for communication with `yylex'. These
variables include `yylval' and `yylloc'.
The Bison declaration `%pure_parser' says that you want the parser
to be reentrant. It looks like this:
The effect is that the two communication variables become local
variables in `yyparse', and a different calling convention is used for
the lexical analyzer function `yylex'. *Note Calling for Pure Parsers:
Pure Calling, for the details of this. The variable `yynerrs' also
becomes local in `yyparse' (Note: The Error Reporting Function
`yyerror'.). The convention for calling `yyparse'
itself is unchanged.
automatically generated by info2www