From d9df47b656fd1757f1f36c8f3d823ca9ca5bfe91 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Mon, 29 Oct 2007 17:36:40 +0000 Subject: [PATCH] Deprecate %pure-parser and add `%define api.pure'. Discussed starting at . * NEWS (2.3a+): Mention. * data/bison.m4 (b4_pure_if): Don't define it here. * data/c.m4 (b4_identification): Depend on individual skeletons to define b4_pure_flag, b4_push_flag, or b4_pull_flag if they use the values of the %define variables api.pure or api.push_pull. Define YYPURE, YYPUSH, and YYPULL accordingly. * data/glr.c: Define b4_pure_if based on `%define api.pure' unless glr.cc has already defined b4_pure_flag. * data/push.c: Define b4_pure_if based on `%define api.pure'. Remove YYPUSH and YYPULL since they're back in b4_identification again. * data/yacc.c Define b4_pure_if based on `%define api.pure'. * doc/bison.texinfo (Pure Decl): Update. (Push Decl): Update. (Decl Summary): Add api.pure to %define entry. In %pure-parser entry, say it's deprecated and reference %define. (Pure Calling): Update. (Error Reporting): Update. (C++ Scanner Interface): Update. (How Can I Reset the Parser): Update. (Table of Symbols): In %pure-parser entry, say it's deprecated and reference %define. * src/getargs.c (pure_parser): Remove global variable. * src/getargs.h (pure_parser): Remove extern. * src/output.c (prepare): Don't define pure_flag muscle. * src/parse-gram.y (prologue_declaration): Implement %pure-parser as a wrapper around `%define api.pure'. * tests/calc.at (Simple LALR Calculator): Update. (Simple GLR Calculator): Update. * tests/cxx-type.at (GLR: Resolve ambiguity, pure, no locations): Update. (GLR: Resolve ambiguity, pure, locations): Update. (GLR: Merge conflicting parses, pure, no locations): Update. (GLR: Merge conflicting parses, pure, locations): Update. * tests/glr-regression.at (Uninitialized location when reporting ambiguity): Update * tests/input.at (Unused %define api.pure): New test case. * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Update definition for AT_PURE_IF and AT_PURE_AND_LOC_IF. * tests/push.at (Push Parsing: Memory Leak for Early Deletion): Update. --- ChangeLog | 45 +++++ NEWS | 17 +- data/bison.m4 | 1 - data/c.m4 | 23 ++- data/glr.c | 7 + data/push.c | 13 +- data/yacc.c | 4 + doc/bison.texinfo | 58 +++--- src/getargs.c | 1 - src/getargs.h | 5 - src/output.c | 1 - src/parse-gram.c | 393 +++++++++++++++++++++------------------- src/parse-gram.h | 4 +- src/parse-gram.y | 14 +- tests/calc.at | 16 +- tests/cxx-type.at | 11 +- tests/glr-regression.at | 2 +- tests/input.at | 33 ++++ tests/local.at | 9 +- tests/push.at | 2 +- 20 files changed, 397 insertions(+), 262 deletions(-) diff --git a/ChangeLog b/ChangeLog index 413d63ea..8a126f01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,48 @@ +2007-10-28 Joel E. Denny + + Deprecate %pure-parser and add `%define api.pure'. Discussed starting + at + . + * NEWS (2.3a+): Mention. + * data/bison.m4 (b4_pure_if): Don't define it here. + * data/c.m4 (b4_identification): Depend on individual skeletons to + define b4_pure_flag, b4_push_flag, or b4_pull_flag if they use the + values of the %define variables api.pure or api.push_pull. Define + YYPURE, YYPUSH, and YYPULL accordingly. + * data/glr.c: Define b4_pure_if based on `%define api.pure' unless + glr.cc has already defined b4_pure_flag. + * data/push.c: Define b4_pure_if based on `%define api.pure'. + Remove YYPUSH and YYPULL since they're back in b4_identification again. + * data/yacc.c Define b4_pure_if based on `%define api.pure'. + * doc/bison.texinfo (Pure Decl): Update. + (Push Decl): Update. + (Decl Summary): Add api.pure to %define entry. + In %pure-parser entry, say it's deprecated and reference %define. + (Pure Calling): Update. + (Error Reporting): Update. + (C++ Scanner Interface): Update. + (How Can I Reset the Parser): Update. + (Table of Symbols): In %pure-parser entry, say it's deprecated and + reference %define. + * src/getargs.c (pure_parser): Remove global variable. + * src/getargs.h (pure_parser): Remove extern. + * src/output.c (prepare): Don't define pure_flag muscle. + * src/parse-gram.y (prologue_declaration): Implement %pure-parser as a + wrapper around `%define api.pure'. + * tests/calc.at (Simple LALR Calculator): Update. + (Simple GLR Calculator): Update. + * tests/cxx-type.at (GLR: Resolve ambiguity, pure, no locations): + Update. + (GLR: Resolve ambiguity, pure, locations): Update. + (GLR: Merge conflicting parses, pure, no locations): Update. + (GLR: Merge conflicting parses, pure, locations): Update. + * tests/glr-regression.at (Uninitialized location when reporting + ambiguity): Update + * tests/input.at (Unused %define api.pure): New test case. + * tests/local.at (_AT_BISON_OPTION_PUSHDEFS): Update definition for + AT_PURE_IF and AT_PURE_AND_LOC_IF. + * tests/push.at (Push Parsing: Memory Leak for Early Deletion): Update. + 2007-10-28 Joel E. Denny %define push_pull -> %define api.push_pull. Discussed starting at diff --git a/NEWS b/NEWS index 09defd4d..18e71b7d 100644 --- a/NEWS +++ b/NEWS @@ -3,6 +3,18 @@ Bison News Changes in version 2.3a+ (????-??-??): +* The quotes around NAME that used to be required in the following directive + are now deprecated: + + %define NAME "VALUE" + +* The directive `%pure-parser' is now deprecated in favor of: + + %define api.pure + + which has the same effect except that Bison is more careful to warn about + unreasonable usage in the latter case. + * Push Parsing Bison can now generate an LALR(1) parser in C with a push interface. That @@ -69,11 +81,6 @@ Changes in version 2.3a+ (????-??-??): %name-prefix "c_" %output "parser.c" -* The quotes around NAME that used to be required in the following directive - are now deprecated: - - %define NAME "VALUE" - * An Alternative to `%{...%}' -- `%code QUALIFIER {CODE}' Bison 2.3a provided a new set of directives as a more flexible alternative to diff --git a/data/bison.m4 b/data/bison.m4 index fbf375bd..75c9b753 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -249,7 +249,6 @@ b4_define_flag_if([error_verbose]) # Whether error are verbose. b4_define_flag_if([glr]) # Whether a GLR parser is requested. b4_define_flag_if([locations]) # Whether locations are tracked. b4_define_flag_if([nondeterministic]) # Whether conflicts should be handled. -b4_define_flag_if([pure]) # Whether the interface is pure. b4_define_flag_if([yacc]) # Whether POSIX Yacc is emulated. diff --git a/data/c.m4 b/data/c.m4 index f5f38ba1..dbec53c6 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -28,22 +28,31 @@ m4_define([b4_comment], [/* m4_bpatsubst([$1], [ # b4_identification # ----------------- +# Depends on individual skeletons to define b4_pure_flag, b4_push_flag, or +# b4_pull_flag if they use the values of the %define variables api.pure or +# api.push_pull. m4_define([b4_identification], -[/* Identify Bison output. */ -[#]define YYBISON 1 +[[/* Identify Bison output. */ +#define YYBISON 1 /* Bison version. */ -[#]define YYBISON_VERSION "b4_version" +#define YYBISON_VERSION "]b4_version[" /* Skeleton name. */ -[#]define YYSKELETON_NAME b4_skeleton +#define YYSKELETON_NAME ]b4_skeleton[]m4_ifdef([b4_pure_flag], [[ /* Pure parsers. */ -[#]define YYPURE b4_pure_flag +#define YYPURE ]b4_pure_flag])[]m4_ifdef([b4_push_flag], [[ + +/* Push parsers. */ +#define YYPUSH ]b4_push_flag])[]m4_ifdef([b4_pull_flag], [[ + +/* Pull parsers. */ +#define YYPULL ]b4_pull_flag])[ /* Using locations. */ -[#]define YYLSP_NEEDED b4_locations_flag -]) +#define YYLSP_NEEDED ]b4_locations_flag[ +]]) ## ---------------- ## diff --git a/data/glr.c b/data/glr.c index 0f0e3daa..49588fe1 100644 --- a/data/glr.c +++ b/data/glr.c @@ -34,6 +34,13 @@ m4_define_default([b4_stack_depth_init], [200]) ## Pure/impure interfaces. ## ## ------------------------ ## +b4_define_flag_if([pure]) +# If glr.cc is including this file and thus has already set b4_pure_flag, don't +# change the value of b4_pure_flag, and don't record a use of api.pure. +m4_ifndef([b4_pure_flag], +[b4_percent_define_default([[api.pure]], [[false]]) + m4_define([b4_pure_flag], + [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])])]) # b4_user_formals # --------------- diff --git a/data/push.c b/data/push.c index 346b65ff..b0cbeb32 100644 --- a/data/push.c +++ b/data/push.c @@ -51,6 +51,10 @@ m4_define_default([b4_stack_depth_init], [200]) ## Pure/impure interfaces. ## ## ------------------------ ## +b4_percent_define_default([[api.pure]], [[false]]) +b4_define_flag_if([pure]) +m4_define([b4_pure_flag], + [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])]) # b4_yacc_pure_if(IF-TRUE, IF-FALSE) # ---------------------------------- @@ -163,14 +167,9 @@ b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -]b4_identification[ -/* Push parsers. */ -#define YYPUSH ]b4_push_flag[ +]b4_identification -/* Pull parsers. */ -#define YYPULL ]b4_pull_flag[ - -]b4_percent_code_get([[top]])[]dnl +b4_percent_code_get([[top]])[]dnl m4_if(b4_prefix, [yy], [], [[/* Substitute the variable and function names. */ ]b4_pull_if([[#define yyparse ]b4_prefix[parse diff --git a/data/yacc.c b/data/yacc.c index 4461f023..f76b06f4 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -37,6 +37,10 @@ m4_define_default([b4_stack_depth_init], [200]) ## Pure/impure interfaces. ## ## ------------------------ ## +b4_percent_define_default([[api.pure]], [[false]]) +b4_define_flag_if([pure]) +m4_define([b4_pure_flag], + [b4_percent_define_flag_if([[api.pure]], [[1]], [[0]])]) # b4_yacc_pure_if(IF-TRUE, IF-FALSE) # ---------------------------------- diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 3ba5b652..c0fa7f08 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -4487,7 +4487,7 @@ may override this restriction with the @code{%start} declaration as follows: @subsection A Pure (Reentrant) Parser @cindex reentrant parser @cindex pure parser -@findex %pure-parser +@findex %define api.pure A @dfn{reentrant} program is one which does not alter in the course of execution; in other words, it consists entirely of @dfn{pure} (read-only) @@ -4503,11 +4503,11 @@ statically allocated variables for communication with @code{yylex}, including @code{yylval} and @code{yylloc}.) Alternatively, you can generate a pure, reentrant parser. The Bison -declaration @code{%pure-parser} says that you want the parser to be +declaration @code{%define api.pure} says that you want the parser to be reentrant. It looks like this: @example -%pure-parser +%define api.pure @end example The result is that the communication variables @code{yylval} and @@ -4554,7 +4554,7 @@ compatibility with the impure Yacc pull mode interface. Unless you know what you are doing, your declarations should look like this: @example -%pure-parser +%define api.pure %define api.push_pull "push" @end example @@ -4627,8 +4627,8 @@ yypull_parse (ps); /* Will call the lexer */ yypstate_delete (ps); @end example -Adding the @code{%pure-parser} declaration does exactly the same thing to the -generated parser with @code{%define api.push_pull "both"} as it did for +Adding the @code{%define api.pure} declaration does exactly the same thing to +the generated parser with @code{%define api.push_pull "both"} as it did for @code{%define api.push_pull "push"}. @node Decl Summary @@ -4837,6 +4837,20 @@ target language and/or parser skeleton. Some of the accepted @var{variable}s are: @itemize @bullet +@item api.pure +@findex %define api.pure + +@itemize @bullet +@item Language(s): C + +@item Purpose: Request a pure (reentrant) parser program. +@xref{Pure Decl, ,A Pure (Reentrant) Parser}. + +@item Accepted Values: Boolean + +@item Default Value: @code{"false"} +@end itemize + @item api.push_pull @findex %define api.push_pull @@ -5054,8 +5068,8 @@ Specify @var{file} for the parser file. @end deffn @deffn {Directive} %pure-parser -Request a pure (reentrant) parser program (@pxref{Pure Decl, ,A Pure -(Reentrant) Parser}). +Deprecated version of @code{%define api.pure} (@pxref{Decl Summary, ,%define}), +for which Bison is more careful to warn about unreasonable usage. @end deffn @deffn {Directive} %require "@var{version}" @@ -5498,7 +5512,7 @@ The data type of @code{yylloc} has the name @code{YYLTYPE}. @node Pure Calling @subsection Calling Conventions for Pure Parsers -When you use the Bison declaration @code{%pure-parser} to request a +When you use the Bison declaration @code{%define api.pure} to request a pure, reentrant parser, the global communication variables @code{yylval} and @code{yylloc} cannot be used. (@xref{Pure Decl, ,A Pure (Reentrant) Parser}.) In such parsers the two global variables are replaced by @@ -5549,7 +5563,7 @@ int yylex (int *nastiness); int yyparse (int *nastiness, int *randomness); @end example -If @code{%pure-parser} is added: +If @code{%define api.pure} is added: @example int yylex (YYSTYPE *lvalp, int *nastiness); @@ -5557,7 +5571,7 @@ int yyparse (int *nastiness, int *randomness); @end example @noindent -and finally, if both @code{%pure-parser} and @code{%locations} are used: +and finally, if both @code{%define api.pure} and @code{%locations} are used: @example int yylex (YYSTYPE *lvalp, YYLTYPE *llocp, int *nastiness); @@ -5623,7 +5637,7 @@ Obviously, in location tracking pure parsers, @code{yyerror} should have an access to the current location. This is indeed the case for the @acronym{GLR} parsers, but not for the Yacc parser, for historical reasons. I.e., if -@samp{%locations %pure-parser} is passed then the prototypes for +@samp{%locations %define api.pure} is passed then the prototypes for @code{yyerror} are: @example @@ -5641,13 +5655,14 @@ void yyerror (int *nastiness, char const *msg); /* GLR parsers. */ Finally, @acronym{GLR} and Yacc parsers share the same @code{yyerror} calling convention for absolutely pure parsers, i.e., when the calling convention of @code{yylex} @emph{and} the calling convention of -@code{%pure-parser} are pure. I.e.: +@code{%define api.pure} are pure. +I.e.: @example /* Location tracking. */ %locations /* Pure yylex. */ -%pure-parser +%define api.pure %lex-param @{int *nastiness@} /* Pure yyparse. */ %parse-param @{int *nastiness@} @@ -8108,7 +8123,7 @@ described by @var{m}. The parser invokes the scanner by calling @code{yylex}. Contrary to C parsers, C++ parsers are always pure: there is no point in using the -@code{%pure-parser} directive. Therefore the interface is as follows. +@code{%define api.pure} directive. Therefore the interface is as follows. @deftypemethod {parser} {int} yylex (semantic_value_type& @var{yylval}, location_type& @var{yylloc}, @var{type1} @var{arg1}, ...) Return the next token. Its type is the return value, its semantic @@ -8860,10 +8875,9 @@ The return type can be changed using @samp{%define "stype" @end deftypemethod -If @code{%pure-parser} is not specified, the lexer interface -resides in the same class (@code{YYParser}) as the Bison-generated -parser. The fields and methods that are provided to -this end are as follows. +The lexer interface resides in the same class (@code{YYParser}) as the +Bison-generated parser. +The fields and methods that are provided to this end are as follows. @deftypemethod {YYParser} {void} error (Location @var{l}, String @var{m}) As explained in @pxref{Java Parser Interface}, this method is defined @@ -8996,7 +9010,7 @@ or @display My parser includes support for an @samp{#include}-like feature, in which case I run @code{yyparse} from @code{yyparse}. This fails -although I did specify I needed a @code{%pure-parser}. +although I did specify @code{%define api.pure}. @end display These problems typically come not from Bison itself, but from @@ -9558,8 +9572,8 @@ Bison declaration to assign a precedence to a specific rule. @end deffn @deffn {Directive} %pure-parser -Bison declaration to request a pure (reentrant) parser. -@xref{Pure Decl, ,A Pure (Reentrant) Parser}. +Deprecated version of @code{%define api.pure} (@pxref{Decl Summary, ,%define}), +for which Bison is more careful to warn about unreasonable usage. @end deffn @deffn {Directive} %require "@var{version}" diff --git a/src/getargs.c b/src/getargs.c index 5aaba801..bea533b6 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -59,7 +59,6 @@ bool error_verbose = false; bool nondeterministic_parser = false; bool glr_parser = false; -bool pure_parser = false; int report_flag = report_none; int trace_flag = trace_none; diff --git a/src/getargs.h b/src/getargs.h index f75ec100..8449626b 100644 --- a/src/getargs.h +++ b/src/getargs.h @@ -51,11 +51,6 @@ extern bool error_verbose; extern bool glr_parser; -/* PURE_PARSER is true if should generate a parser that is all pure - and reentrant. */ - -extern bool pure_parser; - /* NONDETERMINISTIC_PARSER is true iff conflicts are accepted. This is used by the GLR parser, and might be used in BackTracking parsers too. */ diff --git a/src/output.c b/src/output.c index c9400e69..1a1d7b3a 100644 --- a/src/output.c +++ b/src/output.c @@ -571,7 +571,6 @@ 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 ("pure_flag", pure_parser); MUSCLE_INSERT_BOOL ("synclines_flag", !no_lines_flag); MUSCLE_INSERT_BOOL ("tag_seen_flag", tag_seen); MUSCLE_INSERT_BOOL ("use_push_for_pull_flag", use_push_for_pull_flag); diff --git a/src/parse-gram.c b/src/parse-gram.c index a652dcc4..41168732 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -69,7 +69,7 @@ /* Copy the first part of user declarations. */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1 "parse-gram.y" /* Bison Grammar Parser -*- C -*- @@ -146,7 +146,7 @@ static int current_prec = 0; #define YYTYPE_UINT8 uint_fast8_t -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 151 "parse-gram.c" /* Enabling traces. */ @@ -295,7 +295,7 @@ static int current_prec = 0; typedef union YYSTYPE { -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 94 "parse-gram.y" symbol *symbol; @@ -309,7 +309,7 @@ typedef union YYSTYPE -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 314 "parse-gram.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 @@ -334,7 +334,7 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 339 "parse-gram.c" #ifdef short @@ -661,15 +661,15 @@ static const yytype_uint16 yyrline[] = { 0, 204, 204, 212, 214, 218, 219, 229, 230, 234, 235, 240, 241, 242, 243, 244, 245, 250, 259, 260, - 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, - 271, 295, 296, 297, 298, 302, 303, 304, 308, 315, - 322, 326, 330, 337, 352, 353, 357, 369, 369, 374, - 374, 379, 390, 405, 406, 407, 411, 412, 417, 419, - 424, 425, 429, 430, 431, 432, 437, 442, 447, 453, - 459, 470, 471, 480, 481, 487, 488, 489, 496, 496, - 500, 501, 502, 507, 508, 510, 512, 514, 516, 526, - 527, 533, 536, 545, 565, 567, 576, 581, 582, 587, - 594, 596 + 261, 262, 263, 264, 265, 266, 267, 268, 269, 282, + 283, 307, 308, 309, 310, 314, 315, 316, 320, 327, + 334, 338, 342, 349, 364, 365, 369, 381, 381, 386, + 386, 391, 402, 417, 418, 419, 423, 424, 429, 431, + 436, 437, 441, 442, 443, 444, 449, 454, 459, 465, + 471, 482, 483, 492, 493, 499, 500, 501, 508, 508, + 512, 513, 514, 519, 520, 522, 524, 526, 528, 538, + 539, 545, 548, 557, 577, 579, 588, 593, 594, 599, + 606, 608 }; #endif @@ -1020,146 +1020,146 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) { case 3: /* "\"string\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 182 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1029 "parse-gram.c" break; case 4: /* "\"integer\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 193 "parse-gram.y" { fprintf (stderr, "%d", (yyvaluep->integer)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1038 "parse-gram.c" break; case 43: /* "\"{...}\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 184 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1047 "parse-gram.c" break; case 44: /* "\"char\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 176 "parse-gram.y" { fputs (char_name ((yyvaluep->character)), stderr); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1056 "parse-gram.c" break; case 45: /* "\"epilogue\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 184 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1065 "parse-gram.c" break; case 47: /* "\"identifier\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 189 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1074 "parse-gram.c" break; case 48: /* "\"identifier:\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 190 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->uniqstr)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1083 "parse-gram.c" break; case 51: /* "\"%{...%}\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 184 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1092 "parse-gram.c" break; case 53: /* "\"type\"" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 188 "parse-gram.y" { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1101 "parse-gram.c" break; case 80: /* "variable" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 189 "parse-gram.y" { fputs ((yyvaluep->uniqstr), stderr); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1110 "parse-gram.c" break; case 81: /* "content.opt" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 184 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1119 "parse-gram.c" break; case 82: /* "braceless" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 184 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1128 "parse-gram.c" break; case 83: /* "id" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 196 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1137 "parse-gram.c" break; case 84: /* "id_colon" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 197 "parse-gram.y" { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1146 "parse-gram.c" break; case 85: /* "symbol" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 196 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1155 "parse-gram.c" break; case 86: /* "string_as_id" */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 196 "parse-gram.y" { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1164 "parse-gram.c" break; default: @@ -1674,7 +1674,7 @@ YYLTYPE yylloc; /* User initialization code. */ -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 86 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default @@ -1683,7 +1683,7 @@ YYLTYPE yylloc; boundary_set (&yylloc.end, current_file, 1, 1); } -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 1688 "parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -1869,7 +1869,7 @@ yyreduce: { case 6: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 220 "parse-gram.y" { code_props plain_code; @@ -1884,14 +1884,14 @@ yyreduce: case 7: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 229 "parse-gram.y" { debug_flag = true; } break; case 8: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 231 "parse-gram.y" { muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars)); @@ -1900,14 +1900,14 @@ yyreduce: case 9: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 234 "parse-gram.y" { defines_flag = true; } break; case 10: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 236 "parse-gram.y" { defines_flag = true; @@ -1917,42 +1917,42 @@ yyreduce: case 11: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 240 "parse-gram.y" { error_verbose = true; } break; case 12: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 241 "parse-gram.y" { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 13: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 242 "parse-gram.y" { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } break; case 14: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 243 "parse-gram.y" { spec_file_prefix = (yyvsp[(2) - (2)].chars); } break; case 15: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 244 "parse-gram.y" { spec_file_prefix = (yyvsp[(3) - (3)].chars); } break; case 16: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 246 "parse-gram.y" { nondeterministic_parser = true; @@ -1962,7 +1962,7 @@ yyreduce: case 17: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 251 "parse-gram.y" { code_props action; @@ -1976,92 +1976,103 @@ yyreduce: case 18: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 259 "parse-gram.y" { language_argmatch ((yyvsp[(2) - (2)].chars), 1, &(yylsp[(1) - (2)])); } break; case 19: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 260 "parse-gram.y" { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 20: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 261 "parse-gram.y" { locations_flag = true; } break; case 21: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 262 "parse-gram.y" { spec_name_prefix = (yyvsp[(2) - (2)].chars); } break; case 22: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 263 "parse-gram.y" { spec_name_prefix = (yyvsp[(3) - (3)].chars); } break; case 23: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 264 "parse-gram.y" { no_lines_flag = true; } break; case 24: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 265 "parse-gram.y" { nondeterministic_parser = true; } break; case 25: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 266 "parse-gram.y" { spec_outfile = (yyvsp[(2) - (2)].chars); } break; case 26: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 267 "parse-gram.y" { spec_outfile = (yyvsp[(3) - (3)].chars); } break; case 27: -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 268 "parse-gram.y" { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 28: -/* Line 1538 of yacc.c */ -#line 269 "parse-gram.y" - { pure_parser = true; } +/* Line 1542 of yacc.c */ +#line 270 "parse-gram.y" + { + /* %pure-parser is deprecated in favor of `%define api.pure', so use + `%define api.pure' in a backward-compatible manner here. First, don't + complain if %pure-parser is specified multiple times. */ + if (!muscle_find_const ("percent_define(api.pure)")) + muscle_percent_define_insert ("api.pure", (yylsp[(1) - (1)]), ""); + /* In all cases, use api.pure now so that the backend doesn't complain if + the skeleton ignores api.pure, but do warn now if there's a previous + conflicting definition from an actual %define. */ + if (!muscle_percent_define_flag_if ("api.pure")) + muscle_percent_define_insert ("api.pure", (yylsp[(1) - (1)]), ""); + } break; case 29: -/* Line 1538 of yacc.c */ -#line 270 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 282 "parse-gram.y" { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } break; case 30: -/* Line 1538 of yacc.c */ -#line 272 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 284 "parse-gram.y" { char const *skeleton_user = (yyvsp[(2) - (2)].chars); if (strchr (skeleton_user, '/')) @@ -2089,29 +2100,29 @@ yyreduce: case 31: -/* Line 1538 of yacc.c */ -#line 295 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 307 "parse-gram.y" { token_table_flag = true; } break; case 32: -/* Line 1538 of yacc.c */ -#line 296 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 308 "parse-gram.y" { report_flag = report_states; } break; case 33: -/* Line 1538 of yacc.c */ -#line 297 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 309 "parse-gram.y" { yacc_flag = true; } break; case 37: -/* Line 1538 of yacc.c */ -#line 305 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 317 "parse-gram.y" { grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } @@ -2119,8 +2130,8 @@ yyreduce: case 38: -/* Line 1538 of yacc.c */ -#line 309 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 321 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[(3) - (3)].list); list; list = list->next) @@ -2131,8 +2142,8 @@ yyreduce: case 39: -/* Line 1538 of yacc.c */ -#line 316 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 328 "parse-gram.y" { symbol_list *list; for (list = (yyvsp[(3) - (3)].list); list; list = list->next) @@ -2143,8 +2154,8 @@ yyreduce: case 40: -/* Line 1538 of yacc.c */ -#line 323 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 335 "parse-gram.y" { default_prec = true; } @@ -2152,8 +2163,8 @@ yyreduce: case 41: -/* Line 1538 of yacc.c */ -#line 327 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 339 "parse-gram.y" { default_prec = false; } @@ -2161,8 +2172,8 @@ yyreduce: case 42: -/* Line 1538 of yacc.c */ -#line 331 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 343 "parse-gram.y" { /* Do not invoke muscle_percent_code_grow here since it invokes muscle_user_name_list_grow. */ @@ -2173,8 +2184,8 @@ yyreduce: case 43: -/* Line 1538 of yacc.c */ -#line 338 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 350 "parse-gram.y" { muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); code_scanner_last_string_free (); @@ -2183,22 +2194,22 @@ yyreduce: case 44: -/* Line 1538 of yacc.c */ -#line 352 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 364 "parse-gram.y" {} break; case 45: -/* Line 1538 of yacc.c */ -#line 353 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 365 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 46: -/* Line 1538 of yacc.c */ -#line 358 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 370 "parse-gram.y" { union_seen = true; muscle_code_grow ("stype", (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); @@ -2208,15 +2219,15 @@ yyreduce: case 47: -/* Line 1538 of yacc.c */ -#line 369 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 381 "parse-gram.y" { current_class = nterm_sym; } break; case 48: -/* Line 1538 of yacc.c */ -#line 370 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 382 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2225,15 +2236,15 @@ yyreduce: case 49: -/* Line 1538 of yacc.c */ -#line 374 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 386 "parse-gram.y" { current_class = token_sym; } break; case 50: -/* Line 1538 of yacc.c */ -#line 375 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 387 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -2242,8 +2253,8 @@ yyreduce: case 51: -/* Line 1538 of yacc.c */ -#line 380 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 392 "parse-gram.y" { symbol_list *list; tag_seen = true; @@ -2255,8 +2266,8 @@ yyreduce: case 52: -/* Line 1538 of yacc.c */ -#line 391 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 403 "parse-gram.y" { symbol_list *list; ++current_prec; @@ -2272,99 +2283,99 @@ yyreduce: case 53: -/* Line 1538 of yacc.c */ -#line 405 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 417 "parse-gram.y" { (yyval.assoc) = left_assoc; } break; case 54: -/* Line 1538 of yacc.c */ -#line 406 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 418 "parse-gram.y" { (yyval.assoc) = right_assoc; } break; case 55: -/* Line 1538 of yacc.c */ -#line 407 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 419 "parse-gram.y" { (yyval.assoc) = non_assoc; } break; case 56: -/* Line 1538 of yacc.c */ -#line 411 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 423 "parse-gram.y" { current_type = NULL; } break; case 57: -/* Line 1538 of yacc.c */ -#line 412 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 424 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } break; case 58: -/* Line 1538 of yacc.c */ -#line 418 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 430 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 59: -/* Line 1538 of yacc.c */ -#line 420 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 432 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } break; case 60: -/* Line 1538 of yacc.c */ -#line 424 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 436 "parse-gram.y" { (yyval.list) = (yyvsp[(1) - (1)].list); } break; case 61: -/* Line 1538 of yacc.c */ -#line 425 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 437 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } break; case 62: -/* Line 1538 of yacc.c */ -#line 429 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 441 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } break; case 63: -/* Line 1538 of yacc.c */ -#line 430 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 442 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 64: -/* Line 1538 of yacc.c */ -#line 431 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 443 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } break; case 65: -/* Line 1538 of yacc.c */ -#line 432 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 444 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } break; case 66: -/* Line 1538 of yacc.c */ -#line 438 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 450 "parse-gram.y" { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; @@ -2373,8 +2384,8 @@ yyreduce: case 67: -/* Line 1538 of yacc.c */ -#line 443 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 455 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); symbol_type_set ((yyvsp[(1) - (1)].symbol), current_type, (yylsp[(1) - (1)])); @@ -2383,8 +2394,8 @@ yyreduce: case 68: -/* Line 1538 of yacc.c */ -#line 448 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 460 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); @@ -2394,8 +2405,8 @@ yyreduce: case 69: -/* Line 1538 of yacc.c */ -#line 454 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 466 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_type_set ((yyvsp[(1) - (2)].symbol), current_type, (yylsp[(1) - (2)])); @@ -2405,8 +2416,8 @@ yyreduce: case 70: -/* Line 1538 of yacc.c */ -#line 460 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 472 "parse-gram.y" { symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); symbol_type_set ((yyvsp[(1) - (3)].symbol), current_type, (yylsp[(1) - (3)])); @@ -2417,8 +2428,8 @@ yyreduce: case 77: -/* Line 1538 of yacc.c */ -#line 490 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 502 "parse-gram.y" { yyerrok; } @@ -2426,78 +2437,78 @@ yyreduce: case 78: -/* Line 1538 of yacc.c */ -#line 496 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 508 "parse-gram.y" { current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); } break; case 80: -/* Line 1538 of yacc.c */ -#line 500 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 512 "parse-gram.y" { grammar_current_rule_end ((yylsp[(1) - (1)])); } break; case 81: -/* Line 1538 of yacc.c */ -#line 501 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 513 "parse-gram.y" { grammar_current_rule_end ((yylsp[(3) - (3)])); } break; case 83: -/* Line 1538 of yacc.c */ -#line 507 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 519 "parse-gram.y" { grammar_current_rule_begin (current_lhs, current_lhs_location); } break; case 84: -/* Line 1538 of yacc.c */ -#line 509 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 521 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } break; case 85: -/* Line 1538 of yacc.c */ -#line 511 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 523 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } break; case 86: -/* Line 1538 of yacc.c */ -#line 513 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 525 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } break; case 87: -/* Line 1538 of yacc.c */ -#line 515 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 527 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } break; case 88: -/* Line 1538 of yacc.c */ -#line 517 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 529 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } break; case 90: -/* Line 1538 of yacc.c */ -#line 527 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 539 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } break; case 91: -/* Line 1538 of yacc.c */ -#line 533 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 545 "parse-gram.y" { (yyval.chars) = ""; } @@ -2505,8 +2516,8 @@ yyreduce: case 93: -/* Line 1538 of yacc.c */ -#line 546 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 558 "parse-gram.y" { code_props plain_code; (yyvsp[(1) - (1)].code)[strlen ((yyvsp[(1) - (1)].code)) - 1] = '\n'; @@ -2519,15 +2530,15 @@ yyreduce: case 94: -/* Line 1538 of yacc.c */ -#line 566 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 578 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 95: -/* Line 1538 of yacc.c */ -#line 568 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 580 "parse-gram.y" { (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); @@ -2537,15 +2548,15 @@ yyreduce: case 96: -/* Line 1538 of yacc.c */ -#line 576 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 588 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } break; case 99: -/* Line 1538 of yacc.c */ -#line 588 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 600 "parse-gram.y" { (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); symbol_class_set ((yyval.symbol), token_sym, (yylsp[(1) - (1)]), false); @@ -2554,8 +2565,8 @@ yyreduce: case 101: -/* Line 1538 of yacc.c */ -#line 597 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 609 "parse-gram.y" { code_props plain_code; code_props_plain_init (&plain_code, (yyvsp[(2) - (2)].chars), (yylsp[(2) - (2)])); @@ -2568,8 +2579,8 @@ yyreduce: -/* Line 1538 of yacc.c */ -#line 2573 "parse-gram.c" +/* Line 1542 of yacc.c */ +#line 2584 "parse-gram.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); @@ -2787,8 +2798,8 @@ yyreturn: -/* Line 1538 of yacc.c */ -#line 607 "parse-gram.y" +/* Line 1542 of yacc.c */ +#line 619 "parse-gram.y" diff --git a/src/parse-gram.h b/src/parse-gram.h index 50f8daaa..044c8e45 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -160,7 +160,7 @@ typedef union YYSTYPE { -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 94 "parse-gram.y" symbol *symbol; @@ -174,7 +174,7 @@ typedef union YYSTYPE -/* Line 1538 of yacc.c */ +/* Line 1542 of yacc.c */ #line 179 "parse-gram.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 diff --git a/src/parse-gram.y b/src/parse-gram.y index e50ec271..4d1c45a4 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -266,7 +266,19 @@ prologue_declaration: | "%output" STRING { spec_outfile = $2; } | "%output" "=" STRING { spec_outfile = $3; } /* deprecated */ | "%parse-param" "{...}" { add_param ("parse_param", $2, @2); } -| "%pure-parser" { pure_parser = true; } +| "%pure-parser" + { + /* %pure-parser is deprecated in favor of `%define api.pure', so use + `%define api.pure' in a backward-compatible manner here. First, don't + complain if %pure-parser is specified multiple times. */ + if (!muscle_find_const ("percent_define(api.pure)")) + muscle_percent_define_insert ("api.pure", @1, ""); + /* In all cases, use api.pure now so that the backend doesn't complain if + the skeleton ignores api.pure, but do warn now if there's a previous + conflicting definition from an actual %define. */ + if (!muscle_percent_define_flag_if ("api.pure")) + muscle_percent_define_insert ("api.pure", @1, ""); + } | "%require" STRING { version_check (&@2, $2); } | "%skeleton" STRING { diff --git a/tests/calc.at b/tests/calc.at index c6d27154..2fb4d72b 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -559,8 +559,8 @@ AT_CHECK_CALC_LALR([%verbose]) AT_CHECK_CALC_LALR([%yacc]) AT_CHECK_CALC_LALR([%error-verbose]) -AT_CHECK_CALC_LALR([%pure-parser %locations]) -AT_CHECK_CALC_LALR([%define api.push_pull "both" %pure-parser %locations]) +AT_CHECK_CALC_LALR([%define api.pure %locations]) +AT_CHECK_CALC_LALR([%define api.push_pull "both" %define api.pure %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations]) AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) @@ -568,10 +568,10 @@ AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verb AT_CHECK_CALC_LALR([%debug]) AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%define api.push_pull "both" %pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define api.push_pull "both" %define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) # ----------------------- # @@ -597,7 +597,7 @@ AT_CHECK_CALC_GLR([%verbose]) AT_CHECK_CALC_GLR([%yacc]) AT_CHECK_CALC_GLR([%error-verbose]) -AT_CHECK_CALC_GLR([%pure-parser %locations]) +AT_CHECK_CALC_GLR([%define api.pure %locations]) AT_CHECK_CALC_GLR([%error-verbose %locations]) AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) @@ -605,9 +605,9 @@ AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbo AT_CHECK_CALC_GLR([%debug]) AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR([%pure-parser %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) # ----------------------------- # diff --git a/tests/cxx-type.at b/tests/cxx-type.at index 70fd6fac..cb378284 100644 --- a/tests/cxx-type.at +++ b/tests/cxx-type.at @@ -1,5 +1,6 @@ # Checking GLR Parsing. -*- Autotest -*- -# Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, +# Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -423,14 +424,14 @@ AT_PARSER_CHECK([[./types test-input]], 0, AT_CLEANUP AT_SETUP([GLR: Resolve ambiguity, pure, no locations]) -_AT_TEST_GLR_CXXTYPES([%pure-parser], +_AT_TEST_GLR_CXXTYPES([%define api.pure], [%dprec 1], [%dprec 2]) AT_PARSER_CHECK([[./types test-input]], 0, _AT_RESOLVED_GLR_OUTPUT, _AT_GLR_STDERR) AT_CLEANUP AT_SETUP([GLR: Resolve ambiguity, pure, locations]) -_AT_TEST_GLR_CXXTYPES([%pure-parser %locations], +_AT_TEST_GLR_CXXTYPES([%define api.pure %locations], [%dprec 1], [%dprec 2]) AT_PARSER_CHECK([[./types test-input]], 0, _AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR) @@ -451,13 +452,13 @@ AT_PARSER_CHECK([[./types test-input]], 0, AT_CLEANUP AT_SETUP([GLR: Merge conflicting parses, pure, no locations]) -_AT_TEST_GLR_CXXTYPES([%pure-parser], +_AT_TEST_GLR_CXXTYPES([%define api.pure], [%merge ], [%merge ]) AT_PARSER_CHECK([[./types test-input]], 0, _AT_AMBIG_GLR_OUTPUT, _AT_GLR_STDERR) AT_CLEANUP AT_SETUP([GLR: Merge conflicting parses, pure, locations]) -_AT_TEST_GLR_CXXTYPES([%pure-parser %locations], +_AT_TEST_GLR_CXXTYPES([%define api.pure %locations], [%merge ],[%merge ]) AT_PARSER_CHECK([[./types test-input]], 0, _AT_AMBIG_GLR_OUTPUT_WITH_LOC, _AT_GLR_STDERR) diff --git a/tests/glr-regression.at b/tests/glr-regression.at index ed3802f1..cdd1de2b 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -1646,7 +1646,7 @@ AT_DATA_GRAMMAR([glr-regr17.y], [[ %glr-parser %locations -%pure-parser +%define api.pure %error-verbose %union { int dummy; } diff --git a/tests/input.at b/tests/input.at index 883b2011..da52f71c 100644 --- a/tests/input.at +++ b/tests/input.at @@ -859,6 +859,39 @@ AT_CHECK([[bison input.y]], [1], [], AT_CLEANUP +## ------------------------- ## +## Unused %define api.pure. ## +## ------------------------- ## + +AT_SETUP([[Unused %define api.pure]]) + +# AT_CHECK_API_PURE(DECLS, VALUE) +# ------------------------------- +# Make sure Bison reports that `%define api.pure VALUE' is unused when DECLS +# are specified. +m4_define([AT_CHECK_API_PURE], +[ +AT_DATA([[input.y]], +[[%define api.pure ]$2[ +]$1[ +%% +start: ; +]]) + +AT_CHECK([[bison input.y]], [0], [], +[[input.y:1.9-16: warning: %define variable `api.pure' is not used +]]) +]) + +AT_CHECK_API_PURE([[%language "c++" %defines]], [[]]) +AT_CHECK_API_PURE([[%language "c++" %defines]], [["false"]]) +AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [[""]]) +AT_CHECK_API_PURE([[%language "c++" %defines %glr-parser]], [["false"]]) +AT_CHECK_API_PURE([[%language "java"]], [["true"]]) +AT_CHECK_API_PURE([[%language "java"]], [["false"]]) + +AT_CLEANUP + ## -------------------------------- ## ## C++ namespace reference errors. ## ## -------------------------------- ## diff --git a/tests/local.at b/tests/local.at index abe08810..d4864148 100644 --- a/tests/local.at +++ b/tests/local.at @@ -57,10 +57,11 @@ m4_pushdef([AT_PARAM_IF], m4_pushdef([AT_LOCATION_IF], [m4_bmatch([$3], [%locations], [$1], [$2])]) m4_pushdef([AT_PURE_IF], -[m4_bmatch([$3], [%pure-parser], [$1], [$2])]) +[m4_bmatch([$3], [%define *api\.pure\|%pure-parser], + [m4_bmatch([$3], [%define *api\.pure *"false"], [$2], [$1])], + [$2])]) m4_pushdef([AT_PURE_AND_LOC_IF], -[m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations], - [$1], [$2])]) +[m4_bmatch([$3], [%locations], [AT_PURE_IF($@)], [$2])]) m4_pushdef([AT_GLR_OR_PARAM_IF], [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])]) m4_pushdef([AT_NAME_PREFIX], @@ -79,7 +80,7 @@ m4_pushdef([AT_YYERROR_SEES_LOC_IF], [$1])], [$2])]) -# The interface is pure: either because %pure-parser, or because we +# The interface is pure: either because %define api.pure, or because we # are using the C++ parsers. m4_pushdef([AT_PURE_LEX_IF], [AT_PURE_IF([$1], diff --git a/tests/push.at b/tests/push.at index a3222382..6e2bd8b6 100644 --- a/tests/push.at +++ b/tests/push.at @@ -33,7 +33,7 @@ AT_DATA_GRAMMAR([[input.y]], void yyerror (char const *msg); %} -%pure-parser %define api.push_pull "push" +%define api.pure %define api.push_pull "push" %% -- 2.47.2