1 |
Ceci est le fichier Info bison.info, produit par Makeinfo version 4.0b |
This is bison.info, produced by makeinfo version 4.0b from |
2 |
à partir bison.texinfo. |
bison.texinfo. |
3 |
|
|
4 |
START-INFO-DIR-ENTRY |
START-INFO-DIR-ENTRY |
5 |
* bison: (bison). GNU Project parser generator (yacc replacement). |
* bison: (bison). GNU Project parser generator (yacc replacement). |
87 |
|
|
88 |
Reverse Polish Notation Calculator |
Reverse Polish Notation Calculator |
89 |
|
|
90 |
* Decls: Rpcalc Decls. Bison and C declarations for rpcalc. |
* Decls: Rpcalc Decls. Prologue (declarations) for rpcalc. |
91 |
* Rules: Rpcalc Rules. Grammar Rules for rpcalc, with explanation. |
* Rules: Rpcalc Rules. Grammar Rules for rpcalc, with explanation. |
92 |
* Lexer: Rpcalc Lexer. The lexical analyzer. |
* Lexer: Rpcalc Lexer. The lexical analyzer. |
93 |
* Main: Rpcalc Main. The controlling function. |
* Main: Rpcalc Main. The controlling function. |
119 |
|
|
120 |
Outline of a Bison Grammar |
Outline of a Bison Grammar |
121 |
|
|
122 |
* C Declarations:: Syntax and usage of the C declarations section. |
* Prologue:: Syntax and usage of the prologue (declarations section). |
123 |
* Bison Declarations:: Syntax and usage of the Bison declarations section. |
* Bison Declarations:: Syntax and usage of the Bison declarations section. |
124 |
* Grammar Rules:: Syntax and usage of the grammar rules section. |
* Grammar Rules:: Syntax and usage of the grammar rules section. |
125 |
* C Code:: Syntax and usage of the additional C code section. |
* Epilogue:: Syntax and usage of the epilogue (additional code section). |
126 |
|
|
127 |
Defining Language Semantics |
Defining Language Semantics |
128 |
|
|
981 |
general form of a Bison grammar file is as follows: |
general form of a Bison grammar file is as follows: |
982 |
|
|
983 |
%{ |
%{ |
984 |
C DECLARATIONS |
PROLOGUE (DECLARATIONS) |
985 |
%} |
%} |
986 |
|
|
987 |
BISON DECLARATIONS |
BISON DECLARATIONS |
989 |
%% |
%% |
990 |
GRAMMAR RULES |
GRAMMAR RULES |
991 |
%% |
%% |
992 |
ADDITIONAL C CODE |
EPILOGUE (ADDITIONAL CODE) |
993 |
|
|
994 |
The `%%', `%{' and `%}' are punctuation that appears in every Bison |
The `%%', `%{' and `%}' are punctuation that appears in every Bison |
995 |
grammar file to separate the sections. |
grammar file to separate the sections. |
996 |
|
|
997 |
The C declarations may define types and variables used in the |
The prologue may define types and variables used in the actions. You |
998 |
actions. You can also use preprocessor commands to define macros used |
can also use preprocessor commands to define macros used there, and use |
999 |
there, and use `#include' to include header files that do any of these |
`#include' to include header files that do any of these things. |
|
things. |
|
1000 |
|
|
1001 |
The Bison declarations declare the names of the terminal and |
The Bison declarations declare the names of the terminal and |
1002 |
nonterminal symbols, and may also describe operator precedence and the |
nonterminal symbols, and may also describe operator precedence and the |
1005 |
The grammar rules define how to construct each nonterminal symbol |
The grammar rules define how to construct each nonterminal symbol |
1006 |
from its parts. |
from its parts. |
1007 |
|
|
1008 |
The additional C code can contain any C code you want to use. Often |
The epilogue can contain any code you want to use. Often the |
1009 |
the definition of the lexical analyzer `yylex' goes here, plus |
definition of the lexical analyzer `yylex' goes here, plus subroutines |
1010 |
subroutines called by the actions in the grammar rules. In a simple |
called by the actions in the grammar rules. In a simple program, all |
1011 |
program, all the rest of the program can go here. |
the rest of the program can go here. |
1012 |
|
|
1013 |
|
|
1014 |
File: bison.info, Node: Examples, Next: Grammar File, Prev: Concepts, Up: Top |
File: bison.info, Node: Examples, Next: Grammar File, Prev: Concepts, Up: Top |
1054 |
|
|
1055 |
* Menu: |
* Menu: |
1056 |
|
|
1057 |
* Decls: Rpcalc Decls. Bison and C declarations for rpcalc. |
* Decls: Rpcalc Decls. Prologue (declarations) for rpcalc. |
1058 |
* Rules: Rpcalc Rules. Grammar Rules for rpcalc, with explanation. |
* Rules: Rpcalc Rules. Grammar Rules for rpcalc, with explanation. |
1059 |
* Lexer: Rpcalc Lexer. The lexical analyzer. |
* Lexer: Rpcalc Lexer. The lexical analyzer. |
1060 |
* Main: Rpcalc Main. The controlling function. |
* Main: Rpcalc Main. The controlling function. |