entered into RCS

This commit is contained in:
Richard M. Stallman
1993-11-21 22:03:08 +00:00
parent e425e87207
commit c656404a43

View File

@@ -39,7 +39,7 @@
@ifinfo @ifinfo
This file documents the Bison parser generator. This file documents the Bison parser generator.
Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation, Inc. Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice this manual provided the copyright notice and this permission notice
@@ -121,7 +121,7 @@ Cover art by Etienne Suvasa.
@node Top, Introduction, (dir), (dir) @node Top, Introduction, (dir), (dir)
@ifinfo @ifinfo
This manual documents version 1.20 of Bison. This manual documents version 1.23 of Bison.
@end ifinfo @end ifinfo
@menu @menu
@@ -307,7 +307,7 @@ don't know Bison or Yacc, start by reading these chapters. Reference
chapters follow which describe specific aspects of Bison in detail. chapters follow which describe specific aspects of Bison in detail.
Bison was written primarily by Robert Corbett; Richard Stallman made Bison was written primarily by Robert Corbett; Richard Stallman made
it Yacc-compatible. This edition corresponds to version 1.20 of Bison. it Yacc-compatible. This edition corresponds to version 1.23 of Bison.
@node Conditions, Copying, Introduction, Top @node Conditions, Copying, Introduction, Top
@unnumbered Conditions for Using Bison @unnumbered Conditions for Using Bison
@@ -763,8 +763,6 @@ use Bison or Yacc, we suggest you start by reading this chapter carefully.
@node Language and Grammar, Grammar in Bison, , Concepts @node Language and Grammar, Grammar in Bison, , Concepts
@section Languages and Context-Free Grammars @section Languages and Context-Free Grammars
@c !!! ``An expression can be an integer'' is not a valid Bison
@c expression---Bison cannot read English! --rjc 6 Feb 1992
@cindex context-free grammar @cindex context-free grammar
@cindex grammar, context-free @cindex grammar, context-free
In order for Bison to parse a language, it must be described by a In order for Bison to parse a language, it must be described by a
@@ -3055,11 +3053,12 @@ to be reentrant. It looks like this:
@end example @end example
The effect is that the two communication variables become local The effect is that the two communication variables become local
variables in @code{yyparse}, and a different calling convention is used for variables in @code{yyparse}, and a different calling convention is used
the lexical analyzer function @code{yylex}. @xref{Pure Calling, ,Calling for Pure Parsers}, for the for the lexical analyzer function @code{yylex}. @xref{Pure Calling,
details of this. The variable @code{yynerrs} also becomes local in ,Calling Conventions for Pure Parsers}, for the details of this. The
@code{yyparse} (@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}). The convention for calling variable @code{yynerrs} also becomes local in @code{yyparse}
@code{yyparse} itself is unchanged. (@pxref{Error Reporting, ,The Error Reporting Function @code{yyerror}}).
The convention for calling @code{yyparse} itself is unchanged.
@node Decl Summary, , Pure Decl, Declarations @node Decl Summary, , Pure Decl, Declarations
@subsection Bison Declaration Summary @subsection Bison Declaration Summary
@@ -3121,9 +3120,9 @@ variables of the Bison parser to start with @var{prefix} instead of
not conflict. not conflict.
The precise list of symbols renamed is @code{yyparse}, @code{yylex}, The precise list of symbols renamed is @code{yyparse}, @code{yylex},
@code{yyerror}, @code{yylval}, @code{yychar} and @code{yydebug}. For @code{yyerror}, @code{yynerrs}, @code{yylval}, @code{yychar} and
example, if you use @samp{-p c}, the names become @code{cparse}, @code{yydebug}. For example, if you use @samp{-p c}, the names become
@code{clex}, and so on. @code{cparse}, @code{clex}, and so on.
@strong{All the other variables and macros associated with Bison are not @strong{All the other variables and macros associated with Bison are not
renamed.} These others are not global; there is no conflict if the same renamed.} These others are not global; there is no conflict if the same
@@ -3318,7 +3317,7 @@ the use of this feature makes the parser noticeably slower.
The data type of @code{yylloc} has the name @code{YYLTYPE}. The data type of @code{yylloc} has the name @code{YYLTYPE}.
@node Pure Calling, , Token Positions, Lexical @node Pure Calling, , Token Positions, Lexical
@subsection Calling for Pure Parsers @subsection Calling Conventions for Pure Parsers
When you use the Bison declaration @code{%pure_parser} to request a When you use the Bison declaration @code{%pure_parser} to request a
pure, reentrant parser, the global communication variables @code{yylval} pure, reentrant parser, the global communication variables @code{yylval}
@@ -3345,10 +3344,11 @@ textual positions, then the type @code{YYLTYPE} will not be defined. In
this case, omit the second argument; @code{yylex} will be called with this case, omit the second argument; @code{yylex} will be called with
only one argument. only one argument.
If you wish to pass additional parameters to a reentrant parser in a @vindex YYPARSE_PARAM
reentrant way, you can do so by defining the macro @code{YYPARSE_PARAM}. You can pass parameter information to a reentrant parser in a reentrant
Define it as a variable name. The resulting @code{yyparse} function way. Define the macro @code{YYPARSE_PARAM} as a variable name. The
then accepts one argument, of type @code{void *}, with that name. resulting @code{yyparse} function then accepts one argument, of type
@code{void *}, with that name.
When you call @code{yyparse}, pass the address of an object, casting the When you call @code{yyparse}, pass the address of an object, casting the
address to @code{void *}. The grammar actions can refer to the contents address to @code{void *}. The grammar actions can refer to the contents
@@ -3394,6 +3394,31 @@ In the grammar actions, use expressions like this to refer to the data:
((struct parser_control *) parm)->randomness ((struct parser_control *) parm)->randomness
@end example @end example
@vindex YYLEX_PARAM
If you wish to pass the additional parameter data to @code{yylex},
define the macro @code{YYLEX_PARAM} just like @code{YYPARSE_PARAM}, as
shown here:
@example
%@{
struct parser_control
@{
int nastiness;
int randomness;
@};
#define YYPARSE_PARAM parm
#define YYLEX_PARAM parm
%@}
@end example
You should then define @code{yylex} to accept one additional
argument---the value of @code{parm}. (This makes either two or three
arguments in total, depending on whether an argument of type
@code{YYLTYPE} is passed.) You can declare the argument as a pointer to
the proper object type, or you can declare it as @code{void *} and
access the contents as shown above.
@node Error Reporting, Action Features, Lexical, Interface @node Error Reporting, Action Features, Lexical, Interface
@section The Error Reporting Function @code{yyerror} @section The Error Reporting Function @code{yyerror}
@cindex error reporting function @cindex error reporting function
@@ -4896,6 +4921,11 @@ section to request verbose, specific error message strings when
Macro for specifying the initial size of the parser stack. Macro for specifying the initial size of the parser stack.
@xref{Stack Overflow}. @xref{Stack Overflow}.
@item YYLEX_PARAM
Macro for specifying an extra argument (or list of extra arguments) for
@code{yyparse} to pass to @code{yylex}. @xref{Pure Calling,, Calling
Conventions for Pure Parsers}.
@item YYLTYPE @item YYLTYPE
Macro for the data type of @code{yylloc}; a structure with four Macro for the data type of @code{yylloc}; a structure with four
members. @xref{Token Positions, ,Textual Positions of Tokens}. members. @xref{Token Positions, ,Textual Positions of Tokens}.
@@ -4904,6 +4934,10 @@ members. @xref{Token Positions, ,Textual Positions of Tokens}.
Macro for specifying the maximum size of the parser stack. Macro for specifying the maximum size of the parser stack.
@xref{Stack Overflow}. @xref{Stack Overflow}.
@item YYPARSE_PARAM
Macro for specifying the name of a parameter that @code{yyparse} should
accept. @xref{Pure Calling,, Calling Conventions for Pure Parsers}.
@item YYRECOVERING @item YYRECOVERING
Macro whose value indicates whether the parser is recovering from a Macro whose value indicates whether the parser is recovering from a
syntax error. @xref{Action Features, ,Special Features for Use in Actions}. syntax error. @xref{Action Features, ,Special Features for Use in Actions}.