mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-18 08:43:03 +00:00
(Parser Function, Pure Calling, Error Reporting, Table of Symbols):
%parse-param and %lex-param now take just one argument, the declaration; the argument name is deduced from the declaration.
This commit is contained in:
@@ -3847,19 +3847,20 @@ If you use a reentrant parser, you can optionally pass additional
|
|||||||
parameter information to it in a reentrant way. To do so, use the
|
parameter information to it in a reentrant way. To do so, use the
|
||||||
declaration @code{%parse-param}:
|
declaration @code{%parse-param}:
|
||||||
|
|
||||||
@deffn {Directive} %parse-param @{@var{argument-declaration}@}, @{@var{argument-name}@}
|
@deffn {Directive} %parse-param @{@var{argument-declaration}@}
|
||||||
@findex %parse-param
|
@findex %parse-param
|
||||||
Declare that @code{argument-name} is an additional @code{yyparse}
|
Declare that an argument declared by @code{argument-declaration} is an
|
||||||
argument. This argument is also passed to @code{yyerror}. The
|
additional @code{yyparse} argument. This argument is also passed to
|
||||||
@var{argument-declaration} is used when declaring functions or
|
@code{yyerror}. The @var{argument-declaration} is used when declaring
|
||||||
prototypes.
|
functions or prototypes. The last identifier in
|
||||||
|
@var{argument-declaration} must be the argument name.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
Here's an example. Write this in the parser:
|
Here's an example. Write this in the parser:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
%parse-param @{int *nastiness@}, @{nastiness@}
|
%parse-param @{int *nastiness@}
|
||||||
%parse-param @{int *randomness@}, @{randomness@}
|
%parse-param @{int *randomness@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -4090,18 +4091,18 @@ If you wish to pass the additional parameter data to @code{yylex}, use
|
|||||||
@code{%lex-param} just like @code{%parse-param} (@pxref{Parser
|
@code{%lex-param} just like @code{%parse-param} (@pxref{Parser
|
||||||
Function}).
|
Function}).
|
||||||
|
|
||||||
@deffn {Directive} lex-param @{@var{argument-declaration}@}, @{@var{argument-name}@}
|
@deffn {Directive} lex-param @{@var{argument-declaration}@}
|
||||||
@findex %lex-param
|
@findex %lex-param
|
||||||
Declare that @code{argument-name} is an additional @code{yylex}
|
Declare that @code{argument-declaration} is an additional @code{yylex}
|
||||||
argument.
|
argument declaration.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
For instance:
|
For instance:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
%parse-param @{int *nastiness@}, @{nastiness@}
|
%parse-param @{int *nastiness@}
|
||||||
%lex-param @{int *nastiness@}, @{nastiness@}
|
%lex-param @{int *nastiness@}
|
||||||
%parse-param @{int *randomness@}, @{randomness@}
|
%parse-param @{int *randomness@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -4190,7 +4191,7 @@ void yyerror (const char *msg); /* Yacc parsers. */
|
|||||||
void yyerror (YYLTYPE *locp, const char *msg); /* GLR parsers. */
|
void yyerror (YYLTYPE *locp, const char *msg); /* GLR parsers. */
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
If @samp{%parse-param @{int *nastiness@}, @{nastiness@}} is used, then:
|
If @samp{%parse-param @{int *nastiness@}} is used, then:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
void yyerror (int *randomness, const char *msg); /* Yacc parsers. */
|
void yyerror (int *randomness, const char *msg); /* Yacc parsers. */
|
||||||
@@ -4207,10 +4208,10 @@ convention of @code{yylex} @emph{and} the calling convention of
|
|||||||
%locations
|
%locations
|
||||||
/* Pure yylex. */
|
/* Pure yylex. */
|
||||||
%pure-parser
|
%pure-parser
|
||||||
%lex-param @{int *nastiness@}, @{nastiness@}
|
%lex-param @{int *nastiness@}
|
||||||
/* Pure yyparse. */
|
/* Pure yyparse. */
|
||||||
%parse-param @{int *nastiness@}, @{nastiness@}
|
%parse-param @{int *nastiness@}
|
||||||
%parse-param @{int *randomness@}, @{randomness@}
|
%parse-param @{int *randomness@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
@@ -6498,7 +6499,7 @@ Bison declaration to assign left associativity to token(s).
|
|||||||
@xref{Precedence Decl, ,Operator Precedence}.
|
@xref{Precedence Decl, ,Operator Precedence}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %lex-param @{@var{argument-declaration}@}. @{@var{argument-name}"@}
|
@deffn {Directive} %lex-param @{@var{argument-declaration}@}
|
||||||
Bison declaration to specifying an additional parameter that
|
Bison declaration to specifying an additional parameter that
|
||||||
@code{yylex} should accept. @xref{Pure Calling,, Calling Conventions
|
@code{yylex} should accept. @xref{Pure Calling,, Calling Conventions
|
||||||
for Pure Parsers}.
|
for Pure Parsers}.
|
||||||
@@ -6530,7 +6531,7 @@ Bison declaration to set the name of the parser file. @xref{Decl
|
|||||||
Summary}.
|
Summary}.
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@deffn {Directive} %parse-param @{@var{argument-declaration}@}, @{@var{argument-name}@}
|
@deffn {Directive} %parse-param @{@var{argument-declaration}@}
|
||||||
Bison declaration to specifying an additional parameter that
|
Bison declaration to specifying an additional parameter that
|
||||||
@code{yyparse} should accept. @xref{Parser Function,, The Parser
|
@code{yyparse} should accept. @xref{Parser Function,, The Parser
|
||||||
Function @code{yyparse}}.
|
Function @code{yyparse}}.
|
||||||
|
|||||||
Reference in New Issue
Block a user