Grammar declarations may be found in the grammar section.

* src/parse-gram.y (rules_or_grammar_declaration): New.
(declarations): Each declaration may end with a semicolon, not
just...
(grammar_declaration): `"%union"'.
(grammar): Branch to rules_or_grammar_declaration.
This commit is contained in:
Akim Demaille
2002-06-14 17:38:14 +00:00
parent 4515534cd2
commit 1921f1d7a4
4 changed files with 878 additions and 629 deletions

View File

@@ -1,3 +1,14 @@
2002-06-14 Akim Demaille <akim@epita.fr>
Grammar declarations may be found in the grammar section.
* src/parse-gram.y (rules_or_grammar_declaration): New.
(declarations): Each declaration may end with a semicolon, not
just...
(grammar_declaration): `"%union"'.
(grammar): Branch to rules_or_grammar_declaration.
2002-06-14 Akim Demaille <akim@epita.fr>
* src/main.c (main): Invoke scanner_free.

File diff suppressed because it is too large Load Diff

View File

@@ -1,70 +1,124 @@
#ifndef BISON_PARSE_GRAM_H
# define BISON_PARSE_GRAM_H
/* Tokens. */
#ifndef YYTOKENTYPE
# if defined (__STDC__) || defined (__cplusplus)
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
GRAM_EOF = 0,
STRING = 258,
CHARACTER = 259,
INT = 260,
PERCENT_TOKEN = 261,
PERCENT_NTERM = 262,
PERCENT_TYPE = 263,
PERCENT_UNION = 264,
PERCENT_EXPECT = 265,
PERCENT_START = 266,
PERCENT_PREC = 267,
PERCENT_VERBOSE = 268,
PERCENT_ERROR_VERBOSE = 269,
PERCENT_OUTPUT = 270,
PERCENT_FILE_PREFIX = 271,
PERCENT_NAME_PREFIX = 272,
PERCENT_DEFINE = 273,
PERCENT_PURE_PARSER = 274,
PERCENT_DEFINES = 275,
PERCENT_YACC = 276,
PERCENT_DEBUG = 277,
PERCENT_LOCATIONS = 278,
PERCENT_NO_LINES = 279,
PERCENT_SKELETON = 280,
PERCENT_TOKEN_TABLE = 281,
TYPE = 282,
EQUAL = 283,
SEMICOLON = 284,
COLON = 285,
PIPE = 286,
ID = 287,
PERCENT_PERCENT = 288,
PROLOGUE = 289,
EPILOGUE = 290,
BRACED_CODE = 291,
PERCENT_LEFT = 292,
PERCENT_RIGHT = 293,
PERCENT_NONASSOC = 294
};
# endif
/* POSIX requires `int' for tokens in interfaces. */
# define YYTOKENTYPE int
#endif /* !YYTOKENTYPE */
#define GRAM_EOF 0
#define STRING 258
#define CHARACTER 259
#define INT 260
#define PERCENT_TOKEN 261
#define PERCENT_NTERM 262
#define PERCENT_TYPE 263
#define PERCENT_UNION 264
#define PERCENT_EXPECT 265
#define PERCENT_START 266
#define PERCENT_PREC 267
#define PERCENT_VERBOSE 268
#define PERCENT_ERROR_VERBOSE 269
#define PERCENT_OUTPUT 270
#define PERCENT_FILE_PREFIX 271
#define PERCENT_NAME_PREFIX 272
#define PERCENT_DEFINE 273
#define PERCENT_PURE_PARSER 274
#define PERCENT_DEFINES 275
#define PERCENT_YACC 276
#define PERCENT_DEBUG 277
#define PERCENT_LOCATIONS 278
#define PERCENT_NO_LINES 279
#define PERCENT_SKELETON 280
#define PERCENT_TOKEN_TABLE 281
#define TYPE 282
#define EQUAL 283
#define SEMICOLON 284
#define COLON 285
#define PIPE 286
#define ID 287
#define PERCENT_PERCENT 288
#define PROLOGUE 289
#define EPILOGUE 290
#define BRACED_CODE 291
#define PERCENT_LEFT 292
#define PERCENT_RIGHT 293
#define PERCENT_NONASSOC 294
#ifndef YYSTYPE
typedef union
{
#line 74 "parse-gram.y"
typedef union {
symbol_t *symbol;
int integer;
char *string;
associativity assoc;
} yystype;
/* Line 1271 of /home/akim/src/bison/data/bison.simple. */
#line 105 "y.tab.h"
# define YYSTYPE yystype
# define YYSTYPE_IS_TRIVIAL 1
#endif
#ifndef YYLTYPE
typedef struct yyltype
{
int first_line;
int first_column;
int last_line;
int last_column;
} yyltype;
# define YYLTYPE yyltype
# define YYLTYPE_IS_TRIVIAL 1
#endif
# define GRAM_EOF 0
# define STRING 257
# define CHARACTER 258
# define INT 259
# define PERCENT_TOKEN 260
# define PERCENT_NTERM 261
# define PERCENT_TYPE 262
# define PERCENT_UNION 263
# define PERCENT_EXPECT 264
# define PERCENT_START 265
# define PERCENT_LEFT 266
# define PERCENT_RIGHT 267
# define PERCENT_NONASSOC 268
# define PERCENT_PREC 269
# define PERCENT_VERBOSE 270
# define PERCENT_ERROR_VERBOSE 271
# define PERCENT_OUTPUT 272
# define PERCENT_FILE_PREFIX 273
# define PERCENT_NAME_PREFIX 274
# define PERCENT_DEFINE 275
# define PERCENT_PURE_PARSER 276
# define PERCENT_DEFINES 277
# define PERCENT_YACC 278
# define PERCENT_DEBUG 279
# define PERCENT_LOCATIONS 280
# define PERCENT_NO_LINES 281
# define PERCENT_SKELETON 282
# define PERCENT_TOKEN_TABLE 283
# define TYPE 284
# define EQUAL 285
# define SEMICOLON 286
# define COLON 287
# define PIPE 288
# define ID 289
# define PERCENT_PERCENT 290
# define PROLOGUE 291
# define EPILOGUE 292
# define BRACED_CODE 293
#endif /* not BISON_PARSE_GRAM_H */

View File

@@ -89,9 +89,6 @@ int current_prec = 0;
%token PERCENT_UNION "%union"
%token PERCENT_EXPECT "%expect"
%token PERCENT_START "%start"
%token PERCENT_LEFT "%left"
%token PERCENT_RIGHT "%right"
%token PERCENT_NONASSOC "%nonassoc"
%token PERCENT_PREC "%prec"
%token PERCENT_VERBOSE "%verbose"
%token PERCENT_ERROR_VERBOSE "%error-verbose"
@@ -146,7 +143,7 @@ input: { LOCATION_RESET (yylloc); }
declarations:
/* Nothing */
| declarations declaration
| declarations declaration semi_colon.opt
;
declaration:
@@ -176,7 +173,7 @@ grammar_declaration:
{
grammar_start_symbol_set ($2);
}
| "%union" BRACED_CODE semi_colon_opt
| "%union" BRACED_CODE
{
typed = 1;
MUSCLE_INSERT_INT ("stype_line", @2.first_line);
@@ -208,6 +205,9 @@ precedence_declaration:
{ current_assoc = non_assoc; current_type = NULL; }
;
%token PERCENT_LEFT "%left";
%token PERCENT_RIGHT "%right";
%token PERCENT_NONASSOC "%nonassoc";
precedence_declarator:
"%left" { $$ = left_assoc; }
| "%right" { $$ = right_assoc; }
@@ -285,8 +285,16 @@ symbol_defs.1:
`------------------------------------------*/
grammar:
rules_or_grammar_declaration
| grammar rules_or_grammar_declaration
;
/* As a Bison extension, one can use the grammar declarations in the
body of the grammar. But to remain LALR(1), they must be ended
with a semi-colon. */
rules_or_grammar_declaration:
rules
| grammar rules
| grammar_declaration ";"
;
rules:
@@ -350,7 +358,7 @@ epilogue.opt:
}
;
semi_colon_opt:
semi_colon.opt:
/* Nothing. */
| ";"
;