*** empty log message ***

This commit is contained in:
Richard M. Stallman
1993-11-21 10:25:13 +00:00
parent 2a2e87dbe0
commit e425e87207
4 changed files with 87 additions and 11 deletions

View File

@@ -91,10 +91,18 @@ while (0)
#ifdef YYPURE #ifdef YYPURE
#ifdef YYLSP_NEEDED #ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval, &yylloc) #define YYLEX yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, YYLEX_PARAM)
#else #else
#define YYLEX yylex(&yylval) #define YYLEX yylex(&yylval)
#endif #endif
#endif /* not YYLSP_NEEDED */
#endif #endif
/* If nonreentrant, generate the variables here */ /* If nonreentrant, generate the variables here */

View File

@@ -1,7 +1,7 @@
\input texinfo @c -*-texinfo-*- \input texinfo @c -*-texinfo-*-
@comment %**start of header @comment %**start of header
@setfilename bison.info @setfilename bison.info
@settitle Bison 1.20 @settitle Bison 1.23
@setchapternewpage odd @setchapternewpage odd
@iftex @iftex
@@ -73,13 +73,13 @@ instead of in the original English.
@titlepage @titlepage
@title Bison @title Bison
@subtitle The YACC-compatible Parser Generator @subtitle The YACC-compatible Parser Generator
@subtitle December 1992, Bison Version 1.20 @subtitle December 1993, Bison Version 1.23
@author by Charles Donnelly and Richard Stallman @author by Charles Donnelly and Richard Stallman
@page @page
@vskip 0pt plus 1filll @vskip 0pt plus 1filll
Copyright @copyright{} 1988, 1989, 1990, 1991, 1992 Free Software Copyright @copyright{} 1988, 1989, 1990, 1991, 1992, 1993 Free Software
Foundation Foundation
@sp 2 @sp 2
@@ -2281,8 +2281,10 @@ In particular, @code{yylex} should never return this value.
A Bison grammar rule has the following general form: A Bison grammar rule has the following general form:
@example @example
@group
@var{result}: @var{components}@dots{} @var{result}: @var{components}@dots{}
; ;
@end group
@end example @end example
@noindent @noindent
@@ -3318,12 +3320,13 @@ 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 for Pure Parsers
When you use the Bison declaration @code{%pure_parser} to request a pure, When you use the Bison declaration @code{%pure_parser} to request a
reentrant parser, the global communication variables @code{yylval} and pure, reentrant parser, the global communication variables @code{yylval}
@code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant) Parser}.) In such parsers the and @code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant)
two global variables are replaced by pointers passed as arguments to Parser}.) In such parsers the two global variables are replaced by
@code{yylex}. You must declare them as shown here, and pass the pointers passed as arguments to @code{yylex}. You must declare them as
information back by storing it through those pointers. shown here, and pass the information back by storing it through those
pointers.
@example @example
yylex (lvalp, llocp) yylex (lvalp, llocp)
@@ -3342,6 +3345,55 @@ 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
reentrant way, you can do so by defining the macro @code{YYPARSE_PARAM}.
Define it as a variable name. The 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
address to @code{void *}. The grammar actions can refer to the contents
of the object by casting the pointer value back to its proper type and
then dereferencing it. Here's an example. Write this in the parser:
@example
%@{
struct parser_control
@{
int nastiness;
int randomness;
@};
#define YYPARSE_PARAM parm
%@}
@end example
@noindent
Then call the parser like this:
@example
struct parser_control
@{
int nastiness;
int randomness;
@};
@dots{}
@{
struct parser_control foo;
@dots{} /* @r{Store proper data in @code{foo}.} */
value = yyparse ((void *) &foo);
@dots{}
@}
@end example
@noindent
In the grammar actions, use expressions like this to refer to the data:
@example
((struct parser_control *) parm)->randomness
@end example
@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
@@ -4680,8 +4732,8 @@ as described under the @samp{-v} and @samp{-d} switches.
@itemx --name-prefix=@var{prefix} @itemx --name-prefix=@var{prefix}
Rename the external symbols used in the parser so that they start with Rename the external symbols used in the parser so that they start with
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed @var{prefix} instead of @samp{yy}. The precise list of symbols renamed
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yylval}, is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs},
@code{yychar} and @code{yydebug}. @code{yylval}, @code{yychar} and @code{yydebug}.
For example, if you use @samp{-p c}, the names become @code{cparse}, For example, if you use @samp{-p c}, the names become @code{cparse},
@code{clex}, and so on. @code{clex}, and so on.

View File

@@ -91,10 +91,18 @@ while (0)
#ifdef YYPURE #ifdef YYPURE
#ifdef YYLSP_NEEDED #ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval, &yylloc) #define YYLEX yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, YYLEX_PARAM)
#else #else
#define YYLEX yylex(&yylval) #define YYLEX yylex(&yylval)
#endif #endif
#endif /* not YYLSP_NEEDED */
#endif #endif
/* If nonreentrant, generate the variables here */ /* If nonreentrant, generate the variables here */

View File

@@ -91,10 +91,18 @@ while (0)
#ifdef YYPURE #ifdef YYPURE
#ifdef YYLSP_NEEDED #ifdef YYLSP_NEEDED
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
#else
#define YYLEX yylex(&yylval, &yylloc) #define YYLEX yylex(&yylval, &yylloc)
#endif
#else /* not YYLSP_NEEDED */
#ifdef YYLEX_PARAM
#define YYLEX yylex(&yylval, YYLEX_PARAM)
#else #else
#define YYLEX yylex(&yylval) #define YYLEX yylex(&yylval)
#endif #endif
#endif /* not YYLSP_NEEDED */
#endif #endif
/* If nonreentrant, generate the variables here */ /* If nonreentrant, generate the variables here */