From: Akim Demaille Date: Mon, 20 Sep 2004 14:29:31 +0000 (+0000) Subject: * doc/bison.texinfo (Initial Action Decl): New. X-Git-Tag: BISON-2_0~109 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/18d192f0eae3f0ed313100d825e46bf772b0b643 * doc/bison.texinfo (Initial Action Decl): New. --- diff --git a/ChangeLog b/ChangeLog index fad3a07d..56392bc0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2004-09-20 Akim Demaille + + * doc/bison.texinfo (Initial Action Decl): New. + 2004-09-20 Akim Demaille * data/yacc.c (YY_LOCATION_PRINT): Use YYLTYPE_IS_TRIVIAL as a diff --git a/NEWS b/NEWS index b3cc477c..36c20426 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,10 @@ Bison News Changes in version 1.875e: +* New directive: %initial-action. + This directive allows the user to run arbitrary code (including + initializing @$) from yyparse before parsing starts. + * The option `--report=lookahead' was changed to `--report=look-ahead'. The old spelling still works, but is not documented and will be removed. diff --git a/doc/bison.texinfo b/doc/bison.texinfo index dd2407a3..e2706921 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -228,6 +228,7 @@ Bison Declarations * Precedence Decl:: Declaring terminals with precedence and associativity. * Union Decl:: Declaring the set of all semantic value types. * Type Decl:: Declaring the choice of type for a nonterminal symbol. +* Initial Action Decl:: Code run before parsing starts. * Destructor Decl:: Declaring how symbols are freed. * Expect Decl:: Suppressing warnings about parsing conflicts. * Start Decl:: Specifying the start symbol. @@ -3520,6 +3521,7 @@ Grammars}). * Precedence Decl:: Declaring terminals with precedence and associativity. * Union Decl:: Declaring the set of all semantic value types. * Type Decl:: Declaring the choice of type for a nonterminal symbol. +* Initial Action Decl:: Code run before parsing starts. * Destructor Decl:: Declaring how symbols are freed. * Expect Decl:: Suppressing warnings about parsing conflicts. * Start Decl:: Specifying the start symbol. @@ -3729,6 +3731,22 @@ use the same @code{<@var{type}>} construction in a declaration for the terminal symbol. All kinds of token declarations allow @code{<@var{type}>}. +@node Initial Action Decl +@subsection Performing Actions before Parsing +@findex %initial-action + +Sometimes your parser needs to perform some initializations before +parsing. The @code{%initial-action} directive allows for such arbitrary +code. + +@deffn {Directive} %initial-action @{ @var{code} @} +@findex %initial-action +Declare that the @var{code} must be invoked before parsing each time +@code{yyparse} is called. The @var{code} may use @code{@@$} to +designate the initial location, and the @code{%parse-param}. +@end deffn + + @node Destructor Decl @subsection Freeing Discarded Symbols @cindex freeing discarded symbols @@ -7144,6 +7162,10 @@ time to resolve reduce/reduce conflicts. @xref{GLR Parsers, ,Writing @acronym{GLR} Parsers}. @end deffn +@deffn {Directive} %initial-action +Run user code before parsing. @xref{Initial Action Decl, , Performing Actions before Parsing}. +@end deffn + @deffn {Directive} %error-verbose Bison declaration to request verbose, specific error message strings when @code{yyerror} is called.