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). |
48 |
|
|
49 |
%% /* Grammar rules and actions follow */ |
%% /* Grammar rules and actions follow */ |
50 |
|
|
51 |
The C declarations section (*note The C Declarations Section: C |
The declarations section (*note The prologue: Prologue.) contains two |
52 |
Declarations.) contains two preprocessor directives. |
preprocessor directives. |
53 |
|
|
54 |
The `#define' directive defines the macro `YYSTYPE', thus specifying |
The `#define' directive defines the macro `YYSTYPE', thus specifying |
55 |
the C data type for semantic values of both tokens and groupings (*note |
the C data type for semantic values of both tokens and groupings (*note |
359 |
arrange all the source code in one or more source files. For such a |
arrange all the source code in one or more source files. For such a |
360 |
simple example, the easiest thing is to put everything in one file. The |
simple example, the easiest thing is to put everything in one file. The |
361 |
definitions of `yylex', `yyerror' and `main' go at the end, in the |
definitions of `yylex', `yyerror' and `main' go at the end, in the |
362 |
"additional C code" section of the file (*note The Overall Layout of a |
epilogue of the file (*note The Overall Layout of a Bison Grammar: |
363 |
Bison Grammar: Grammar Layout.). |
Grammar Layout.). |
364 |
|
|
365 |
For a large project, you would probably have several source files, |
For a large project, you would probably have several source files, |
366 |
and use `make' to arrange to recompile them. |
and use `make' to arrange to recompile them. |
926 |
appropriate delimiters: |
appropriate delimiters: |
927 |
|
|
928 |
%{ |
%{ |
929 |
C DECLARATIONS |
PROLOGUE |
930 |
%} |
%} |
931 |
|
|
932 |
BISON DECLARATIONS |
BISON DECLARATIONS |
935 |
GRAMMAR RULES |
GRAMMAR RULES |
936 |
%% |
%% |
937 |
|
|
938 |
ADDITIONAL C CODE |
EPILOGUE |
939 |
|
|
940 |
Comments enclosed in `/* ... */' may appear in any of the sections. |
Comments enclosed in `/* ... */' may appear in any of the sections. |
941 |
|
|
942 |
* Menu: |
* Menu: |
943 |
|
|
944 |
* C Declarations:: Syntax and usage of the C declarations section. |
* Prologue:: Syntax and usage of the prologue. |
945 |
* Bison Declarations:: Syntax and usage of the Bison declarations section. |
* Bison Declarations:: Syntax and usage of the Bison declarations section. |
946 |
* Grammar Rules:: Syntax and usage of the grammar rules section. |
* Grammar Rules:: Syntax and usage of the grammar rules section. |
947 |
* C Code:: Syntax and usage of the additional C code section. |
* Epilogue:: Syntax and usage of the epilogue. |
948 |
|
|
949 |
|
|
950 |
File: bison.info, Node: C Declarations, Next: Bison Declarations, Up: Grammar Outline |
File: bison.info, Node: Prologue, Next: Bison Declarations, Up: Grammar Outline |
951 |
|
|
952 |
The C Declarations Section |
The prologue |
953 |
-------------------------- |
------------ |
954 |
|
|
955 |
The C DECLARATIONS section contains macro definitions and |
The PROLOGUE section contains macro definitions and declarations of |
956 |
declarations of functions and variables that are used in the actions in |
functions and variables that are used in the actions in the grammar |
957 |
the grammar rules. These are copied to the beginning of the parser |
rules. These are copied to the beginning of the parser file so that |
958 |
file so that they precede the definition of `yyparse'. You can use |
they precede the definition of `yyparse'. You can use `#include' to |
959 |
`#include' to get the declarations from a header file. If you don't |
get the declarations from a header file. If you don't need any C |
960 |
need any C declarations, you may omit the `%{' and `%}' delimiters that |
declarations, you may omit the `%{' and `%}' delimiters that bracket |
961 |
bracket this section. |
this section. |
962 |
|
|
963 |
|
|
964 |
File: bison.info, Node: Bison Declarations, Next: Grammar Rules, Prev: C Declarations, Up: Grammar Outline |
File: bison.info, Node: Bison Declarations, Next: Grammar Rules, Prev: Prologue, Up: Grammar Outline |
965 |
|
|
966 |
The Bison Declarations Section |
The Bison Declarations Section |
967 |
------------------------------ |
------------------------------ |
972 |
Declarations: Declarations. |
Declarations: Declarations. |
973 |
|
|
974 |
|
|
975 |
File: bison.info, Node: Grammar Rules, Next: C Code, Prev: Bison Declarations, Up: Grammar Outline |
File: bison.info, Node: Grammar Rules, Next: Epilogue, Prev: Bison Declarations, Up: Grammar Outline |
976 |
|
|
977 |
The Grammar Rules Section |
The Grammar Rules Section |
978 |
------------------------- |
------------------------- |
985 |
the first thing in the file. |
the first thing in the file. |
986 |
|
|
987 |
|
|
988 |
File: bison.info, Node: C Code, Prev: Grammar Rules, Up: Grammar Outline |
File: bison.info, Node: Epilogue, Prev: Grammar Rules, Up: Grammar Outline |
989 |
|
|
990 |
The Additional C Code Section |
The epilogue |
991 |
----------------------------- |
------------ |
992 |
|
|
993 |
The ADDITIONAL C CODE section is copied verbatim to the end of the |
The EPILOGUE is copied verbatim to the end of the parser file, just |
994 |
parser file, just as the C DECLARATIONS section is copied to the |
as the PROLOGUE is copied to the beginning. This is the most convenient |
995 |
beginning. This is the most convenient place to put anything that you |
place to put anything that you want to have in the parser file but |
996 |
want to have in the parser file but which need not come before the |
which need not come before the definition of `yyparse'. For example, |
997 |
definition of `yyparse'. For example, the definitions of `yylex' and |
the definitions of `yylex' and `yyerror' often go here. *Note Parser |
998 |
`yyerror' often go here. *Note Parser C-Language Interface: Interface. |
C-Language Interface: Interface. |
999 |
|
|
1000 |
If the last section is empty, you may omit the `%%' that separates it |
If the last section is empty, you may omit the `%%' that separates it |
1001 |
from the grammar rules. |
from the grammar rules. |
1003 |
The Bison parser itself contains many static variables whose names |
The Bison parser itself contains many static variables whose names |
1004 |
start with `yy' and many macros whose names start with `YY'. It is a |
start with `yy' and many macros whose names start with `YY'. It is a |
1005 |
good idea to avoid using any such names (except those documented in this |
good idea to avoid using any such names (except those documented in this |
1006 |
manual) in the additional C code section of the grammar file. |
manual) in the epilogue of the grammar file. |
1007 |
|
|
1008 |
|
|
1009 |
File: bison.info, Node: Symbols, Next: Rules, Prev: Grammar Outline, Up: Grammar File |
File: bison.info, Node: Symbols, Next: Rules, Prev: Grammar Outline, Up: Grammar File |
1256 |
|
|
1257 |
#define YYSTYPE double |
#define YYSTYPE double |
1258 |
|
|
1259 |
This macro definition must go in the C declarations section of the |
This macro definition must go in the prologue of the grammar file |
1260 |
grammar file (*note Outline of a Bison Grammar: Grammar Outline.). |
(*note Outline of a Bison Grammar: Grammar Outline.). |
1261 |
|
|
1262 |
|
|
1263 |
File: bison.info, Node: Multiple Types, Next: Actions, Prev: Value Type, Up: Semantics |
File: bison.info, Node: Multiple Types, Next: Actions, Prev: Value Type, Up: Semantics |