1088 |
; |
; |
1089 |
|
|
1090 |
line: '\n' |
line: '\n' |
1091 |
| exp '\n' @{ printf ("\t%.10g\n", $1); @} |
| exp '\n' @{ printf ("\t%.10g\n", $1); @} |
1092 |
; |
; |
1093 |
|
|
1094 |
exp: NUM @{ $$ = $1; @} |
exp: NUM @{ $$ = $1; @} |
1095 |
| exp exp '+' @{ $$ = $1 + $2; @} |
| exp exp '+' @{ $$ = $1 + $2; @} |
1096 |
| exp exp '-' @{ $$ = $1 - $2; @} |
| exp exp '-' @{ $$ = $1 - $2; @} |
1097 |
| exp exp '*' @{ $$ = $1 * $2; @} |
| exp exp '*' @{ $$ = $1 * $2; @} |
1098 |
| exp exp '/' @{ $$ = $1 / $2; @} |
| exp exp '/' @{ $$ = $1 / $2; @} |
1099 |
/* Exponentiation */ |
/* Exponentiation */ |
1100 |
| exp exp '^' @{ $$ = pow ($1, $2); @} |
| exp exp '^' @{ $$ = pow ($1, $2); @} |
1101 |
/* Unary minus */ |
/* Unary minus */ |
1102 |
| exp 'n' @{ $$ = -$1; @} |
| exp 'n' @{ $$ = -$1; @} |
1103 |
; |
; |
1104 |
%% |
%% |
1105 |
@end example |
@end example |
1706 |
yylex (void) |
yylex (void) |
1707 |
@{ |
@{ |
1708 |
int c; |
int c; |
1709 |
|
@end group |
1710 |
|
|
1711 |
|
@group |
1712 |
/* Skip white space. */ |
/* Skip white space. */ |
1713 |
while ((c = getchar ()) == ' ' || c == '\t') |
while ((c = getchar ()) == ' ' || c == '\t') |
1714 |
++yylloc.last_column; |
++yylloc.last_column; |
1715 |
|
@end group |
1716 |
|
|
1717 |
|
@group |
1718 |
/* Step. */ |
/* Step. */ |
1719 |
yylloc.first_line = yylloc.last_line; |
yylloc.first_line = yylloc.last_line; |
1720 |
yylloc.first_column = yylloc.last_column; |
yylloc.first_column = yylloc.last_column; |
1836 |
Here are the C and Bison declarations for the multi-function calculator. |
Here are the C and Bison declarations for the multi-function calculator. |
1837 |
|
|
1838 |
@smallexample |
@smallexample |
1839 |
|
@group |
1840 |
%@{ |
%@{ |
1841 |
#include <math.h> /* For math functions, cos(), sin(), etc. */ |
#include <math.h> /* For math functions, cos(), sin(), etc. */ |
1842 |
#include "calc.h" /* Contains definition of `symrec' */ |
#include "calc.h" /* Contains definition of `symrec' */ |
1843 |
%@} |
%@} |
1844 |
|
@end group |
1845 |
|
@group |
1846 |
%union @{ |
%union @{ |
1847 |
double val; /* For returning numbers. */ |
double val; /* For returning numbers. */ |
1848 |
symrec *tptr; /* For returning symbol-table pointers */ |
symrec *tptr; /* For returning symbol-table pointers. */ |
1849 |
@} |
@} |
1850 |
|
@end group |
1851 |
%token <val> NUM /* Simple double precision number */ |
%token <val> NUM /* Simple double precision number. */ |
1852 |
%token <tptr> VAR FNCT /* Variable and Function */ |
%token <tptr> VAR FNCT /* Variable and Function. */ |
1853 |
%type <val> exp |
%type <val> exp |
1854 |
|
|
1855 |
|
@group |
1856 |
%right '=' |
%right '=' |
1857 |
%left '-' '+' |
%left '-' '+' |
1858 |
%left '*' '/' |
%left '*' '/' |
1859 |
%left NEG /* Negation--unary minus */ |
%left NEG /* Negation--unary minus */ |
1860 |
%right '^' /* Exponentiation */ |
%right '^' /* Exponentiation */ |
1861 |
|
@end group |
1862 |
/* Grammar follows */ |
/* Grammar follows */ |
1863 |
%% |
%% |
1864 |
@end smallexample |
@end smallexample |
1893 |
those which mention @code{VAR} or @code{FNCT}, are new. |
those which mention @code{VAR} or @code{FNCT}, are new. |
1894 |
|
|
1895 |
@smallexample |
@smallexample |
1896 |
|
@group |
1897 |
input: /* empty */ |
input: /* empty */ |
1898 |
| input line |
| input line |
1899 |
; |
; |
1900 |
|
@end group |
1901 |
|
|
1902 |
|
@group |
1903 |
line: |
line: |
1904 |
'\n' |
'\n' |
1905 |
| exp '\n' @{ printf ("\t%.10g\n", $1); @} |
| exp '\n' @{ printf ("\t%.10g\n", $1); @} |
1906 |
| error '\n' @{ yyerrok; @} |
| error '\n' @{ yyerrok; @} |
1907 |
; |
; |
1908 |
|
@end group |
1909 |
|
|
1910 |
|
@group |
1911 |
exp: NUM @{ $$ = $1; @} |
exp: NUM @{ $$ = $1; @} |
1912 |
| VAR @{ $$ = $1->value.var; @} |
| VAR @{ $$ = $1->value.var; @} |
1913 |
| VAR '=' exp @{ $$ = $3; $1->value.var = $3; @} |
| VAR '=' exp @{ $$ = $3; $1->value.var = $3; @} |
1920 |
| exp '^' exp @{ $$ = pow ($1, $3); @} |
| exp '^' exp @{ $$ = pow ($1, $3); @} |
1921 |
| '(' exp ')' @{ $$ = $2; @} |
| '(' exp ')' @{ $$ = $2; @} |
1922 |
; |
; |
1923 |
|
@end group |
1924 |
/* End of grammar */ |
/* End of grammar */ |
1925 |
%% |
%% |
1926 |
@end smallexample |
@end smallexample |
1975 |
@code{init_table} as well: |
@code{init_table} as well: |
1976 |
|
|
1977 |
@smallexample |
@smallexample |
|
@group |
|
1978 |
#include <stdio.h> |
#include <stdio.h> |
1979 |
|
|
1980 |
|
@group |
1981 |
int |
int |
1982 |
main (void) |
main (void) |
1983 |
@{ |
@{ |
1992 |
@{ |
@{ |
1993 |
printf ("%s\n", s); |
printf ("%s\n", s); |
1994 |
@} |
@} |
1995 |
|
@end group |
1996 |
|
|
1997 |
|
@group |
1998 |
struct init |
struct init |
1999 |
@{ |
@{ |
2000 |
char *fname; |
char *fname; |
2013 |
"sqrt", sqrt, |
"sqrt", sqrt, |
2014 |
0, 0 |
0, 0 |
2015 |
@}; |
@}; |
2016 |
|
@end group |
2017 |
|
|
2018 |
|
@group |
2019 |
/* The symbol table: a chain of `struct symrec'. */ |
/* The symbol table: a chain of `struct symrec'. */ |
2020 |
symrec *sym_table = (symrec *) 0; |
symrec *sym_table = (symrec *) 0; |
2021 |
@end group |
@end group |
2091 |
@smallexample |
@smallexample |
2092 |
@group |
@group |
2093 |
#include <ctype.h> |
#include <ctype.h> |
2094 |
|
@end group |
2095 |
|
|
2096 |
|
@group |
2097 |
int |
int |
2098 |
yylex (void) |
yylex (void) |
2099 |
@{ |
@{ |
2141 |
if (i == length) |
if (i == length) |
2142 |
@{ |
@{ |
2143 |
length *= 2; |
length *= 2; |
2144 |
symbuf = (char *)realloc (symbuf, length + 1); |
symbuf = (char *) realloc (symbuf, length + 1); |
2145 |
@} |
@} |
2146 |
/* Add this character to the buffer. */ |
/* Add this character to the buffer. */ |
2147 |
symbuf[i++] = c; |
symbuf[i++] = c; |
3564 |
|
|
3565 |
Here is a summary of the declarations used to define a grammar: |
Here is a summary of the declarations used to define a grammar: |
3566 |
|
|
3567 |
@table @code |
@deffn {Directive} %union |
|
@item %union |
|
3568 |
Declare the collection of data types that semantic values may have |
Declare the collection of data types that semantic values may have |
3569 |
(@pxref{Union Decl, ,The Collection of Value Types}). |
(@pxref{Union Decl, ,The Collection of Value Types}). |
3570 |
|
@end deffn |
3571 |
|
|
3572 |
@item %token |
@deffn {Directive} %token |
3573 |
Declare a terminal symbol (token type name) with no precedence |
Declare a terminal symbol (token type name) with no precedence |
3574 |
or associativity specified (@pxref{Token Decl, ,Token Type Names}). |
or associativity specified (@pxref{Token Decl, ,Token Type Names}). |
3575 |
|
@end deffn |
3576 |
|
|
3577 |
@item %right |
@deffn {Directive} %right |
3578 |
Declare a terminal symbol (token type name) that is right-associative |
Declare a terminal symbol (token type name) that is right-associative |
3579 |
(@pxref{Precedence Decl, ,Operator Precedence}). |
(@pxref{Precedence Decl, ,Operator Precedence}). |
3580 |
|
@end deffn |
3581 |
|
|
3582 |
@item %left |
@deffn {Directive} %left |
3583 |
Declare a terminal symbol (token type name) that is left-associative |
Declare a terminal symbol (token type name) that is left-associative |
3584 |
(@pxref{Precedence Decl, ,Operator Precedence}). |
(@pxref{Precedence Decl, ,Operator Precedence}). |
3585 |
|
@end deffn |
3586 |
|
|
3587 |
@item %nonassoc |
@deffn {Directive} %nonassoc |
3588 |
Declare a terminal symbol (token type name) that is nonassociative |
Declare a terminal symbol (token type name) that is nonassociative |
3589 |
(using it in a way that would be associative is a syntax error) |
(using it in a way that would be associative is a syntax error) |
3590 |
|
@end deffn |
3591 |
(@pxref{Precedence Decl, ,Operator Precedence}). |
(@pxref{Precedence Decl, ,Operator Precedence}). |
3592 |
|
|
3593 |
@item %type |
@deffn {Directive} %type |
3594 |
Declare the type of semantic values for a nonterminal symbol |
Declare the type of semantic values for a nonterminal symbol |
3595 |
(@pxref{Type Decl, ,Nonterminal Symbols}). |
(@pxref{Type Decl, ,Nonterminal Symbols}). |
3596 |
|
@end deffn |
3597 |
|
|
3598 |
@item %start |
@deffn {Directive} %start |
3599 |
Specify the grammar's start symbol (@pxref{Start Decl, ,The |
Specify the grammar's start symbol (@pxref{Start Decl, ,The |
3600 |
Start-Symbol}). |
Start-Symbol}). |
3601 |
|
@end deffn |
3602 |
|
|
3603 |
@item %expect |
@deffn {Directive} %expect |
3604 |
Declare the expected number of shift-reduce conflicts |
Declare the expected number of shift-reduce conflicts |
3605 |
(@pxref{Expect Decl, ,Suppressing Conflict Warnings}). |
(@pxref{Expect Decl, ,Suppressing Conflict Warnings}). |
3606 |
@end table |
@end deffn |
3607 |
|
|
3608 |
|
|
3609 |
@sp 1 |
@sp 1 |
3610 |
@noindent |
@noindent |
3611 |
In order to change the behavior of @command{bison}, use the following |
In order to change the behavior of @command{bison}, use the following |
3612 |
directives: |
directives: |
3613 |
|
|
3614 |
@table @code |
@deffn {Directive} %debug |
|
@item %debug |
|
3615 |
In the parser file, define the macro @code{YYDEBUG} to 1 if it is not |
In the parser file, define the macro @code{YYDEBUG} to 1 if it is not |
3616 |
already defined, so that the debugging facilities are compiled. |
already defined, so that the debugging facilities are compiled. |
3617 |
|
@end deffn |
3618 |
@xref{Tracing, ,Tracing Your Parser}. |
@xref{Tracing, ,Tracing Your Parser}. |
3619 |
|
|
3620 |
@item %defines |
@deffn {Directive} %defines |
3621 |
Write an extra output file containing macro definitions for the token |
Write an extra output file containing macro definitions for the token |
3622 |
type names defined in the grammar and the semantic value type |
type names defined in the grammar and the semantic value type |
3623 |
@code{YYSTYPE}, as well as a few @code{extern} variable declarations. |
@code{YYSTYPE}, as well as a few @code{extern} variable declarations. |
3629 |
@code{yylex} in a separate source file, because @code{yylex} needs to |
@code{yylex} in a separate source file, because @code{yylex} needs to |
3630 |
be able to refer to token type codes and the variable |
be able to refer to token type codes and the variable |
3631 |
@code{yylval}. @xref{Token Values, ,Semantic Values of Tokens}. |
@code{yylval}. @xref{Token Values, ,Semantic Values of Tokens}. |
3632 |
|
@end deffn |
3633 |
|
|
3634 |
@item %destructor |
@deffn {Directive} %destructor |
3635 |
Specifying how the parser should reclaim the memory associated to |
Specifying how the parser should reclaim the memory associated to |
3636 |
discarded symbols. @xref{Destructor Decl, , Freeing Discarded Symbols}. |
discarded symbols. @xref{Destructor Decl, , Freeing Discarded Symbols}. |
3637 |
|
@end deffn |
3638 |
|
|
3639 |
@item %file-prefix="@var{prefix}" |
@deffn {Directive} %file-prefix="@var{prefix}" |
3640 |
Specify a prefix to use for all Bison output file names. The names are |
Specify a prefix to use for all Bison output file names. The names are |
3641 |
chosen as if the input file were named @file{@var{prefix}.y}. |
chosen as if the input file were named @file{@var{prefix}.y}. |
3642 |
|
@end deffn |
3643 |
|
|
3644 |
@c @item %header-extension |
@deffn {Directive} %locations |
|
@c Specify the extension of the parser header file generated when |
|
|
@c @code{%define} or @samp{-d} are used. |
|
|
@c |
|
|
@c For example, a grammar file named @file{foo.ypp} and containing a |
|
|
@c @code{%header-extension .hh} directive will produce a header file |
|
|
@c named @file{foo.tab.hh} |
|
|
|
|
|
@item %locations |
|
3645 |
Generate the code processing the locations (@pxref{Action Features, |
Generate the code processing the locations (@pxref{Action Features, |
3646 |
,Special Features for Use in Actions}). This mode is enabled as soon as |
,Special Features for Use in Actions}). This mode is enabled as soon as |
3647 |
the grammar uses the special @samp{@@@var{n}} tokens, but if your |
the grammar uses the special @samp{@@@var{n}} tokens, but if your |
3648 |
grammar does not use it, using @samp{%locations} allows for more |
grammar does not use it, using @samp{%locations} allows for more |
3649 |
accurate parse error messages. |
accurate parse error messages. |
3650 |
|
@end deffn |
3651 |
|
|
3652 |
@item %name-prefix="@var{prefix}" |
@deffn {Directive} %name-prefix="@var{prefix}" |
3653 |
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 |
3654 |
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed |
@var{prefix} instead of @samp{yy}. The precise list of symbols renamed |
3655 |
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs}, |
is @code{yyparse}, @code{yylex}, @code{yyerror}, @code{yynerrs}, |
3658 |
@samp{%name-prefix="c_"}, the names become @code{c_parse}, @code{c_lex}, |
@samp{%name-prefix="c_"}, the names become @code{c_parse}, @code{c_lex}, |
3659 |
and so on. @xref{Multiple Parsers, ,Multiple Parsers in the Same |
and so on. @xref{Multiple Parsers, ,Multiple Parsers in the Same |
3660 |
Program}. |
Program}. |
3661 |
|
@end deffn |
3662 |
|
|
3663 |
@item %no-parser |
@deffn {Directive} %no-parser |
3664 |
Do not include any C code in the parser file; generate tables only. The |
Do not include any C code in the parser file; generate tables only. The |
3665 |
parser file contains just @code{#define} directives and static variable |
parser file contains just @code{#define} directives and static variable |
3666 |
declarations. |
declarations. |
3668 |
This option also tells Bison to write the C code for the grammar actions |
This option also tells Bison to write the C code for the grammar actions |
3669 |
into a file named @file{@var{filename}.act}, in the form of a |
into a file named @file{@var{filename}.act}, in the form of a |
3670 |
brace-surrounded body fit for a @code{switch} statement. |
brace-surrounded body fit for a @code{switch} statement. |
3671 |
|
@end deffn |
3672 |
|
|
3673 |
@item %no-lines |
@deffn {Directive} %no-lines |
3674 |
Don't generate any @code{#line} preprocessor commands in the parser |
Don't generate any @code{#line} preprocessor commands in the parser |
3675 |
file. Ordinarily Bison writes these commands in the parser file so that |
file. Ordinarily Bison writes these commands in the parser file so that |
3676 |
the C compiler and debuggers will associate errors and object code with |
the C compiler and debuggers will associate errors and object code with |
3677 |
your source file (the grammar file). This directive causes them to |
your source file (the grammar file). This directive causes them to |
3678 |
associate errors with the parser file, treating it an independent source |
associate errors with the parser file, treating it an independent source |
3679 |
file in its own right. |
file in its own right. |
3680 |
|
@end deffn |
3681 |
|
|
3682 |
@item %output="@var{filename}" |
@deffn {Directive} %output="@var{filename}" |
3683 |
Specify the @var{filename} for the parser file. |
Specify the @var{filename} for the parser file. |
3684 |
|
@end deffn |
3685 |
|
|
3686 |
@item %pure-parser |
@deffn {Directive} %pure-parser |
3687 |
Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure |
Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure |
3688 |
(Reentrant) Parser}). |
(Reentrant) Parser}). |
3689 |
|
@end deffn |
3690 |
|
|
3691 |
@c @item %source-extension |
@deffn {Directive} %token-table |
|
@c Specify the extension of the parser output file. |
|
|
@c |
|
|
@c For example, a grammar file named @file{foo.yy} and containing a |
|
|
@c @code{%source-extension .cpp} directive will produce a parser file |
|
|
@c named @file{foo.tab.cpp} |
|
|
|
|
|
@item %token-table |
|
3692 |
Generate an array of token names in the parser file. The name of the |
Generate an array of token names in the parser file. The name of the |
3693 |
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the |
array is @code{yytname}; @code{yytname[@var{i}]} is the name of the |
3694 |
token whose internal Bison token code number is @var{i}. The first |
token whose internal Bison token code number is @var{i}. The first |
3720 |
@item YYNSTATES |
@item YYNSTATES |
3721 |
The number of parser states (@pxref{Parser States}). |
The number of parser states (@pxref{Parser States}). |
3722 |
@end table |
@end table |
3723 |
|
@end deffn |
3724 |
|
|
3725 |
@item %verbose |
@deffn {Directive} %verbose |
3726 |
Write an extra output file containing verbose descriptions of the |
Write an extra output file containing verbose descriptions of the |
3727 |
parser states and what is done for each type of look-ahead token in |
parser states and what is done for each type of look-ahead token in |
3728 |
that state. @xref{Understanding, , Understanding Your Parser}, for more |
that state. @xref{Understanding, , Understanding Your Parser}, for more |
3729 |
information. |
information. |
3730 |
|
@end deffn |
3731 |
|
|
3732 |
@item %yacc |
@deffn {Directive} %yacc |
3733 |
Pretend the option @option{--yacc} was given, i.e., imitate Yacc, |
Pretend the option @option{--yacc} was given, i.e., imitate Yacc, |
3734 |
including its naming conventions. @xref{Bison Options}, for more. |
including its naming conventions. @xref{Bison Options}, for more. |
3735 |
@end table |
@end deffn |
|
|
|
|
|
|
3736 |
|
|
3737 |
|
|
3738 |
@node Multiple Parsers |
@node Multiple Parsers |
4219 |
Here is a table of Bison constructs, variables and macros that |
Here is a table of Bison constructs, variables and macros that |
4220 |
are useful in actions. |
are useful in actions. |
4221 |
|
|
4222 |
@table @samp |
@deffn {Variable} $$ |
|
@item $$ |
|
4223 |
Acts like a variable that contains the semantic value for the |
Acts like a variable that contains the semantic value for the |
4224 |
grouping made by the current rule. @xref{Actions}. |
grouping made by the current rule. @xref{Actions}. |
4225 |
|
@end deffn |
4226 |
|
|
4227 |
@item $@var{n} |
@deffn {Variable} $@var{n} |
4228 |
Acts like a variable that contains the semantic value for the |
Acts like a variable that contains the semantic value for the |
4229 |
@var{n}th component of the current rule. @xref{Actions}. |
@var{n}th component of the current rule. @xref{Actions}. |
4230 |
|
@end deffn |
4231 |
|
|
4232 |
@item $<@var{typealt}>$ |
@deffn {Variable} $<@var{typealt}>$ |
4233 |
Like @code{$$} but specifies alternative @var{typealt} in the union |
Like @code{$$} but specifies alternative @var{typealt} in the union |
4234 |
specified by the @code{%union} declaration. @xref{Action Types, ,Data |
specified by the @code{%union} declaration. @xref{Action Types, ,Data |
4235 |
Types of Values in Actions}. |
Types of Values in Actions}. |
4236 |
|
@end deffn |
4237 |
|
|
4238 |
@item $<@var{typealt}>@var{n} |
@deffn {Variable} $<@var{typealt}>@var{n} |
4239 |
Like @code{$@var{n}} but specifies alternative @var{typealt} in the |
Like @code{$@var{n}} but specifies alternative @var{typealt} in the |
4240 |
union specified by the @code{%union} declaration. |
union specified by the @code{%union} declaration. |
4241 |
@xref{Action Types, ,Data Types of Values in Actions}. |
@xref{Action Types, ,Data Types of Values in Actions}. |
4242 |
|
@end deffn |
4243 |
|
|
4244 |
@item YYABORT; |
@deffn {Macro} YYABORT; |
4245 |
Return immediately from @code{yyparse}, indicating failure. |
Return immediately from @code{yyparse}, indicating failure. |
4246 |
@xref{Parser Function, ,The Parser Function @code{yyparse}}. |
@xref{Parser Function, ,The Parser Function @code{yyparse}}. |
4247 |
|
@end deffn |
4248 |
|
|
4249 |
@item YYACCEPT; |
@deffn {Macro} YYACCEPT; |
4250 |
Return immediately from @code{yyparse}, indicating success. |
Return immediately from @code{yyparse}, indicating success. |
4251 |
@xref{Parser Function, ,The Parser Function @code{yyparse}}. |
@xref{Parser Function, ,The Parser Function @code{yyparse}}. |
4252 |
|
@end deffn |
4253 |
|
|
4254 |
@item YYBACKUP (@var{token}, @var{value}); |
@deffn {Macro} YYBACKUP (@var{token}, @var{value}); |
4255 |
@findex YYBACKUP |
@findex YYBACKUP |
4256 |
Unshift a token. This macro is allowed only for rules that reduce |
Unshift a token. This macro is allowed only for rules that reduce |
4257 |
a single value, and only when there is no look-ahead token. |
a single value, and only when there is no look-ahead token. |
4266 |
recovery. |
recovery. |
4267 |
|
|
4268 |
In either case, the rest of the action is not executed. |
In either case, the rest of the action is not executed. |
4269 |
|
@end deffn |
4270 |
|
|
4271 |
@item YYEMPTY |
@deffn {Macro} YYEMPTY |
4272 |
@vindex YYEMPTY |
@vindex YYEMPTY |
4273 |
Value stored in @code{yychar} when there is no look-ahead token. |
Value stored in @code{yychar} when there is no look-ahead token. |
4274 |
|
@end deffn |
4275 |
|
|
4276 |
@item YYERROR; |
@deffn {Macro} YYERROR; |
4277 |
@findex YYERROR |
@findex YYERROR |
4278 |
Cause an immediate syntax error. This statement initiates error |
Cause an immediate syntax error. This statement initiates error |
4279 |
recovery just as if the parser itself had detected an error; however, it |
recovery just as if the parser itself had detected an error; however, it |
4280 |
does not call @code{yyerror}, and does not print any message. If you |
does not call @code{yyerror}, and does not print any message. If you |
4281 |
want to print an error message, call @code{yyerror} explicitly before |
want to print an error message, call @code{yyerror} explicitly before |
4282 |
the @samp{YYERROR;} statement. @xref{Error Recovery}. |
the @samp{YYERROR;} statement. @xref{Error Recovery}. |
4283 |
|
@end deffn |
4284 |
|
|
4285 |
@item YYRECOVERING |
@deffn {Macro} YYRECOVERING |
4286 |
This macro stands for an expression that has the value 1 when the parser |
This macro stands for an expression that has the value 1 when the parser |
4287 |
is recovering from a syntax error, and 0 the rest of the time. |
is recovering from a syntax error, and 0 the rest of the time. |
4288 |
@xref{Error Recovery}. |
@xref{Error Recovery}. |
4289 |
|
@end deffn |
4290 |
|
|
4291 |
@item yychar |
@deffn {Variable} yychar |
4292 |
Variable containing the current look-ahead token. (In a pure parser, |
Variable containing the current look-ahead token. (In a pure parser, |
4293 |
this is actually a local variable within @code{yyparse}.) When there is |
this is actually a local variable within @code{yyparse}.) When there is |
4294 |
no look-ahead token, the value @code{YYEMPTY} is stored in the variable. |
no look-ahead token, the value @code{YYEMPTY} is stored in the variable. |
4295 |
@xref{Look-Ahead, ,Look-Ahead Tokens}. |
@xref{Look-Ahead, ,Look-Ahead Tokens}. |
4296 |
|
@end deffn |
4297 |
|
|
4298 |
@item yyclearin; |
@deffn {Macro} yyclearin; |
4299 |
Discard the current look-ahead token. This is useful primarily in |
Discard the current look-ahead token. This is useful primarily in |
4300 |
error rules. @xref{Error Recovery}. |
error rules. @xref{Error Recovery}. |
4301 |
|
@end deffn |
4302 |
|
|
4303 |
@item yyerrok; |
@deffn {Macro} yyerrok; |
4304 |
Resume generating error messages immediately for subsequent syntax |
Resume generating error messages immediately for subsequent syntax |
4305 |
errors. This is useful primarily in error rules. |
errors. This is useful primarily in error rules. |
4306 |
@xref{Error Recovery}. |
@xref{Error Recovery}. |
4307 |
|
@end deffn |
4308 |
|
|
4309 |
@item @@$ |
@deffn {Value} @@$ |
4310 |
@findex @@$ |
@findex @@$ |
4311 |
Acts like a structure variable containing information on the textual position |
Acts like a structure variable containing information on the textual position |
4312 |
of the grouping made by the current rule. @xref{Locations, , |
of the grouping made by the current rule. @xref{Locations, , |
4330 |
@c those members. |
@c those members. |
4331 |
|
|
4332 |
@c The use of this feature makes the parser noticeably slower. |
@c The use of this feature makes the parser noticeably slower. |
4333 |
|
@end deffn |
4334 |
|
|
4335 |
@item @@@var{n} |
@deffn {Value} @@@var{n} |
4336 |
@findex @@@var{n} |
@findex @@@var{n} |
4337 |
Acts like a structure variable containing information on the textual position |
Acts like a structure variable containing information on the textual position |
4338 |
of the @var{n}th component of the current rule. @xref{Locations, , |
of the @var{n}th component of the current rule. @xref{Locations, , |
4339 |
Tracking Locations}. |
Tracking Locations}. |
4340 |
|
@end deffn |
4341 |
|
|
|
@end table |
|
4342 |
|
|
4343 |
@node Algorithm |
@node Algorithm |
4344 |
@chapter The Bison Parser Algorithm |
@chapter The Bison Parser Algorithm |
6234 |
@cindex Bison symbols, table of |
@cindex Bison symbols, table of |
6235 |
@cindex symbols in Bison, table of |
@cindex symbols in Bison, table of |
6236 |
|
|
6237 |
@table @code |
@deffn {Variable} @@$ |
|
@item @@$ |
|
6238 |
In an action, the location of the left-hand side of the rule. |
In an action, the location of the left-hand side of the rule. |
6239 |
@xref{Locations, , Locations Overview}. |
@xref{Locations, , Locations Overview}. |
6240 |
|
@end deffn |
6241 |
|
|
6242 |
@item @@@var{n} |
@deffn {Variable} @@@var{n} |
6243 |
In an action, the location of the @var{n}-th symbol of the right-hand |
In an action, the location of the @var{n}-th symbol of the right-hand |
6244 |
side of the rule. @xref{Locations, , Locations Overview}. |
side of the rule. @xref{Locations, , Locations Overview}. |
6245 |
|
@end deffn |
6246 |
|
|
6247 |
@item $$ |
@deffn {Variable} $$ |
6248 |
In an action, the semantic value of the left-hand side of the rule. |
In an action, the semantic value of the left-hand side of the rule. |
6249 |
@xref{Actions}. |
@xref{Actions}. |
6250 |
|
@end deffn |
6251 |
|
|
6252 |
@item $@var{n} |
@deffn {Variable} $@var{n} |
6253 |
In an action, the semantic value of the @var{n}-th symbol of the |
In an action, the semantic value of the @var{n}-th symbol of the |
6254 |
right-hand side of the rule. @xref{Actions}. |
right-hand side of the rule. @xref{Actions}. |
6255 |
|
@end deffn |
6256 |
|
|
6257 |
@item $accept |
@deffn {Symbol} $accept |
6258 |
The predefined nonterminal whose only rule is @samp{$accept: @var{start} |
The predefined nonterminal whose only rule is @samp{$accept: @var{start} |
6259 |
$end}, where @var{start} is the start symbol. @xref{Start Decl, , The |
$end}, where @var{start} is the start symbol. @xref{Start Decl, , The |
6260 |
Start-Symbol}. It cannot be used in the grammar. |
Start-Symbol}. It cannot be used in the grammar. |
6261 |
|
@end deffn |
6262 |
|
|
6263 |
@item $end |
@deffn {Symbol} $end |
6264 |
The predefined token marking the end of the token stream. It cannot be |
The predefined token marking the end of the token stream. It cannot be |
6265 |
used in the grammar. |
used in the grammar. |
6266 |
|
@end deffn |
6267 |
|
|
6268 |
@item $undefined |
@deffn {Symbol} $undefined |
6269 |
The predefined token onto which all undefined values returned by |
The predefined token onto which all undefined values returned by |
6270 |
@code{yylex} are mapped. It cannot be used in the grammar, rather, use |
@code{yylex} are mapped. It cannot be used in the grammar, rather, use |
6271 |
@code{error}. |
@code{error}. |
6272 |
|
@end deffn |
6273 |
|
|
6274 |
@item error |
@deffn {Symbol} error |
6275 |
A token name reserved for error recovery. This token may be used in |
A token name reserved for error recovery. This token may be used in |
6276 |
grammar rules so as to allow the Bison parser to recognize an error in |
grammar rules so as to allow the Bison parser to recognize an error in |
6277 |
the grammar without halting the process. In effect, a sentence |
the grammar without halting the process. In effect, a sentence |
6280 |
corresponding to @code{error} are then executed, and the look-ahead |
corresponding to @code{error} are then executed, and the look-ahead |
6281 |
token is reset to the token that originally caused the violation. |
token is reset to the token that originally caused the violation. |
6282 |
@xref{Error Recovery}. |
@xref{Error Recovery}. |
6283 |
|
@end deffn |
6284 |
|
|
6285 |
@item YYABORT |
@deffn {Macro} YYABORT |
6286 |
Macro to pretend that an unrecoverable syntax error has occurred, by |
Macro to pretend that an unrecoverable syntax error has occurred, by |
6287 |
making @code{yyparse} return 1 immediately. The error reporting |
making @code{yyparse} return 1 immediately. The error reporting |
6288 |
function @code{yyerror} is not called. @xref{Parser Function, ,The |
function @code{yyerror} is not called. @xref{Parser Function, ,The |
6289 |
Parser Function @code{yyparse}}. |
Parser Function @code{yyparse}}. |
6290 |
|
@end deffn |
6291 |
|
|
6292 |
@item YYACCEPT |
@deffn {Macro} YYACCEPT |
6293 |
Macro to pretend that a complete utterance of the language has been |
Macro to pretend that a complete utterance of the language has been |
6294 |
read, by making @code{yyparse} return 0 immediately. |
read, by making @code{yyparse} return 0 immediately. |
6295 |
@xref{Parser Function, ,The Parser Function @code{yyparse}}. |
@xref{Parser Function, ,The Parser Function @code{yyparse}}. |
6296 |
|
@end deffn |
6297 |
|
|
6298 |
@item YYBACKUP |
@deffn {Macro} YYBACKUP |
6299 |
Macro to discard a value from the parser stack and fake a look-ahead |
Macro to discard a value from the parser stack and fake a look-ahead |
6300 |
token. @xref{Action Features, ,Special Features for Use in Actions}. |
token. @xref{Action Features, ,Special Features for Use in Actions}. |
6301 |
|
@end deffn |
6302 |
|
|
6303 |
@item YYDEBUG |
@deffn {Macro} YYDEBUG |
6304 |
Macro to define to equip the parser with tracing code. @xref{Tracing, |
Macro to define to equip the parser with tracing code. @xref{Tracing, |
6305 |
,Tracing Your Parser}. |
,Tracing Your Parser}. |
6306 |
|
@end deffn |
6307 |
|
|
6308 |
@item YYERROR |
@deffn {Macro} YYERROR |
6309 |
Macro to pretend that a syntax error has just been detected: call |
Macro to pretend that a syntax error has just been detected: call |
6310 |
@code{yyerror} and then perform normal error recovery if possible |
@code{yyerror} and then perform normal error recovery if possible |
6311 |
(@pxref{Error Recovery}), or (if recovery is impossible) make |
(@pxref{Error Recovery}), or (if recovery is impossible) make |
6312 |
@code{yyparse} return 1. @xref{Error Recovery}. |
@code{yyparse} return 1. @xref{Error Recovery}. |
6313 |
|
@end deffn |
6314 |
|
|
6315 |
@item YYERROR_VERBOSE |
@deffn {Macro} YYERROR_VERBOSE |
6316 |
An obsolete macro that you define with @code{#define} in the Bison |
An obsolete macro that you define with @code{#define} in the Bison |
6317 |
declarations section to request verbose, specific error message strings |
declarations section to request verbose, specific error message strings |
6318 |
when @code{yyerror} is called. It doesn't matter what definition you |
when @code{yyerror} is called. It doesn't matter what definition you |
6319 |
use for @code{YYERROR_VERBOSE}, just whether you define it. Using |
use for @code{YYERROR_VERBOSE}, just whether you define it. Using |
6320 |
@code{%error-verbose} is preferred. |
@code{%error-verbose} is preferred. |
6321 |
|
@end deffn |
6322 |
|
|
6323 |
@item YYINITDEPTH |
@deffn {Macro} YYINITDEPTH |
6324 |
Macro for specifying the initial size of the parser stack. |
Macro for specifying the initial size of the parser stack. |
6325 |
@xref{Stack Overflow}. |
@xref{Stack Overflow}. |
6326 |
|
@end deffn |
6327 |
|
|
6328 |
@item YYLEX_PARAM |
@deffn {Macro} YYLEX_PARAM |
6329 |
An obsolete macro for specifying an extra argument (or list of extra |
An obsolete macro for specifying an extra argument (or list of extra |
6330 |
arguments) for @code{yyparse} to pass to @code{yylex}. he use of this |
arguments) for @code{yyparse} to pass to @code{yylex}. he use of this |
6331 |
macro is deprecated, and is supported only for Yacc like parsers. |
macro is deprecated, and is supported only for Yacc like parsers. |
6332 |
@xref{Pure Calling,, Calling Conventions for Pure Parsers}. |
@xref{Pure Calling,, Calling Conventions for Pure Parsers}. |
6333 |
|
@end deffn |
6334 |
|
|
6335 |
@item YYLTYPE |
@deffn {Macro} YYLTYPE |
6336 |
Macro for the data type of @code{yylloc}; a structure with four |
Macro for the data type of @code{yylloc}; a structure with four |
6337 |
members. @xref{Location Type, , Data Types of Locations}. |
members. @xref{Location Type, , Data Types of Locations}. |
6338 |
|
@end deffn |
6339 |
|
|
6340 |
@item yyltype |
@deffn {Type} yyltype |
6341 |
Default value for YYLTYPE. |
Default value for YYLTYPE. |
6342 |
|
@end deffn |
6343 |
|
|
6344 |
@item YYMAXDEPTH |
@deffn {Macro} YYMAXDEPTH |
6345 |
Macro for specifying the maximum size of the parser stack. |
Macro for specifying the maximum size of the parser stack. @xref{Stack |
6346 |
@xref{Stack Overflow}. |
Overflow}. |
6347 |
|
@end deffn |
6348 |
|
|
6349 |
@item YYPARSE_PARAM |
@deffn {Macro} YYPARSE_PARAM |
6350 |
An obsolete macro for specifying the name of a parameter that |
An obsolete macro for specifying the name of a parameter that |
6351 |
@code{yyparse} should accept. The use of this macro is deprecated, and |
@code{yyparse} should accept. The use of this macro is deprecated, and |
6352 |
is supported only for Yacc like parsers. @xref{Pure Calling,, Calling |
is supported only for Yacc like parsers. @xref{Pure Calling,, Calling |
6353 |
Conventions for Pure Parsers}. |
Conventions for Pure Parsers}. |
6354 |
|
@end deffn |
6355 |
|
|
6356 |
@item YYRECOVERING |
@deffn {Macro} YYRECOVERING |
6357 |
Macro whose value indicates whether the parser is recovering from a |
Macro whose value indicates whether the parser is recovering from a |
6358 |
syntax error. @xref{Action Features, ,Special Features for Use in Actions}. |
syntax error. @xref{Action Features, ,Special Features for Use in Actions}. |
6359 |
|
@end deffn |
6360 |
|
|
6361 |
@item YYSTACK_USE_ALLOCA |
@deffn {Macro} YYSTACK_USE_ALLOCA |
6362 |
Macro used to control the use of @code{alloca}. If defined to @samp{0}, |
Macro used to control the use of @code{alloca}. If defined to @samp{0}, |
6363 |
the parser will not use @code{alloca} but @code{malloc} when trying to |
the parser will not use @code{alloca} but @code{malloc} when trying to |
6364 |
grow its internal stacks. Do @emph{not} define @code{YYSTACK_USE_ALLOCA} |
grow its internal stacks. Do @emph{not} define @code{YYSTACK_USE_ALLOCA} |
6365 |
to anything else. |
to anything else. |
6366 |
|
@end deffn |
6367 |
|
|
6368 |
@item YYSTYPE |
@deffn {Macro} YYSTYPE |
6369 |
Macro for the data type of semantic values; @code{int} by default. |
Macro for the data type of semantic values; @code{int} by default. |
6370 |
@xref{Value Type, ,Data Types of Semantic Values}. |
@xref{Value Type, ,Data Types of Semantic Values}. |
6371 |
|
@end deffn |
6372 |
|
|
6373 |
@item yychar |
@deffn {Variable} yychar |
6374 |
External integer variable that contains the integer value of the current |
External integer variable that contains the integer value of the current |
6375 |
look-ahead token. (In a pure parser, it is a local variable within |
look-ahead token. (In a pure parser, it is a local variable within |
6376 |
@code{yyparse}.) Error-recovery rule actions may examine this variable. |
@code{yyparse}.) Error-recovery rule actions may examine this variable. |
6377 |
@xref{Action Features, ,Special Features for Use in Actions}. |
@xref{Action Features, ,Special Features for Use in Actions}. |
6378 |
|
@end deffn |
6379 |
|
|
6380 |
@item yyclearin |
@deffn {Variable} yyclearin |
6381 |
Macro used in error-recovery rule actions. It clears the previous |
Macro used in error-recovery rule actions. It clears the previous |
6382 |
look-ahead token. @xref{Error Recovery}. |
look-ahead token. @xref{Error Recovery}. |
6383 |
|
@end deffn |
6384 |
|
|
6385 |
@item yydebug |
@deffn {Variable} yydebug |
6386 |
External integer variable set to zero by default. If @code{yydebug} |
External integer variable set to zero by default. If @code{yydebug} |
6387 |
is given a nonzero value, the parser will output information on input |
is given a nonzero value, the parser will output information on input |
6388 |
symbols and parser action. @xref{Tracing, ,Tracing Your Parser}. |
symbols and parser action. @xref{Tracing, ,Tracing Your Parser}. |
6389 |
|
@end deffn |
6390 |
|
|
6391 |
@item yyerrok |
@deffn {Macro} yyerrok |
6392 |
Macro to cause parser to recover immediately to its normal mode |
Macro to cause parser to recover immediately to its normal mode |
6393 |
after a parse error. @xref{Error Recovery}. |
after a parse error. @xref{Error Recovery}. |
6394 |
|
@end deffn |
6395 |
|
|
6396 |
@item yyerror |
@deffn {Function} yyerror |
6397 |
User-supplied function to be called by @code{yyparse} on error. The |
User-supplied function to be called by @code{yyparse} on error. The |
6398 |
function receives one argument, a pointer to a character string |
function receives one argument, a pointer to a character string |
6399 |
containing an error message. @xref{Error Reporting, ,The Error |
containing an error message. @xref{Error Reporting, ,The Error |
6400 |
Reporting Function @code{yyerror}}. |
Reporting Function @code{yyerror}}. |
6401 |
|
@end deffn |
6402 |
|
|
6403 |
@item yylex |
@deffn {Function} yylex |
6404 |
User-supplied lexical analyzer function, called with no arguments to get |
User-supplied lexical analyzer function, called with no arguments to get |
6405 |
the next token. @xref{Lexical, ,The Lexical Analyzer Function |
the next token. @xref{Lexical, ,The Lexical Analyzer Function |
6406 |
@code{yylex}}. |
@code{yylex}}. |
6407 |
|
@end deffn |
6408 |
|
|
6409 |
@item yylval |
@deffn {Variable} yylval |
6410 |
External variable in which @code{yylex} should place the semantic |
External variable in which @code{yylex} should place the semantic |
6411 |
value associated with a token. (In a pure parser, it is a local |
value associated with a token. (In a pure parser, it is a local |
6412 |
variable within @code{yyparse}, and its address is passed to |
variable within @code{yyparse}, and its address is passed to |
6413 |
@code{yylex}.) @xref{Token Values, ,Semantic Values of Tokens}. |
@code{yylex}.) @xref{Token Values, ,Semantic Values of Tokens}. |
6414 |
|
@end deffn |
6415 |
|
|
6416 |
@item yylloc |
@deffn {Variable} yylloc |
6417 |
External variable in which @code{yylex} should place the line and column |
External variable in which @code{yylex} should place the line and column |
6418 |
numbers associated with a token. (In a pure parser, it is a local |
numbers associated with a token. (In a pure parser, it is a local |
6419 |
variable within @code{yyparse}, and its address is passed to |
variable within @code{yyparse}, and its address is passed to |
6420 |
@code{yylex}.) You can ignore this variable if you don't use the |
@code{yylex}.) You can ignore this variable if you don't use the |
6421 |
@samp{@@} feature in the grammar actions. @xref{Token Positions, |
@samp{@@} feature in the grammar actions. @xref{Token Positions, |
6422 |
,Textual Positions of Tokens}. |
,Textual Positions of Tokens}. |
6423 |
|
@end deffn |
6424 |
|
|
6425 |
@item yynerrs |
@deffn {Variable} yynerrs |
6426 |
Global variable which Bison increments each time there is a parse error. |
Global variable which Bison increments each time there is a parse error. |
6427 |
(In a pure parser, it is a local variable within @code{yyparse}.) |
(In a pure parser, it is a local variable within @code{yyparse}.) |
6428 |
@xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}. |
@xref{Error Reporting, ,The Error Reporting Function @code{yyerror}}. |
6429 |
|
@end deffn |
6430 |
|
|
6431 |
@item yyparse |
@deffn {Function} yyparse |
6432 |
The parser function produced by Bison; call this function to start |
The parser function produced by Bison; call this function to start |
6433 |
parsing. @xref{Parser Function, ,The Parser Function @code{yyparse}}. |
parsing. @xref{Parser Function, ,The Parser Function @code{yyparse}}. |
6434 |
|
@end deffn |
6435 |
|
|
6436 |
@item %debug |
@deffn {Directive} %debug |
6437 |
Equip the parser for debugging. @xref{Decl Summary}. |
Equip the parser for debugging. @xref{Decl Summary}. |
6438 |
|
@end deffn |
6439 |
|
|
6440 |
@item %defines |
@deffn {Directive} %defines |
6441 |
Bison declaration to create a header file meant for the scanner. |
Bison declaration to create a header file meant for the scanner. |
6442 |
@xref{Decl Summary}. |
@xref{Decl Summary}. |
6443 |
|
@end deffn |
6444 |
|
|
6445 |
@item %destructor |
@deffn {Directive} %destructor |
6446 |
Specifying how the parser should reclaim the memory associated to |
Specifying how the parser should reclaim the memory associated to |
6447 |
discarded symbols. @xref{Destructor Decl, , Freeing Discarded Symbols}. |
discarded symbols. @xref{Destructor Decl, , Freeing Discarded Symbols}. |
6448 |
|
@end deffn |
6449 |
|
|
6450 |
@item %dprec |
@deffn {Directive} %dprec |
6451 |
Bison declaration to assign a precedence to a rule that is used at parse |
Bison declaration to assign a precedence to a rule that is used at parse |
6452 |
time to resolve reduce/reduce conflicts. @xref{GLR Parsers, ,Writing |
time to resolve reduce/reduce conflicts. @xref{GLR Parsers, ,Writing |
6453 |
@acronym{GLR} Parsers}. |
@acronym{GLR} Parsers}. |
6454 |
|
@end deffn |
6455 |
|
|
6456 |
@item %error-verbose |
@deffn {Directive} %error-verbose |
6457 |
Bison declaration to request verbose, specific error message strings |
Bison declaration to request verbose, specific error message strings |
6458 |
when @code{yyerror} is called. |
when @code{yyerror} is called. |
6459 |
|
@end deffn |
6460 |
|
|
6461 |
@item %file-prefix="@var{prefix}" |
@deffn {Directive} %file-prefix="@var{prefix}" |
6462 |
Bison declaration to set the prefix of the output files. @xref{Decl |
Bison declaration to set the prefix of the output files. @xref{Decl |
6463 |
Summary}. |
Summary}. |
6464 |
|
@end deffn |
6465 |
|
|
6466 |
@item %glr-parser |
@deffn {Directive} %glr-parser |
6467 |
Bison declaration to produce a @acronym{GLR} parser. @xref{GLR |
Bison declaration to produce a @acronym{GLR} parser. @xref{GLR |
6468 |
Parsers, ,Writing @acronym{GLR} Parsers}. |
Parsers, ,Writing @acronym{GLR} Parsers}. |
6469 |
|
@end deffn |
6470 |
|
|
6471 |
@c @item %source-extension |
@deffn {Directive} %left |
|
@c Bison declaration to specify the generated parser output file extension. |
|
|
@c @xref{Decl Summary}. |
|
|
@c |
|
|
@c @item %header-extension |
|
|
@c Bison declaration to specify the generated parser header file extension |
|
|
@c if required. @xref{Decl Summary}. |
|
|
|
|
|
@item %left |
|
6472 |
Bison declaration to assign left associativity to token(s). |
Bison declaration to assign left associativity to token(s). |
6473 |
@xref{Precedence Decl, ,Operator Precedence}. |
@xref{Precedence Decl, ,Operator Precedence}. |
6474 |
|
@end deffn |
6475 |
|
|
6476 |
@item %lex-param "@var{argument-declaration}" "@var{argument-name}" |
@deffn {Directive} %lex-param "@var{argument-declaration}" "@var{argument-name}" |
6477 |
Bison declaration to specifying an additional parameter that |
Bison declaration to specifying an additional parameter that |
6478 |
@code{yylex} should accept. @xref{Pure Calling,, Calling Conventions |
@code{yylex} should accept. @xref{Pure Calling,, Calling Conventions |
6479 |
for Pure Parsers}. |
for Pure Parsers}. |
6480 |
|
@end deffn |
6481 |
|
|
6482 |
@item %merge |
@deffn {Directive} %merge |
6483 |
Bison declaration to assign a merging function to a rule. If there is a |
Bison declaration to assign a merging function to a rule. If there is a |
6484 |
reduce/reduce conflict with a rule having the same merging function, the |
reduce/reduce conflict with a rule having the same merging function, the |
6485 |
function is applied to the two semantic values to get a single result. |
function is applied to the two semantic values to get a single result. |
6486 |
@xref{GLR Parsers, ,Writing @acronym{GLR} Parsers}. |
@xref{GLR Parsers, ,Writing @acronym{GLR} Parsers}. |
6487 |
|
@end deffn |
6488 |
|
|
6489 |
@item %name-prefix="@var{prefix}" |
@deffn {Directive} %name-prefix="@var{prefix}" |
6490 |
Bison declaration to rename the external symbols. @xref{Decl Summary}. |
Bison declaration to rename the external symbols. @xref{Decl Summary}. |
6491 |
|
@end deffn |
6492 |
|
|
6493 |
@item %no-lines |
@deffn {Directive} %no-lines |
6494 |
Bison declaration to avoid generating @code{#line} directives in the |
Bison declaration to avoid generating @code{#line} directives in the |
6495 |
parser file. @xref{Decl Summary}. |
parser file. @xref{Decl Summary}. |
6496 |
|
@end deffn |
6497 |
|
|
6498 |
@item %nonassoc |
@deffn {Directive} %nonassoc |
6499 |
Bison declaration to assign non-associativity to token(s). |
Bison declaration to assign non-associativity to token(s). |
6500 |
@xref{Precedence Decl, ,Operator Precedence}. |
@xref{Precedence Decl, ,Operator Precedence}. |
6501 |
|
@end deffn |
6502 |
|
|
6503 |
@item %output="@var{filename}" |
@deffn {Directive} %output="@var{filename}" |
6504 |
Bison declaration to set the name of the parser file. @xref{Decl |
Bison declaration to set the name of the parser file. @xref{Decl |
6505 |
Summary}. |
Summary}. |
6506 |
|
@end deffn |
6507 |
|
|
6508 |
@item %parse-param "@var{argument-declaration}" "@var{argument-name}" |
@deffn {Directive} %parse-param "@var{argument-declaration}" "@var{argument-name}" |
6509 |
Bison declaration to specifying an additional parameter that |
Bison declaration to specifying an additional parameter that |
6510 |
@code{yyparse} should accept. @xref{Parser Function,, The Parser |
@code{yyparse} should accept. @xref{Parser Function,, The Parser |
6511 |
Function @code{yyparse}}. |
Function @code{yyparse}}. |
6512 |
|
@end deffn |
6513 |
|
|
6514 |
@item %prec |
@deffn {Directive} %prec |
6515 |
Bison declaration to assign a precedence to a specific rule. |
Bison declaration to assign a precedence to a specific rule. |
6516 |
@xref{Contextual Precedence, ,Context-Dependent Precedence}. |
@xref{Contextual Precedence, ,Context-Dependent Precedence}. |
6517 |
|
@end deffn |
6518 |
|
|
6519 |
@item %pure-parser |
@deffn {Directive} %pure-parser |
6520 |
Bison declaration to request a pure (reentrant) parser. |
Bison declaration to request a pure (reentrant) parser. |
6521 |
@xref{Pure Decl, ,A Pure (Reentrant) Parser}. |
@xref{Pure Decl, ,A Pure (Reentrant) Parser}. |
6522 |
|
@end deffn |
6523 |
|
|
6524 |
@item %right |
@deffn {Directive} %right |
6525 |
Bison declaration to assign right associativity to token(s). |
Bison declaration to assign right associativity to token(s). |
6526 |
@xref{Precedence Decl, ,Operator Precedence}. |
@xref{Precedence Decl, ,Operator Precedence}. |
6527 |
|
@end deffn |
6528 |
|
|
6529 |
@item %start |
@deffn {Directive} %start |
6530 |
Bison declaration to specify the start symbol. @xref{Start Decl, ,The |
Bison declaration to specify the start symbol. @xref{Start Decl, ,The |
6531 |
Start-Symbol}. |
Start-Symbol}. |
6532 |
|
@end deffn |
6533 |
|
|
6534 |
@item %token |
@deffn {Directive} %token |
6535 |
Bison declaration to declare token(s) without specifying precedence. |
Bison declaration to declare token(s) without specifying precedence. |
6536 |
@xref{Token Decl, ,Token Type Names}. |
@xref{Token Decl, ,Token Type Names}. |
6537 |
|
@end deffn |
6538 |
|
|
6539 |
@item %token-table |
@deffn {Directive} %token-table |
6540 |
Bison declaration to include a token name table in the parser file. |
Bison declaration to include a token name table in the parser file. |
6541 |
@xref{Decl Summary}. |
@xref{Decl Summary}. |
6542 |
|
@end deffn |
6543 |
|
|
6544 |
@item %type |
@deffn {Directive} %type |
6545 |
Bison declaration to declare nonterminals. @xref{Type Decl, |
Bison declaration to declare nonterminals. @xref{Type Decl, |
6546 |
,Nonterminal Symbols}. |
,Nonterminal Symbols}. |
6547 |
|
@end deffn |
6548 |
|
|
6549 |
@item %union |
@deffn {Directive} %union |
6550 |
Bison declaration to specify several possible data types for semantic |
Bison declaration to specify several possible data types for semantic |
6551 |
values. @xref{Union Decl, ,The Collection of Value Types}. |
values. @xref{Union Decl, ,The Collection of Value Types}. |
6552 |
@end table |
@end deffn |
6553 |
|
|
6554 |
@sp 1 |
@sp 1 |
6555 |
|
|
6556 |
These are the punctuation and delimiters used in Bison input: |
These are the punctuation and delimiters used in Bison input: |
6557 |
|
|
6558 |
@table @samp |
@deffn {Delimiter} %% |
|
@item %% |
|
6559 |
Delimiter used to separate the grammar rule section from the |
Delimiter used to separate the grammar rule section from the |
6560 |
Bison declarations section or the epilogue. |
Bison declarations section or the epilogue. |
6561 |
@xref{Grammar Layout, ,The Overall Layout of a Bison Grammar}. |
@xref{Grammar Layout, ,The Overall Layout of a Bison Grammar}. |
6562 |
|
@end deffn |
6563 |
|
|
6564 |
@item %@{ %@} |
@c Don't insert spaces, or check the DVI output. |
6565 |
|
@deffn {Delimiter} %@{@var{code}%@} |
6566 |
All code listed between @samp{%@{} and @samp{%@}} is copied directly to |
All code listed between @samp{%@{} and @samp{%@}} is copied directly to |
6567 |
the output file uninterpreted. Such code forms the prologue of the input |
the output file uninterpreted. Such code forms the prologue of the input |
6568 |
file. @xref{Grammar Outline, ,Outline of a Bison |
file. @xref{Grammar Outline, ,Outline of a Bison |
6569 |
Grammar}. |
Grammar}. |
6570 |
|
@end deffn |
6571 |
|
|
6572 |
@item /*@dots{}*/ |
@deffn {Construct} /*@dots{}*/ |
6573 |
Comment delimiters, as in C. |
Comment delimiters, as in C. |
6574 |
|
@end deffn |
6575 |
|
|
6576 |
@item : |
@deffn {Delimiter} : |
6577 |
Separates a rule's result from its components. @xref{Rules, ,Syntax of |
Separates a rule's result from its components. @xref{Rules, ,Syntax of |
6578 |
Grammar Rules}. |
Grammar Rules}. |
6579 |
|
@end deffn |
6580 |
|
|
6581 |
@item ; |
@deffn {Delimiter} ; |
6582 |
Terminates a rule. @xref{Rules, ,Syntax of Grammar Rules}. |
Terminates a rule. @xref{Rules, ,Syntax of Grammar Rules}. |
6583 |
|
@end deffn |
6584 |
|
|
6585 |
@item | |
@deffn {Delimiter} | |
6586 |
Separates alternate rules for the same result nonterminal. |
Separates alternate rules for the same result nonterminal. |
6587 |
@xref{Rules, ,Syntax of Grammar Rules}. |
@xref{Rules, ,Syntax of Grammar Rules}. |
6588 |
@end table |
@end deffn |
6589 |
|
|
6590 |
@node Glossary |
@node Glossary |
6591 |
@appendix Glossary |
@appendix Glossary |