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.
Normally, Bison generates a parser which is not reentrant. This is
suitable for most uses, and it permits compatibility with Yacc. (The
standard Yacc interfaces are inherently nonreentrant, because they use
statically allocated variables for communication with
Alternatively, you can generate a pure, reentrant parser. The Bison
%define api.pure says that you want the parser to be
reentrant. It looks like this:
%define api.pure full
The result is that the communication variables
yylloc become local variables in
yyparse, and a different
calling convention is used for the lexical analyzer function
yylex. See Calling Conventions for Pure Parsers, for the details of this. The variable
becomes local in
yyparse in pull mode but it becomes a member
of yypstate in push mode. (see The Error Reporting Function
yyerror). The convention for calling
yyparse itself is unchanged.
Whether the parser is pure has nothing to do with the grammar rules. You can generate either a pure parser or a nonreentrant parser from any valid grammar.