X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/b8458aa5ccca039e48c37a3947df3025e3acbcee..18d192f0eae3f0ed313100d825e46bf772b0b643:/doc/bison.texinfo?ds=sidebyside 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.