DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

(bison.info) Pure Decl

Info Catalog (bison.info) Start Decl (bison.info) Declarations (bison.info) Decl Summary
 
 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.
 
    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 `yylex',
 including `yylval' and `yylloc'.)
 
    Alternatively, you can generate a pure, reentrant parser.  The Bison
 declaration `%pure_parser' says that you want the parser to be
 reentrant.  It looks like this:
 
      %pure_parser
 
    The result is that the communication variables `yylval' and `yylloc'
 become local variables in `yyparse', and a different calling convention
 is used for the lexical analyzer function `yylex'.   Calling
 Conventions for Pure Parsers Pure Calling, for the details of this.
 The variable `yynerrs' also becomes local in `yyparse' ( The Error
 Reporting Function `yyerror' Error Reporting.).  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.
 
Info Catalog (bison.info) Start Decl (bison.info) Declarations (bison.info) Decl Summary
automatically generated byinfo2html