mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
For push mode, convert yyparse from a macro to a function, invoke yylex
instead of passing a yylexp argument to yypull_parse, and don't generate yypull_parse or yyparse unless %push-pull-parser is declared. Discussed starting at <http://lists.gnu.org/archive/html/bison-patches/2006-12/msg00163.html>. * data/bison.m4 (b4_pull_if): New. * data/c.m4 (b4_identification): Define YYPULL similar to YYPUSH. * data/push.c: Improve M4 quoting a little. (b4_generate_macro_args, b4_parenthesize): Remove. (yyparse): If there's a b4_prefix, #define this to b4_prefix[parse] any time a pull parser is requested. Don't #define this as a wrapper around yypull_parse. Instead, when both push and pull are requested, make it a function that does that same thing. (yypull_parse): If there's a b4_prefix, #define this to b4_prefix[pull_parse] when both push and pull are requested. Don't define this as a function unless both push and pull are requested. Remove the yylexp argument and hard-code yylex invocation instead. * etc/bench.pl.in (bench_grammar): Use %push-pull-parser instead of %push-parser. * src/getargs.c (pull_parser): New global initialized to true. * getargs.h (pull_parser): extern it. * src/output.c (prepare): Insert pull_flag muscle. * src/parse-gram.y (PERCENT_PUSH_PULL_PARSER): New token. (prologue_declaration): Set both push_parser and pull_parser = true for %push-pull-parser. Set push_parser = true and pull_parser = false for %push-parser. * src/scan-gram.l: Don't accept %push_parser as an alternative to %push-parser since there's no backward-compatibility concern here. Scan %push-pull-parser. * tests/calc.at (Simple LALR(1) Calculator): Use %push-pull-parser instead of %push-parser. * tests/headers.at (export YYLTYPE): Make yylex static, and don't prototype it in the module that calls yyparse. * tests/input.at (Torturing the Scanner): Likewise. * tests/local.at (AT_PUSH_IF): Check for %push-pull-parser as well.
This commit is contained in:
@@ -59,6 +59,7 @@ bool error_verbose = false;
|
||||
|
||||
bool nondeterministic_parser = false;
|
||||
bool glr_parser = false;
|
||||
bool pull_parser = true;
|
||||
bool pure_parser = false;
|
||||
bool push_parser = false;
|
||||
|
||||
|
||||
@@ -52,13 +52,16 @@ extern bool error_verbose;
|
||||
|
||||
extern bool glr_parser;
|
||||
|
||||
/* PULL_PARSER is true if should generate a pull parser. */
|
||||
|
||||
extern bool pull_parser;
|
||||
|
||||
/* PURE_PARSER is true if should generate a parser that is all pure
|
||||
and reentrant. */
|
||||
|
||||
extern bool pure_parser;
|
||||
|
||||
/* PUSH_PARSER is true if should generate a parser that is capable of being
|
||||
called asynchronously. Is must be pure and reentrant. */
|
||||
/* PUSH_PARSER is true if should generate a push parser. */
|
||||
|
||||
extern bool push_parser;
|
||||
|
||||
|
||||
@@ -593,6 +593,7 @@ prepare (void)
|
||||
MUSCLE_INSERT_BOOL ("glr_flag", glr_parser);
|
||||
MUSCLE_INSERT_BOOL ("locations_flag", locations_flag);
|
||||
MUSCLE_INSERT_BOOL ("nondeterministic_flag", nondeterministic_parser);
|
||||
MUSCLE_INSERT_BOOL ("pull_flag", pull_parser);
|
||||
MUSCLE_INSERT_BOOL ("pure_flag", pure_parser);
|
||||
MUSCLE_INSERT_BOOL ("push_flag", push_parser);
|
||||
MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag);
|
||||
|
||||
873
src/parse-gram.c
873
src/parse-gram.c
File diff suppressed because it is too large
Load Diff
@@ -78,27 +78,28 @@
|
||||
PERCENT_PROVIDES = 292,
|
||||
PERCENT_PURE_PARSER = 293,
|
||||
PERCENT_PUSH_PARSER = 294,
|
||||
PERCENT_REQUIRE = 295,
|
||||
PERCENT_REQUIRES = 296,
|
||||
PERCENT_SKELETON = 297,
|
||||
PERCENT_START = 298,
|
||||
PERCENT_TOKEN_TABLE = 299,
|
||||
PERCENT_VERBOSE = 300,
|
||||
PERCENT_YACC = 301,
|
||||
BRACED_CODE = 302,
|
||||
CHAR = 303,
|
||||
EPILOGUE = 304,
|
||||
EQUAL = 305,
|
||||
ID = 306,
|
||||
ID_COLON = 307,
|
||||
PERCENT_PERCENT = 308,
|
||||
PIPE = 309,
|
||||
PROLOGUE = 310,
|
||||
SEMICOLON = 311,
|
||||
TYPE = 312,
|
||||
TYPE_TAG_ANY = 313,
|
||||
TYPE_TAG_NONE = 314,
|
||||
PERCENT_UNION = 315
|
||||
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
|
||||
};
|
||||
#endif
|
||||
/* Tokens. */
|
||||
@@ -140,27 +141,28 @@
|
||||
#define PERCENT_PROVIDES 292
|
||||
#define PERCENT_PURE_PARSER 293
|
||||
#define PERCENT_PUSH_PARSER 294
|
||||
#define PERCENT_REQUIRE 295
|
||||
#define PERCENT_REQUIRES 296
|
||||
#define PERCENT_SKELETON 297
|
||||
#define PERCENT_START 298
|
||||
#define PERCENT_TOKEN_TABLE 299
|
||||
#define PERCENT_VERBOSE 300
|
||||
#define PERCENT_YACC 301
|
||||
#define BRACED_CODE 302
|
||||
#define CHAR 303
|
||||
#define EPILOGUE 304
|
||||
#define EQUAL 305
|
||||
#define ID 306
|
||||
#define ID_COLON 307
|
||||
#define PERCENT_PERCENT 308
|
||||
#define PIPE 309
|
||||
#define PROLOGUE 310
|
||||
#define SEMICOLON 311
|
||||
#define TYPE 312
|
||||
#define TYPE_TAG_ANY 313
|
||||
#define TYPE_TAG_NONE 314
|
||||
#define PERCENT_UNION 315
|
||||
#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
|
||||
|
||||
|
||||
|
||||
@@ -182,7 +184,7 @@ typedef union YYSTYPE
|
||||
}
|
||||
|
||||
/* Line 1535 of yacc.c */
|
||||
#line 186 "parse-gram.h"
|
||||
#line 188 "parse-gram.h"
|
||||
YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
||||
@@ -156,6 +156,8 @@ static int current_prec = 0;
|
||||
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"
|
||||
@@ -257,7 +259,8 @@ prologue_declaration:
|
||||
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
||||
| "%parse-param" "{...}" { add_param ("parse_param", $2, @2); }
|
||||
| "%pure-parser" { pure_parser = true; }
|
||||
| "%push-parser" { push_parser = true; }
|
||||
| "%push-parser" { push_parser = true; pull_parser = false; }
|
||||
| "%push-pull-parser" { push_parser = true; pull_parser = true; }
|
||||
| "%require" STRING { version_check (&@2, $2); }
|
||||
| "%skeleton" STRING { skeleton_arg ($2, 1, &@1); }
|
||||
| "%token-table" { token_table_flag = true; }
|
||||
|
||||
@@ -189,7 +189,8 @@ splice (\\[ \f\t\v]*\n)*
|
||||
"%printer" return PERCENT_PRINTER;
|
||||
"%provides" return PERCENT_PROVIDES;
|
||||
"%pure"[-_]"parser" return PERCENT_PURE_PARSER;
|
||||
"%push"[-_]"parser" return PERCENT_PUSH_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;
|
||||
|
||||
Reference in New Issue
Block a user