mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 14:23:04 +00:00
Consolidate the 4 prologue alternative directives (%code, %requires,
%provides, and %code-top) into a single %code directive with an optional qualifier field. Discussed at <http://lists.gnu.org/archive/html/bison-patches/2007-01/msg00012.html>. * NEWS (2.3a+): Rewrite the existing entry for the prologue alternatives. * doc/bison.texinfo (Prologue Alternatives): Update. (Decl Summary): Update to %code "requires" and %code "provides". (Calc++ Parser): Update to %code "requires". (Bison Symbols): Remove entries for %requires, %provides, and %code-top. Rewrite %code entry, and add a %code "QUALIFIER" entry. * data/bison.m4 (b4_user_provides, b4_user_requires): Remove as these are replaced by b4_percent_code_provides and b4_percent_code_requires, which are skeleton-specific. (b4_check_percent_code_qualifiers): New. A skeleton can use this to declare what %code qualifiers it supports and to complain if any other qualifiers were used in the grammar. * data/glr.cc: Update to use b4_user_code([b4_percent_code_requires]) and b4_user_code([b4_percent_code_provides]) in place of b4_user_requires and b4_user_provides. * data/glr.c, data/lalr1.cc, data/push.c, data/yacc.c: Likewise. Add b4_user_code([b4_percent_code_top]) and b4_user_code([b4_percent_code]). Invoke b4_check_percent_code_qualifiers. * src/parse-gram.y (PERCENT_CODE_TOP, PERCENT_PROVIDES, PERCENT_REQUIRES): Remove. (grammar_declaration): Remove RHS's for %code-top, %provides, and %requires. Rewrite the %code RHS as the unqualified form defining the muscle b4_percent_code. Add another RHS for the qualified %code form, which defines muscles of the form b4_percent_code_QUALIFIER and the b4_used_percent_code_qualifiers muscle. * src/scan-gram.l (PERCENT_CODE_TOP, PERCENT_PROVIDES, PERCENT_REQUIRES): Remove. * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Update to use %code "requires" and %code "provides". * tests/input.at (Reject bad %code qualifiers): New.
This commit is contained in:
1195
src/parse-gram.c
1195
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
180
src/parse-gram.h
180
src/parse-gram.h
@@ -55,51 +55,48 @@
|
||||
PERCENT_DPREC = 269,
|
||||
PERCENT_MERGE = 270,
|
||||
PERCENT_CODE = 271,
|
||||
PERCENT_CODE_TOP = 272,
|
||||
PERCENT_DEBUG = 273,
|
||||
PERCENT_DEFAULT_PREC = 274,
|
||||
PERCENT_DEFINE = 275,
|
||||
PERCENT_DEFINES = 276,
|
||||
PERCENT_ERROR_VERBOSE = 277,
|
||||
PERCENT_EXPECT = 278,
|
||||
PERCENT_EXPECT_RR = 279,
|
||||
PERCENT_FILE_PREFIX = 280,
|
||||
PERCENT_GLR_PARSER = 281,
|
||||
PERCENT_INITIAL_ACTION = 282,
|
||||
PERCENT_LANGUAGE = 283,
|
||||
PERCENT_LEX_PARAM = 284,
|
||||
PERCENT_LOCATIONS = 285,
|
||||
PERCENT_NAME_PREFIX = 286,
|
||||
PERCENT_NO_DEFAULT_PREC = 287,
|
||||
PERCENT_NO_LINES = 288,
|
||||
PERCENT_NONDETERMINISTIC_PARSER = 289,
|
||||
PERCENT_OUTPUT = 290,
|
||||
PERCENT_PARSE_PARAM = 291,
|
||||
PERCENT_PROVIDES = 292,
|
||||
PERCENT_PURE_PARSER = 293,
|
||||
PERCENT_PUSH_PARSER = 294,
|
||||
PERCENT_PUSH_PULL_PARSER = 295,
|
||||
PERCENT_REQUIRE = 296,
|
||||
PERCENT_REQUIRES = 297,
|
||||
PERCENT_SKELETON = 298,
|
||||
PERCENT_START = 299,
|
||||
PERCENT_TOKEN_TABLE = 300,
|
||||
PERCENT_VERBOSE = 301,
|
||||
PERCENT_YACC = 302,
|
||||
BRACED_CODE = 303,
|
||||
CHAR = 304,
|
||||
EPILOGUE = 305,
|
||||
EQUAL = 306,
|
||||
ID = 307,
|
||||
ID_COLON = 308,
|
||||
PERCENT_PERCENT = 309,
|
||||
PIPE = 310,
|
||||
PROLOGUE = 311,
|
||||
SEMICOLON = 312,
|
||||
TYPE = 313,
|
||||
TYPE_TAG_ANY = 314,
|
||||
TYPE_TAG_NONE = 315,
|
||||
PERCENT_UNION = 316
|
||||
PERCENT_DEBUG = 272,
|
||||
PERCENT_DEFAULT_PREC = 273,
|
||||
PERCENT_DEFINE = 274,
|
||||
PERCENT_DEFINES = 275,
|
||||
PERCENT_ERROR_VERBOSE = 276,
|
||||
PERCENT_EXPECT = 277,
|
||||
PERCENT_EXPECT_RR = 278,
|
||||
PERCENT_FILE_PREFIX = 279,
|
||||
PERCENT_GLR_PARSER = 280,
|
||||
PERCENT_INITIAL_ACTION = 281,
|
||||
PERCENT_LANGUAGE = 282,
|
||||
PERCENT_LEX_PARAM = 283,
|
||||
PERCENT_LOCATIONS = 284,
|
||||
PERCENT_NAME_PREFIX = 285,
|
||||
PERCENT_NO_DEFAULT_PREC = 286,
|
||||
PERCENT_NO_LINES = 287,
|
||||
PERCENT_NONDETERMINISTIC_PARSER = 288,
|
||||
PERCENT_OUTPUT = 289,
|
||||
PERCENT_PARSE_PARAM = 290,
|
||||
PERCENT_PURE_PARSER = 291,
|
||||
PERCENT_PUSH_PARSER = 292,
|
||||
PERCENT_PUSH_PULL_PARSER = 293,
|
||||
PERCENT_REQUIRE = 294,
|
||||
PERCENT_SKELETON = 295,
|
||||
PERCENT_START = 296,
|
||||
PERCENT_TOKEN_TABLE = 297,
|
||||
PERCENT_VERBOSE = 298,
|
||||
PERCENT_YACC = 299,
|
||||
BRACED_CODE = 300,
|
||||
CHAR = 301,
|
||||
EPILOGUE = 302,
|
||||
EQUAL = 303,
|
||||
ID = 304,
|
||||
ID_COLON = 305,
|
||||
PERCENT_PERCENT = 306,
|
||||
PIPE = 307,
|
||||
PROLOGUE = 308,
|
||||
SEMICOLON = 309,
|
||||
TYPE = 310,
|
||||
TYPE_TAG_ANY = 311,
|
||||
TYPE_TAG_NONE = 312,
|
||||
PERCENT_UNION = 313
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
@@ -118,51 +115,48 @@
|
||||
#define PERCENT_DPREC 269
|
||||
#define PERCENT_MERGE 270
|
||||
#define PERCENT_CODE 271
|
||||
#define PERCENT_CODE_TOP 272
|
||||
#define PERCENT_DEBUG 273
|
||||
#define PERCENT_DEFAULT_PREC 274
|
||||
#define PERCENT_DEFINE 275
|
||||
#define PERCENT_DEFINES 276
|
||||
#define PERCENT_ERROR_VERBOSE 277
|
||||
#define PERCENT_EXPECT 278
|
||||
#define PERCENT_EXPECT_RR 279
|
||||
#define PERCENT_FILE_PREFIX 280
|
||||
#define PERCENT_GLR_PARSER 281
|
||||
#define PERCENT_INITIAL_ACTION 282
|
||||
#define PERCENT_LANGUAGE 283
|
||||
#define PERCENT_LEX_PARAM 284
|
||||
#define PERCENT_LOCATIONS 285
|
||||
#define PERCENT_NAME_PREFIX 286
|
||||
#define PERCENT_NO_DEFAULT_PREC 287
|
||||
#define PERCENT_NO_LINES 288
|
||||
#define PERCENT_NONDETERMINISTIC_PARSER 289
|
||||
#define PERCENT_OUTPUT 290
|
||||
#define PERCENT_PARSE_PARAM 291
|
||||
#define PERCENT_PROVIDES 292
|
||||
#define PERCENT_PURE_PARSER 293
|
||||
#define PERCENT_PUSH_PARSER 294
|
||||
#define PERCENT_PUSH_PULL_PARSER 295
|
||||
#define PERCENT_REQUIRE 296
|
||||
#define PERCENT_REQUIRES 297
|
||||
#define PERCENT_SKELETON 298
|
||||
#define PERCENT_START 299
|
||||
#define PERCENT_TOKEN_TABLE 300
|
||||
#define PERCENT_VERBOSE 301
|
||||
#define PERCENT_YACC 302
|
||||
#define BRACED_CODE 303
|
||||
#define CHAR 304
|
||||
#define EPILOGUE 305
|
||||
#define EQUAL 306
|
||||
#define ID 307
|
||||
#define ID_COLON 308
|
||||
#define PERCENT_PERCENT 309
|
||||
#define PIPE 310
|
||||
#define PROLOGUE 311
|
||||
#define SEMICOLON 312
|
||||
#define TYPE 313
|
||||
#define TYPE_TAG_ANY 314
|
||||
#define TYPE_TAG_NONE 315
|
||||
#define PERCENT_UNION 316
|
||||
#define PERCENT_DEBUG 272
|
||||
#define PERCENT_DEFAULT_PREC 273
|
||||
#define PERCENT_DEFINE 274
|
||||
#define PERCENT_DEFINES 275
|
||||
#define PERCENT_ERROR_VERBOSE 276
|
||||
#define PERCENT_EXPECT 277
|
||||
#define PERCENT_EXPECT_RR 278
|
||||
#define PERCENT_FILE_PREFIX 279
|
||||
#define PERCENT_GLR_PARSER 280
|
||||
#define PERCENT_INITIAL_ACTION 281
|
||||
#define PERCENT_LANGUAGE 282
|
||||
#define PERCENT_LEX_PARAM 283
|
||||
#define PERCENT_LOCATIONS 284
|
||||
#define PERCENT_NAME_PREFIX 285
|
||||
#define PERCENT_NO_DEFAULT_PREC 286
|
||||
#define PERCENT_NO_LINES 287
|
||||
#define PERCENT_NONDETERMINISTIC_PARSER 288
|
||||
#define PERCENT_OUTPUT 289
|
||||
#define PERCENT_PARSE_PARAM 290
|
||||
#define PERCENT_PURE_PARSER 291
|
||||
#define PERCENT_PUSH_PARSER 292
|
||||
#define PERCENT_PUSH_PULL_PARSER 293
|
||||
#define PERCENT_REQUIRE 294
|
||||
#define PERCENT_SKELETON 295
|
||||
#define PERCENT_START 296
|
||||
#define PERCENT_TOKEN_TABLE 297
|
||||
#define PERCENT_VERBOSE 298
|
||||
#define PERCENT_YACC 299
|
||||
#define BRACED_CODE 300
|
||||
#define CHAR 301
|
||||
#define EPILOGUE 302
|
||||
#define EQUAL 303
|
||||
#define ID 304
|
||||
#define ID_COLON 305
|
||||
#define PERCENT_PERCENT 306
|
||||
#define PIPE 307
|
||||
#define PROLOGUE 308
|
||||
#define SEMICOLON 309
|
||||
#define TYPE 310
|
||||
#define TYPE_TAG_ANY 311
|
||||
#define TYPE_TAG_NONE 312
|
||||
#define PERCENT_UNION 313
|
||||
|
||||
|
||||
|
||||
@@ -170,7 +164,7 @@
|
||||
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
/* Line 1538 of yacc.c */
|
||||
/* Line 1546 of yacc.c */
|
||||
#line 98 "parse-gram.y"
|
||||
|
||||
symbol *symbol;
|
||||
@@ -183,8 +177,8 @@ typedef union YYSTYPE
|
||||
unsigned char character;
|
||||
}
|
||||
|
||||
/* Line 1538 of yacc.c */
|
||||
#line 188 "parse-gram.h"
|
||||
/* Line 1546 of yacc.c */
|
||||
#line 182 "parse-gram.h"
|
||||
YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
||||
@@ -133,7 +133,6 @@ static int current_prec = 0;
|
||||
|
||||
%token
|
||||
PERCENT_CODE "%code"
|
||||
PERCENT_CODE_TOP "%code-top"
|
||||
PERCENT_DEBUG "%debug"
|
||||
PERCENT_DEFAULT_PREC "%default-prec"
|
||||
PERCENT_DEFINE "%define"
|
||||
@@ -154,13 +153,11 @@ static int current_prec = 0;
|
||||
"%nondeterministic-parser"
|
||||
PERCENT_OUTPUT "%output"
|
||||
PERCENT_PARSE_PARAM "%parse-param"
|
||||
PERCENT_PROVIDES "%provides"
|
||||
PERCENT_PURE_PARSER "%pure-parser"
|
||||
PERCENT_PUSH_PARSER "%push-parser"
|
||||
PERCENT_PUSH_PULL_PARSER
|
||||
"%push-pull-parser"
|
||||
PERCENT_REQUIRE "%require"
|
||||
PERCENT_REQUIRES "%requires"
|
||||
PERCENT_SKELETON "%skeleton"
|
||||
PERCENT_START "%start"
|
||||
PERCENT_TOKEN_TABLE "%token-table"
|
||||
@@ -312,10 +309,22 @@ grammar_declaration:
|
||||
{
|
||||
default_prec = false;
|
||||
}
|
||||
| "%code" braceless { prologue_augment ($2, @2, true); }
|
||||
| "%code-top" braceless { prologue_augment ($2, @2, false); }
|
||||
| "%provides" braceless { muscle_code_grow ("provides", $2, @2); }
|
||||
| "%requires" braceless { muscle_code_grow ("requires", $2, @2); }
|
||||
| "%code" braceless
|
||||
{
|
||||
muscle_code_grow ("percent_code", $2, @2);
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
| "%code" STRING braceless
|
||||
{
|
||||
char const name_prefix[] = "percent_code_";
|
||||
char *name = xmalloc (sizeof name_prefix + strlen ($2));
|
||||
strcpy (name, name_prefix);
|
||||
strcpy (name + sizeof name_prefix - 1, $2);
|
||||
muscle_code_grow (uniqstr_new (name), $3, @3);
|
||||
free (name);
|
||||
code_scanner_last_string_free ();
|
||||
muscle_grow ("used_percent_code_qualifiers", $2, ",");
|
||||
}
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -159,7 +159,6 @@ splice (\\[ \f\t\v]*\n)*
|
||||
{
|
||||
"%binary" return PERCENT_NONASSOC;
|
||||
"%code" return PERCENT_CODE;
|
||||
"%code-top" return PERCENT_CODE_TOP;
|
||||
"%debug" return PERCENT_DEBUG;
|
||||
"%default"[-_]"prec" return PERCENT_DEFAULT_PREC;
|
||||
"%define" return PERCENT_DEFINE;
|
||||
@@ -188,12 +187,10 @@ splice (\\[ \f\t\v]*\n)*
|
||||
"%parse-param" return PERCENT_PARSE_PARAM;
|
||||
"%prec" return PERCENT_PREC;
|
||||
"%printer" return PERCENT_PRINTER;
|
||||
"%provides" return PERCENT_PROVIDES;
|
||||
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
|
||||
"%push-parser" return PERCENT_PUSH_PARSER;
|
||||
"%push-pull-parser" return PERCENT_PUSH_PULL_PARSER;
|
||||
"%require" return PERCENT_REQUIRE;
|
||||
"%requires" return PERCENT_REQUIRES;
|
||||
"%right" return PERCENT_RIGHT;
|
||||
"%skeleton" return PERCENT_SKELETON;
|
||||
"%start" return PERCENT_START;
|
||||
|
||||
Reference in New Issue
Block a user