From: Joel E. Denny Date: Thu, 23 Apr 2009 08:12:58 +0000 (-0400) Subject: Rename "default rule" to "default reduction". X-Git-Tag: v2.7.90~885 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/110ef36a1a93c60cc83627492de40cb95aedf9b1 Rename "default rule" to "default reduction". This includes changing variable names in code, changing comments, and renaming %define lr.default_rules to %define lr.default_reductions. * NEWS (2.5): Update IELR documentation. * data/bison.m4 (b4_integral_parser_tables_map): Adjust YYDEFACT documentation. * data/glr.c, data/lalr1.java: Sync copyright dates. * doc/bison.texinfo (Decl Summary): Adjust lr.default_reductions and lr.type documentation. Make some other wording improvements. (Glossary): Adjust cross-references and Default Reduction definition. * src/lalr.c (state_lookahead_tokens_count): Adjust code. Remove a confusing comment pointed out by Akim Demaille. (initialize_LA): Adjust code. * src/print-xml.c (print_reductions): Adjust code. * src/print.c (print_reductions): Adjust code. * src/reader.c (reader): Adjust code. * src/tables.c (action_row): Adjust code. (token_actions): Adjust code. * src/tables.h: Adjust YYDEFACT documentation. * tests/input.at (%define lr.default_rules invalid values): Rename test group to... (%define lr.default_reductions invalid values): ... this, and update grammar file and expected output. * tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): Rename to... (AT_TEST_LR_DEFAULT_REDUCTIONS): ... this, and update. --- diff --git a/ChangeLog b/ChangeLog index 8adc86ce..13193edd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +2009-04-23 Joel E. Denny + + Rename "default rule" to "default reduction". + This includes changing variable names in code, changing + comments, and renaming %define lr.default_rules to %define + lr.default_reductions. + * NEWS (2.5): Update IELR documentation. + * data/bison.m4 (b4_integral_parser_tables_map): Adjust YYDEFACT + documentation. + * data/glr.c, data/lalr1.java: Sync copyright dates. + * doc/bison.texinfo (Decl Summary): Adjust lr.default_reductions + and lr.type documentation. Make some other wording + improvements. + (Glossary): Adjust cross-references and Default Reduction + definition. + * src/lalr.c (state_lookahead_tokens_count): Adjust code. + Remove a confusing comment pointed out by Akim Demaille. + (initialize_LA): Adjust code. + * src/print-xml.c (print_reductions): Adjust code. + * src/print.c (print_reductions): Adjust code. + * src/reader.c (reader): Adjust code. + * src/tables.c (action_row): Adjust code. + (token_actions): Adjust code. + * src/tables.h: Adjust YYDEFACT documentation. + * tests/input.at (%define lr.default_rules invalid values): + Rename test group to... + (%define lr.default_reductions invalid values): ... this, and + update grammar file and expected output. + * tests/reduce.at (AT_TEST_LR_DEFAULT_RULES): Rename to... + (AT_TEST_LR_DEFAULT_REDUCTIONS): ... this, and update. + 2009-04-21 Akim Demaille tests: check the use of dashes and periods in symbols. diff --git a/NEWS b/NEWS index a42ec81d..5c8aac3f 100644 --- a/NEWS +++ b/NEWS @@ -32,10 +32,11 @@ Bison News %define lr.type "IELR" %define lr.type "canonical LR" - The default rules optimization in the parser tables can also be - adjusted using `%define lr.default_rules'. See the documentation for - `%define lr.type' and `%define lr.default_rules' in the section `Bison - Declaration Summary' in the Bison manual for the details. + The default reduction optimization in the parser tables can also be + adjusted using `%define lr.default_reductions'. See the documentation + for `%define lr.type' and `%define lr.default_reductions' in the + section `Bison Declaration Summary' in the Bison manual for the + details. These features are experimental. More user feedback will help to stabilize them. diff --git a/data/bison.m4 b/data/bison.m4 index 8c18d32c..3c68c4c1 100644 --- a/data/bison.m4 +++ b/data/bison.m4 @@ -255,9 +255,9 @@ m4_define([b4_integral_parser_tables_map], STATE-NUM.]]) $1([defact], [b4_defact], - [[YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE -does not specify something else to do. Zero means the default is an -error.]]) + [[YYDEFACT[S] -- default reduction number in state S. Performed when +YYTABLE does not specify something else to do. Zero means the default +is an error.]]) $1([pgoto], [b4_pgoto], [[YYPGOTO[NTERM-NUM].]]) diff --git a/data/glr.c b/data/glr.c index dcbc7d88..d67ec421 100644 --- a/data/glr.c +++ b/data/glr.c @@ -1,8 +1,8 @@ -*- C -*- # GLR skeleton for Bison -# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software -# Foundation, Inc. +# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 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 @@ -158,7 +158,7 @@ m4_changecom() m4_divert_push(0)dnl @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison GLR parsers in C], - [2002, 2003, 2004, 2005, 2006, 2007, 2008]) + [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009]) [ /* C GLR parser skeleton written by Paul Hilfinger. */ @@ -2580,7 +2580,7 @@ m4_if(b4_skeleton, ["glr.c"], [b4_defines_if( [@output(b4_spec_defines_file@)@ b4_copyright([Skeleton interface for Bison GLR parsers in C], - [2002, 2003, 2004, 2005, 2006, 2007, 2008]) + [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009]) b4_shared_declarations diff --git a/data/lalr1.java b/data/lalr1.java index 0140a683..e68650d9 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -33,7 +33,7 @@ b4_symbol_foreach([b4_symbol_no_destructor_assert]) m4_divert_push(0)dnl @output(b4_parser_file_name@)@ b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], - [2007, 2008]) + [2007, 2008, 2009]) b4_percent_define_ifdef([package], [package b4_percent_define_get([package]); ])[/* First part of user declarations. */ diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 1c227448..67a43008 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -4930,9 +4930,9 @@ Boolean @c error-verbose -@item lr.default_rules -@cindex default rules -@findex %define lr.default_rules +@item lr.default_reductions +@cindex default reductions +@findex %define lr.default_reductions @cindex delayed syntax errors @cindex syntax errors delayed @@ -4940,15 +4940,14 @@ Boolean @item Language(s): all @item Purpose: Specifies the kind of states that are permitted to -contain default rules. -That is, in such a state, Bison declares the rule with the largest -lookahead set to be the default rule by which to reduce and then removes -that lookahead set. -The advantages of default rules are discussed below. +contain default reductions. +That is, in such a state, Bison declares the reduction with the largest +lookahead set to be the default reduction and then removes that +lookahead set. +The advantages of default reductions are discussed below. The disadvantage is that, when the generated parser encounters a syntactically unacceptable token, the parser might then perform -unnecessary reductions by default rules before it can detect the syntax -error. +unnecessary default reductions before it can detect the syntax error. (This feature is experimental. More user feedback will help to stabilize it.) @@ -4958,14 +4957,14 @@ More user feedback will help to stabilize it.) @item @code{"all"}. For @acronym{LALR} and @acronym{IELR} parsers (@pxref{Decl Summary,,lr.type}) by default, all states are permitted to contain -default rules. +default reductions. The advantage is that parser table sizes can be significantly reduced. The reason Bison does not by default attempt to address the disadvantage of delayed syntax error detection is that this disadvantage is already inherent in @acronym{LALR} and @acronym{IELR} parser tables. -That is, unlike a canonical @acronym{LR} state, an @acronym{LALR} or -@acronym{IELR} state can contain syntactically incorrect tokens in the -lookahead sets of its rules. +That is, unlike in a canonical @acronym{LR} state, the lookahead sets of +reductions in an @acronym{LALR} or @acronym{IELR} state can contain +tokens that are syntactically incorrect for some left contexts. @item @code{"consistent"}. @cindex consistent states @@ -4973,16 +4972,17 @@ A consistent state is a state that has only one possible action. If that action is a reduction, then the parser does not need to request a lookahead token from the scanner before performing that action. However, the parser only recognizes the ability to ignore the lookahead -token when such a reduction is encoded as a default rule. -Thus, if default rules are permitted in and only in consistent states, -then a canonical @acronym{LR} parser reports a syntax error as soon as -it @emph{needs} the syntactically unacceptable token from the scanner. +token when such a reduction is encoded as a default reduction. +Thus, if default reductions are permitted in and only in consistent +states, then a canonical @acronym{LR} parser reports a syntax error as +soon as it @emph{needs} the syntactically unacceptable token from the +scanner. @item @code{"accepting"}. @cindex accepting state -By default, the only default rule permitted in a canonical @acronym{LR} -parser is the accept rule in the accepting state, which the parser -reaches only after reading all tokens from the input. +By default, the only default reduction permitted in a canonical +@acronym{LR} parser is the accept action in the accepting state, which +the parser reaches only after reading all tokens from the input. Thus, the default canonical @acronym{LR} parser reports a syntax error as soon as it @emph{reaches} the syntactically unacceptable token without performing any extra reductions. @@ -5060,8 +5060,8 @@ While Bison generates @acronym{LALR} parser tables by default for historical reasons, @acronym{IELR} or canonical @acronym{LR} is almost always preferable for deterministic parsers. The trouble is that @acronym{LALR} parser tables can suffer from -mysterious conflicts and may not accept the full set of sentences that -@acronym{IELR} and canonical @acronym{LR} accept. +mysterious conflicts and thus may not accept the full set of sentences +that @acronym{IELR} and canonical @acronym{LR} accept. @xref{Mystery Conflicts}, for details. However, there are at least two scenarios where @acronym{LALR} may be worthwhile: @@ -5071,8 +5071,8 @@ worthwhile: do not resolve any conflicts statically (for example, with @code{%left} or @code{%prec}), then the parser explores all potential parses of any given input. -Thus, the use of @acronym{LALR} parser tables is guaranteed not to alter -the language accepted by the parser. +In this case, the use of @acronym{LALR} parser tables is guaranteed not +to alter the language accepted by the parser. @acronym{LALR} parser tables are the smallest parser tables Bison can currently generate, so they may be preferable. @@ -5101,13 +5101,14 @@ This can significantly reduce the complexity of developing of a grammar. @item @code{"canonical LR"}. @cindex delayed syntax errors @cindex syntax errors delayed -The only advantage of canonical @acronym{LR} over @acronym{IELR} is that -every canonical @acronym{LR} state encodes that state's exact set of -syntactically acceptable tokens. -The only difference in parsing behavior is then that the canonical +The only advantage of canonical @acronym{LR} over @acronym{IELR} is +that, for every left context of every canonical @acronym{LR} state, the +set of tokens accepted by that state is the exact set of tokens that is +syntactically acceptable in that left context. +Thus, the only difference in parsing behavior is that the canonical @acronym{LR} parser can report a syntax error as soon as possible without performing any unnecessary reductions. -@xref{Decl Summary,,lr.default_rules}, for further details. +@xref{Decl Summary,,lr.default_reductions}, for further details. Even when canonical @acronym{LR} behavior is ultimately desired, @acronym{IELR}'s elimination of duplicate conflicts should still facilitate the development of a grammar. @@ -10525,7 +10526,7 @@ committee document contributing to what became the Algol 60 report. @item Consistent State A state containing only one possible action. -@xref{Decl Summary,,lr.default_rules}. +@xref{Decl Summary,,lr.default_reductions}. @item Context-free grammars Grammars specified as rules that can be applied regardless of context. @@ -10534,12 +10535,13 @@ expression, integers are allowed @emph{anywhere} an expression is permitted. @xref{Language and Grammar, ,Languages and Context-Free Grammars}. -@item Default Rule -The rule by which a parser should reduce if the current parser state +@item Default Reduction +The reduction that a parser should perform if the current parser state contains no other action for the lookahead token. -In permitted parser states, Bison declares the rule with the largest -lookahead set to be the default rule and removes that lookahead set. -@xref{Decl Summary,,lr.default_rules}. +In permitted parser states, Bison declares the reduction with the +largest lookahead set to be the default reduction and removes that +lookahead set. +@xref{Decl Summary,,lr.default_reductions}. @item Dynamic allocation Allocation of memory that occurs during execution, rather than at diff --git a/src/lalr.c b/src/lalr.c index 4f26a45f..857efe95 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -328,7 +328,7 @@ compute_lookahead_tokens (void) `----------------------------------------------------*/ static int -state_lookahead_tokens_count (state *s, bool default_rule_only_for_accept) +state_lookahead_tokens_count (state *s, bool default_reduction_only_for_accept) { int n_lookahead_tokens = 0; reductions *rp = s->reductions; @@ -344,14 +344,14 @@ state_lookahead_tokens_count (state *s, bool default_rule_only_for_accept) /* We need a lookahead either to distinguish different reductions (i.e., there are two or more), or to distinguish a reduction from a shift. Otherwise, it is straightforward, and the state is - `consistent'. However, for states that have any rules, treat only - the accepting state as consistent (since there is never a lookahead - token that makes sense there, and so no lookahead token should be - read) if the user has otherwise disabled default rules. */ + `consistent'. However, treat only the accepting state as + consistent (because there is never a lookahead token that makes + sense there, and so no lookahead token should be read) if the user + has otherwise disabled default reductions. */ if (rp->num > 1 || (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0)) || (rp->num == 1 && rp->rules[0]->number != 0 - && default_rule_only_for_accept)) + && default_reduction_only_for_accept)) n_lookahead_tokens += rp->num; else s->consistent = 1; @@ -369,18 +369,21 @@ initialize_LA (void) { state_number i; bitsetv pLA; - bool default_rule_only_for_accept; + bool default_reduction_only_for_accept; { - char *default_rules = muscle_percent_define_get ("lr.default_rules"); - default_rule_only_for_accept = 0 == strcmp (default_rules, "accepting"); - free (default_rules); + char *default_reductions = + muscle_percent_define_get ("lr.default_reductions"); + default_reduction_only_for_accept = + 0 == strcmp (default_reductions, "accepting"); + free (default_reductions); } /* Compute the total number of reductions requiring a lookahead. */ nLA = 0; for (i = 0; i < nstates; i++) nLA += - state_lookahead_tokens_count (states[i], default_rule_only_for_accept); + state_lookahead_tokens_count (states[i], + default_reduction_only_for_accept); /* Avoid having to special case 0. */ if (!nLA) nLA = 1; @@ -392,7 +395,8 @@ initialize_LA (void) for (i = 0; i < nstates; i++) { int count = - state_lookahead_tokens_count (states[i], default_rule_only_for_accept); + state_lookahead_tokens_count (states[i], + default_reduction_only_for_accept); if (count) { states[i]->reductions->lookahead_tokens = pLA; diff --git a/src/parse-gram.c b/src/parse-gram.c index fd22575a..7ccd4669 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.4.294-184e3. */ +/* A Bison parser, made by GNU Bison 2.4.305-d937. */ /* Implementation for Bison's Yacc-like parsers in C @@ -45,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.294-184e3" +#define YYBISON_VERSION "2.4.305-d937" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -148,7 +148,7 @@ static int current_prec = 0; #define YYTYPE_UINT8 uint_fast8_t /* Line 191 of yacc.c */ -#line 152 "../../src/parse-gram.c" +#line 152 "src/parse-gram.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -291,7 +291,7 @@ static int current_prec = 0; #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 216 of yacc.c */ +/* Line 224 of yacc.c */ #line 92 "parse-gram.y" symbol *symbol; @@ -304,8 +304,8 @@ typedef union YYSTYPE unsigned char character; -/* Line 216 of yacc.c */ -#line 309 "../../src/parse-gram.c" +/* Line 224 of yacc.c */ +#line 309 "src/parse-gram.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -329,7 +329,7 @@ typedef struct YYLTYPE /* Copy the second part of user declarations. */ /* Line 266 of yacc.c */ -#line 333 "../../src/parse-gram.c" +#line 333 "src/parse-gram.c" #ifdef short # undef short @@ -688,9 +688,9 @@ static const yytype_int16 yypact[] = -93 }; - /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE - does not specify something else to do. Zero means the default is an - error. */ + /* YYDEFACT[S] -- default reduction number in state S. Performed when + YYTABLE does not specify something else to do. Zero means the default + is an error. */ static const yytype_uint8 yydefact[] = { 3, 0, 0, 1, 46, 44, 0, 0, 0, 50, @@ -983,7 +983,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 178 "parse-gram.y" { fputs (quotearg_style (c_quoting_style, ((*yyvaluep).chars)), stderr); } /* Line 647 of yacc.c */ -#line 987 "../../src/parse-gram.c" +#line 987 "src/parse-gram.c" break; case 4: // "integer" @@ -992,7 +992,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 190 "parse-gram.y" { fprintf (stderr, "%d", ((*yyvaluep).integer)); } /* Line 647 of yacc.c */ -#line 996 "../../src/parse-gram.c" +#line 996 "src/parse-gram.c" break; case 23: // "%" @@ -1001,7 +1001,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 186 "parse-gram.y" { fprintf (stderr, "%%%s", ((*yyvaluep).uniqstr)); } /* Line 647 of yacc.c */ -#line 1005 "../../src/parse-gram.c" +#line 1005 "src/parse-gram.c" break; case 41: // "{...}" @@ -1010,7 +1010,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 180 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).code)); } /* Line 647 of yacc.c */ -#line 1014 "../../src/parse-gram.c" +#line 1014 "src/parse-gram.c" break; case 42: // "char" @@ -1019,7 +1019,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 172 "parse-gram.y" { fputs (char_name (((*yyvaluep).character)), stderr); } /* Line 647 of yacc.c */ -#line 1023 "../../src/parse-gram.c" +#line 1023 "src/parse-gram.c" break; case 43: // "epilogue" @@ -1028,7 +1028,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 180 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); } /* Line 647 of yacc.c */ -#line 1032 "../../src/parse-gram.c" +#line 1032 "src/parse-gram.c" break; case 45: // "identifier" @@ -1037,7 +1037,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 184 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); } /* Line 647 of yacc.c */ -#line 1041 "../../src/parse-gram.c" +#line 1041 "src/parse-gram.c" break; case 46: // "identifier:" @@ -1046,7 +1046,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 185 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).uniqstr)); } /* Line 647 of yacc.c */ -#line 1050 "../../src/parse-gram.c" +#line 1050 "src/parse-gram.c" break; case 49: // "%{...%}" @@ -1055,7 +1055,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 180 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); } /* Line 647 of yacc.c */ -#line 1059 "../../src/parse-gram.c" +#line 1059 "src/parse-gram.c" break; case 51: // "" @@ -1064,7 +1064,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 187 "parse-gram.y" { fprintf (stderr, "<%s>", ((*yyvaluep).uniqstr)); } /* Line 647 of yacc.c */ -#line 1068 "../../src/parse-gram.c" +#line 1068 "src/parse-gram.c" break; case 80: // variable @@ -1073,7 +1073,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 184 "parse-gram.y" { fputs (((*yyvaluep).uniqstr), stderr); } /* Line 647 of yacc.c */ -#line 1077 "../../src/parse-gram.c" +#line 1077 "src/parse-gram.c" break; case 81: // content.opt @@ -1082,7 +1082,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 180 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); } /* Line 647 of yacc.c */ -#line 1086 "../../src/parse-gram.c" +#line 1086 "src/parse-gram.c" break; case 82: // braceless @@ -1091,7 +1091,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 180 "parse-gram.y" { fprintf (stderr, "{\n%s\n}", ((*yyvaluep).chars)); } /* Line 647 of yacc.c */ -#line 1095 "../../src/parse-gram.c" +#line 1095 "src/parse-gram.c" break; case 83: // id @@ -1100,7 +1100,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 193 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); } /* Line 647 of yacc.c */ -#line 1104 "../../src/parse-gram.c" +#line 1104 "src/parse-gram.c" break; case 84: // id_colon @@ -1109,7 +1109,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 194 "parse-gram.y" { fprintf (stderr, "%s:", ((*yyvaluep).symbol)->tag); } /* Line 647 of yacc.c */ -#line 1113 "../../src/parse-gram.c" +#line 1113 "src/parse-gram.c" break; case 85: // symbol @@ -1118,7 +1118,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 193 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); } /* Line 647 of yacc.c */ -#line 1122 "../../src/parse-gram.c" +#line 1122 "src/parse-gram.c" break; case 86: // string_as_id @@ -1127,7 +1127,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp) #line 193 "parse-gram.y" { fprintf (stderr, "%s", ((*yyvaluep).symbol)->tag); } /* Line 647 of yacc.c */ -#line 1131 "../../src/parse-gram.c" +#line 1131 "src/parse-gram.c" break; default: @@ -1640,7 +1640,7 @@ YYLTYPE yylloc; #endif /* User initialization code. */ -/* Line 1167 of yacc.c */ +/* Line 1173 of yacc.c */ #line 84 "parse-gram.y" { /* Bison's grammar can initial empty locations, hence a default @@ -1648,8 +1648,8 @@ YYLTYPE yylloc; boundary_set (&yylloc.start, current_file, 1, 1); boundary_set (&yylloc.end, current_file, 1, 1); } -/* Line 1167 of yacc.c */ -#line 1653 "../../src/parse-gram.c" +/* Line 1173 of yacc.c */ +#line 1653 "src/parse-gram.c" yylsp[0] = yylloc; goto yysetstate; @@ -1847,7 +1847,7 @@ yyreduce: code_scanner_last_string_free (); } /* Line 1380 of yacc.c */ -#line 1851 "../../src/parse-gram.c" +#line 1851 "src/parse-gram.c" break; case 7: @@ -1857,7 +1857,7 @@ yyreduce: muscle_percent_define_ensure ((yyvsp[0].uniqstr), (yylsp[0]), true); } /* Line 1380 of yacc.c */ -#line 1861 "../../src/parse-gram.c" +#line 1861 "src/parse-gram.c" break; case 8: @@ -1867,7 +1867,7 @@ yyreduce: muscle_percent_define_insert ((yyvsp[-1].uniqstr), (yylsp[-1]), (yyvsp[0].chars)); } /* Line 1380 of yacc.c */ -#line 1871 "../../src/parse-gram.c" +#line 1871 "src/parse-gram.c" break; case 9: @@ -1875,7 +1875,7 @@ yyreduce: #line 234 "parse-gram.y" { defines_flag = true; } /* Line 1380 of yacc.c */ -#line 1879 "../../src/parse-gram.c" +#line 1879 "src/parse-gram.c" break; case 10: @@ -1886,7 +1886,7 @@ yyreduce: spec_defines_file = xstrdup ((yyvsp[0].chars)); } /* Line 1380 of yacc.c */ -#line 1890 "../../src/parse-gram.c" +#line 1890 "src/parse-gram.c" break; case 11: @@ -1894,7 +1894,7 @@ yyreduce: #line 240 "parse-gram.y" { expected_sr_conflicts = (yyvsp[0].integer); } /* Line 1380 of yacc.c */ -#line 1898 "../../src/parse-gram.c" +#line 1898 "src/parse-gram.c" break; case 12: @@ -1902,7 +1902,7 @@ yyreduce: #line 241 "parse-gram.y" { expected_rr_conflicts = (yyvsp[0].integer); } /* Line 1380 of yacc.c */ -#line 1906 "../../src/parse-gram.c" +#line 1906 "src/parse-gram.c" break; case 13: @@ -1910,7 +1910,7 @@ yyreduce: #line 242 "parse-gram.y" { spec_file_prefix = (yyvsp[0].chars); } /* Line 1380 of yacc.c */ -#line 1914 "../../src/parse-gram.c" +#line 1914 "src/parse-gram.c" break; case 14: @@ -1918,7 +1918,7 @@ yyreduce: #line 243 "parse-gram.y" { spec_file_prefix = (yyvsp[0].chars); } /* Line 1380 of yacc.c */ -#line 1922 "../../src/parse-gram.c" +#line 1922 "src/parse-gram.c" break; case 15: @@ -1929,7 +1929,7 @@ yyreduce: glr_parser = true; } /* Line 1380 of yacc.c */ -#line 1933 "../../src/parse-gram.c" +#line 1933 "src/parse-gram.c" break; case 16: @@ -1944,7 +1944,7 @@ yyreduce: code_scanner_last_string_free (); } /* Line 1380 of yacc.c */ -#line 1948 "../../src/parse-gram.c" +#line 1948 "src/parse-gram.c" break; case 17: @@ -1952,7 +1952,7 @@ yyreduce: #line 258 "parse-gram.y" { language_argmatch ((yyvsp[0].chars), grammar_prio, (yylsp[-1])); } /* Line 1380 of yacc.c */ -#line 1956 "../../src/parse-gram.c" +#line 1956 "src/parse-gram.c" break; case 18: @@ -1960,7 +1960,7 @@ yyreduce: #line 259 "parse-gram.y" { add_param ("lex_param", (yyvsp[0].code), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 1964 "../../src/parse-gram.c" +#line 1964 "src/parse-gram.c" break; case 19: @@ -1968,7 +1968,7 @@ yyreduce: #line 260 "parse-gram.y" { spec_name_prefix = (yyvsp[0].chars); } /* Line 1380 of yacc.c */ -#line 1972 "../../src/parse-gram.c" +#line 1972 "src/parse-gram.c" break; case 20: @@ -1976,7 +1976,7 @@ yyreduce: #line 261 "parse-gram.y" { spec_name_prefix = (yyvsp[0].chars); } /* Line 1380 of yacc.c */ -#line 1980 "../../src/parse-gram.c" +#line 1980 "src/parse-gram.c" break; case 21: @@ -1984,7 +1984,7 @@ yyreduce: #line 262 "parse-gram.y" { no_lines_flag = true; } /* Line 1380 of yacc.c */ -#line 1988 "../../src/parse-gram.c" +#line 1988 "src/parse-gram.c" break; case 22: @@ -1992,7 +1992,7 @@ yyreduce: #line 263 "parse-gram.y" { nondeterministic_parser = true; } /* Line 1380 of yacc.c */ -#line 1996 "../../src/parse-gram.c" +#line 1996 "src/parse-gram.c" break; case 23: @@ -2000,7 +2000,7 @@ yyreduce: #line 264 "parse-gram.y" { spec_outfile = (yyvsp[0].chars); } /* Line 1380 of yacc.c */ -#line 2004 "../../src/parse-gram.c" +#line 2004 "src/parse-gram.c" break; case 24: @@ -2008,7 +2008,7 @@ yyreduce: #line 265 "parse-gram.y" { spec_outfile = (yyvsp[0].chars); } /* Line 1380 of yacc.c */ -#line 2012 "../../src/parse-gram.c" +#line 2012 "src/parse-gram.c" break; case 25: @@ -2016,7 +2016,7 @@ yyreduce: #line 266 "parse-gram.y" { add_param ("parse_param", (yyvsp[0].code), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2020 "../../src/parse-gram.c" +#line 2020 "src/parse-gram.c" break; case 26: @@ -2024,7 +2024,7 @@ yyreduce: #line 267 "parse-gram.y" { version_check (&(yylsp[0]), (yyvsp[0].chars)); } /* Line 1380 of yacc.c */ -#line 2028 "../../src/parse-gram.c" +#line 2028 "src/parse-gram.c" break; case 27: @@ -2054,7 +2054,7 @@ yyreduce: skeleton_arg (skeleton_user, grammar_prio, (yylsp[-1])); } /* Line 1380 of yacc.c */ -#line 2058 "../../src/parse-gram.c" +#line 2058 "src/parse-gram.c" break; case 28: @@ -2062,7 +2062,7 @@ yyreduce: #line 292 "parse-gram.y" { token_table_flag = true; } /* Line 1380 of yacc.c */ -#line 2066 "../../src/parse-gram.c" +#line 2066 "src/parse-gram.c" break; case 29: @@ -2070,7 +2070,7 @@ yyreduce: #line 293 "parse-gram.y" { report_flag |= report_states; } /* Line 1380 of yacc.c */ -#line 2074 "../../src/parse-gram.c" +#line 2074 "src/parse-gram.c" break; case 30: @@ -2078,7 +2078,7 @@ yyreduce: #line 294 "parse-gram.y" { yacc_flag = true; } /* Line 1380 of yacc.c */ -#line 2082 "../../src/parse-gram.c" +#line 2082 "src/parse-gram.c" break; case 34: @@ -2088,7 +2088,7 @@ yyreduce: grammar_start_symbol_set ((yyvsp[0].symbol), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2092 "../../src/parse-gram.c" +#line 2092 "src/parse-gram.c" break; case 35: @@ -2101,7 +2101,7 @@ yyreduce: symbol_list_free ((yyvsp[0].list)); } /* Line 1380 of yacc.c */ -#line 2105 "../../src/parse-gram.c" +#line 2105 "src/parse-gram.c" break; case 36: @@ -2114,7 +2114,7 @@ yyreduce: symbol_list_free ((yyvsp[0].list)); } /* Line 1380 of yacc.c */ -#line 2118 "../../src/parse-gram.c" +#line 2118 "src/parse-gram.c" break; case 37: @@ -2124,7 +2124,7 @@ yyreduce: default_prec = true; } /* Line 1380 of yacc.c */ -#line 2128 "../../src/parse-gram.c" +#line 2128 "src/parse-gram.c" break; case 38: @@ -2134,7 +2134,7 @@ yyreduce: default_prec = false; } /* Line 1380 of yacc.c */ -#line 2138 "../../src/parse-gram.c" +#line 2138 "src/parse-gram.c" break; case 39: @@ -2147,7 +2147,7 @@ yyreduce: code_scanner_last_string_free (); } /* Line 1380 of yacc.c */ -#line 2151 "../../src/parse-gram.c" +#line 2151 "src/parse-gram.c" break; case 40: @@ -2158,7 +2158,7 @@ yyreduce: code_scanner_last_string_free (); } /* Line 1380 of yacc.c */ -#line 2162 "../../src/parse-gram.c" +#line 2162 "src/parse-gram.c" break; case 41: @@ -2166,7 +2166,7 @@ yyreduce: #line 349 "parse-gram.y" {} /* Line 1380 of yacc.c */ -#line 2170 "../../src/parse-gram.c" +#line 2170 "src/parse-gram.c" break; case 42: @@ -2174,7 +2174,7 @@ yyreduce: #line 350 "parse-gram.y" { muscle_code_grow ("union_name", (yyvsp[0].uniqstr), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2178 "../../src/parse-gram.c" +#line 2178 "src/parse-gram.c" break; case 43: @@ -2186,7 +2186,7 @@ yyreduce: code_scanner_last_string_free (); } /* Line 1380 of yacc.c */ -#line 2190 "../../src/parse-gram.c" +#line 2190 "src/parse-gram.c" break; case 44: @@ -2194,7 +2194,7 @@ yyreduce: #line 366 "parse-gram.y" { current_class = nterm_sym; } /* Line 1380 of yacc.c */ -#line 2198 "../../src/parse-gram.c" +#line 2198 "src/parse-gram.c" break; case 45: @@ -2205,7 +2205,7 @@ yyreduce: current_type = NULL; } /* Line 1380 of yacc.c */ -#line 2209 "../../src/parse-gram.c" +#line 2209 "src/parse-gram.c" break; case 46: @@ -2213,7 +2213,7 @@ yyreduce: #line 371 "parse-gram.y" { current_class = token_sym; } /* Line 1380 of yacc.c */ -#line 2217 "../../src/parse-gram.c" +#line 2217 "src/parse-gram.c" break; case 47: @@ -2224,7 +2224,7 @@ yyreduce: current_type = NULL; } /* Line 1380 of yacc.c */ -#line 2228 "../../src/parse-gram.c" +#line 2228 "src/parse-gram.c" break; case 48: @@ -2238,7 +2238,7 @@ yyreduce: symbol_list_free ((yyvsp[0].list)); } /* Line 1380 of yacc.c */ -#line 2242 "../../src/parse-gram.c" +#line 2242 "src/parse-gram.c" break; case 49: @@ -2256,7 +2256,7 @@ yyreduce: current_type = NULL; } /* Line 1380 of yacc.c */ -#line 2260 "../../src/parse-gram.c" +#line 2260 "src/parse-gram.c" break; case 50: @@ -2264,7 +2264,7 @@ yyreduce: #line 402 "parse-gram.y" { (yyval.assoc) = left_assoc; } /* Line 1380 of yacc.c */ -#line 2268 "../../src/parse-gram.c" +#line 2268 "src/parse-gram.c" break; case 51: @@ -2272,7 +2272,7 @@ yyreduce: #line 403 "parse-gram.y" { (yyval.assoc) = right_assoc; } /* Line 1380 of yacc.c */ -#line 2276 "../../src/parse-gram.c" +#line 2276 "src/parse-gram.c" break; case 52: @@ -2280,7 +2280,7 @@ yyreduce: #line 404 "parse-gram.y" { (yyval.assoc) = non_assoc; } /* Line 1380 of yacc.c */ -#line 2284 "../../src/parse-gram.c" +#line 2284 "src/parse-gram.c" break; case 53: @@ -2288,7 +2288,7 @@ yyreduce: #line 405 "parse-gram.y" { (yyval.assoc) = precedence_assoc; } /* Line 1380 of yacc.c */ -#line 2292 "../../src/parse-gram.c" +#line 2292 "src/parse-gram.c" break; case 54: @@ -2296,7 +2296,7 @@ yyreduce: #line 409 "parse-gram.y" { current_type = NULL; } /* Line 1380 of yacc.c */ -#line 2300 "../../src/parse-gram.c" +#line 2300 "src/parse-gram.c" break; case 55: @@ -2304,7 +2304,7 @@ yyreduce: #line 410 "parse-gram.y" { current_type = (yyvsp[0].uniqstr); tag_seen = true; } /* Line 1380 of yacc.c */ -#line 2308 "../../src/parse-gram.c" +#line 2308 "src/parse-gram.c" break; case 56: @@ -2312,7 +2312,7 @@ yyreduce: #line 416 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2316 "../../src/parse-gram.c" +#line 2316 "src/parse-gram.c" break; case 57: @@ -2320,7 +2320,7 @@ yyreduce: #line 418 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } /* Line 1380 of yacc.c */ -#line 2324 "../../src/parse-gram.c" +#line 2324 "src/parse-gram.c" break; case 58: @@ -2328,7 +2328,7 @@ yyreduce: #line 422 "parse-gram.y" { (yyval.symbol) = (yyvsp[0].symbol); } /* Line 1380 of yacc.c */ -#line 2332 "../../src/parse-gram.c" +#line 2332 "src/parse-gram.c" break; case 59: @@ -2336,7 +2336,7 @@ yyreduce: #line 423 "parse-gram.y" { (yyval.symbol) = (yyvsp[-1].symbol); symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2340 "../../src/parse-gram.c" +#line 2340 "src/parse-gram.c" break; case 60: @@ -2344,7 +2344,7 @@ yyreduce: #line 429 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2348 "../../src/parse-gram.c" +#line 2348 "src/parse-gram.c" break; case 61: @@ -2352,7 +2352,7 @@ yyreduce: #line 431 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0]))); } /* Line 1380 of yacc.c */ -#line 2356 "../../src/parse-gram.c" +#line 2356 "src/parse-gram.c" break; case 62: @@ -2360,7 +2360,7 @@ yyreduce: #line 435 "parse-gram.y" { (yyval.list) = (yyvsp[0].list); } /* Line 1380 of yacc.c */ -#line 2364 "../../src/parse-gram.c" +#line 2364 "src/parse-gram.c" break; case 63: @@ -2368,7 +2368,7 @@ yyreduce: #line 436 "parse-gram.y" { (yyval.list) = symbol_list_prepend ((yyvsp[-1].list), (yyvsp[0].list)); } /* Line 1380 of yacc.c */ -#line 2372 "../../src/parse-gram.c" +#line 2372 "src/parse-gram.c" break; case 64: @@ -2376,7 +2376,7 @@ yyreduce: #line 440 "parse-gram.y" { (yyval.list) = symbol_list_sym_new ((yyvsp[0].symbol), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2380 "../../src/parse-gram.c" +#line 2380 "src/parse-gram.c" break; case 65: @@ -2384,7 +2384,7 @@ yyreduce: #line 441 "parse-gram.y" { (yyval.list) = symbol_list_type_new ((yyvsp[0].uniqstr), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2388 "../../src/parse-gram.c" +#line 2388 "src/parse-gram.c" break; case 66: @@ -2392,7 +2392,7 @@ yyreduce: #line 442 "parse-gram.y" { (yyval.list) = symbol_list_default_tagged_new ((yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2396 "../../src/parse-gram.c" +#line 2396 "src/parse-gram.c" break; case 67: @@ -2400,7 +2400,7 @@ yyreduce: #line 443 "parse-gram.y" { (yyval.list) = symbol_list_default_tagless_new ((yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2404 "../../src/parse-gram.c" +#line 2404 "src/parse-gram.c" break; case 68: @@ -2411,7 +2411,7 @@ yyreduce: tag_seen = true; } /* Line 1380 of yacc.c */ -#line 2415 "../../src/parse-gram.c" +#line 2415 "src/parse-gram.c" break; case 69: @@ -2422,7 +2422,7 @@ yyreduce: symbol_type_set ((yyvsp[0].symbol), current_type, (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2426 "../../src/parse-gram.c" +#line 2426 "src/parse-gram.c" break; case 70: @@ -2434,7 +2434,7 @@ yyreduce: symbol_user_token_number_set ((yyvsp[-1].symbol), (yyvsp[0].integer), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2438 "../../src/parse-gram.c" +#line 2438 "src/parse-gram.c" break; case 71: @@ -2446,7 +2446,7 @@ yyreduce: symbol_make_alias ((yyvsp[-1].symbol), (yyvsp[0].symbol), (yyloc)); } /* Line 1380 of yacc.c */ -#line 2450 "../../src/parse-gram.c" +#line 2450 "src/parse-gram.c" break; case 72: @@ -2459,7 +2459,7 @@ yyreduce: symbol_make_alias ((yyvsp[-2].symbol), (yyvsp[0].symbol), (yyloc)); } /* Line 1380 of yacc.c */ -#line 2463 "../../src/parse-gram.c" +#line 2463 "src/parse-gram.c" break; case 79: @@ -2469,7 +2469,7 @@ yyreduce: yyerrok; } /* Line 1380 of yacc.c */ -#line 2473 "../../src/parse-gram.c" +#line 2473 "src/parse-gram.c" break; case 80: @@ -2477,7 +2477,7 @@ yyreduce: #line 507 "parse-gram.y" { current_lhs = (yyvsp[0].symbol); current_lhs_location = (yylsp[0]); } /* Line 1380 of yacc.c */ -#line 2481 "../../src/parse-gram.c" +#line 2481 "src/parse-gram.c" break; case 82: @@ -2485,7 +2485,7 @@ yyreduce: #line 511 "parse-gram.y" { grammar_current_rule_end ((yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2489 "../../src/parse-gram.c" +#line 2489 "src/parse-gram.c" break; case 83: @@ -2493,7 +2493,7 @@ yyreduce: #line 512 "parse-gram.y" { grammar_current_rule_end ((yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2497 "../../src/parse-gram.c" +#line 2497 "src/parse-gram.c" break; case 85: @@ -2501,7 +2501,7 @@ yyreduce: #line 518 "parse-gram.y" { grammar_current_rule_begin (current_lhs, current_lhs_location); } /* Line 1380 of yacc.c */ -#line 2505 "../../src/parse-gram.c" +#line 2505 "src/parse-gram.c" break; case 86: @@ -2509,7 +2509,7 @@ yyreduce: #line 520 "parse-gram.y" { grammar_current_rule_symbol_append ((yyvsp[0].symbol), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2513 "../../src/parse-gram.c" +#line 2513 "src/parse-gram.c" break; case 87: @@ -2517,7 +2517,7 @@ yyreduce: #line 522 "parse-gram.y" { grammar_current_rule_action_append ((yyvsp[0].code), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2521 "../../src/parse-gram.c" +#line 2521 "src/parse-gram.c" break; case 88: @@ -2525,7 +2525,7 @@ yyreduce: #line 524 "parse-gram.y" { grammar_current_rule_prec_set ((yyvsp[0].symbol), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2529 "../../src/parse-gram.c" +#line 2529 "src/parse-gram.c" break; case 89: @@ -2533,7 +2533,7 @@ yyreduce: #line 526 "parse-gram.y" { grammar_current_rule_dprec_set ((yyvsp[0].integer), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2537 "../../src/parse-gram.c" +#line 2537 "src/parse-gram.c" break; case 90: @@ -2541,7 +2541,7 @@ yyreduce: #line 528 "parse-gram.y" { grammar_current_rule_merge_set ((yyvsp[0].uniqstr), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2545 "../../src/parse-gram.c" +#line 2545 "src/parse-gram.c" break; case 92: @@ -2549,7 +2549,7 @@ yyreduce: #line 538 "parse-gram.y" { (yyval.uniqstr) = uniqstr_new ((yyvsp[0].chars)); } /* Line 1380 of yacc.c */ -#line 2553 "../../src/parse-gram.c" +#line 2553 "src/parse-gram.c" break; case 93: @@ -2557,7 +2557,7 @@ yyreduce: #line 543 "parse-gram.y" { (yyval.chars) = ""; } /* Line 1380 of yacc.c */ -#line 2561 "../../src/parse-gram.c" +#line 2561 "src/parse-gram.c" break; case 95: @@ -2572,7 +2572,7 @@ yyreduce: (yyval.chars) = plain_code.code; } /* Line 1380 of yacc.c */ -#line 2576 "../../src/parse-gram.c" +#line 2576 "src/parse-gram.c" break; case 96: @@ -2580,7 +2580,7 @@ yyreduce: #line 574 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2584 "../../src/parse-gram.c" +#line 2584 "src/parse-gram.c" break; case 97: @@ -2592,7 +2592,7 @@ yyreduce: symbol_user_token_number_set ((yyval.symbol), (yyvsp[0].character), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2596 "../../src/parse-gram.c" +#line 2596 "src/parse-gram.c" break; case 98: @@ -2600,7 +2600,7 @@ yyreduce: #line 584 "parse-gram.y" { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[0].uniqstr), (yylsp[0])); } /* Line 1380 of yacc.c */ -#line 2604 "../../src/parse-gram.c" +#line 2604 "src/parse-gram.c" break; case 101: @@ -2611,7 +2611,7 @@ yyreduce: symbol_class_set ((yyval.symbol), token_sym, (yylsp[0]), false); } /* Line 1380 of yacc.c */ -#line 2615 "../../src/parse-gram.c" +#line 2615 "src/parse-gram.c" break; case 103: @@ -2626,12 +2626,12 @@ yyreduce: code_scanner_last_string_free (); } /* Line 1380 of yacc.c */ -#line 2630 "../../src/parse-gram.c" +#line 2630 "src/parse-gram.c" break; /* Line 1380 of yacc.c */ -#line 2635 "../../src/parse-gram.c" +#line 2635 "src/parse-gram.c" default: break; } YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); diff --git a/src/parse-gram.h b/src/parse-gram.h index d0d04119..7a64824b 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.4.294-184e3. */ +/* A Bison parser, made by GNU Bison 2.4.305-d937. */ /* Interface for Bison's Yacc-like parsers in C @@ -153,7 +153,7 @@ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED typedef union YYSTYPE { -/* Line 1600 of yacc.c */ +/* Line 1663 of yacc.c */ #line 92 "parse-gram.y" symbol *symbol; @@ -166,8 +166,8 @@ typedef union YYSTYPE unsigned char character; -/* Line 1600 of yacc.c */ -#line 171 "../../src/parse-gram.h" +/* Line 1663 of yacc.c */ +#line 171 "src/parse-gram.h" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ diff --git a/src/print-xml.c b/src/print-xml.c index cb6707da..72e61a84 100644 --- a/src/print-xml.c +++ b/src/print-xml.c @@ -1,6 +1,6 @@ /* Print an xml on generated parser, for Bison, - Copyright (C) 2007 Free Software Foundation, Inc. + Copyright (C) 2007, 2009 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -244,7 +244,7 @@ print_reductions (FILE *out, int level, state *s) { transitions *trans = s->transitions; reductions *reds = s->reductions; - rule *default_rule = NULL; + rule *default_reduction = NULL; int report = false; int i, j; @@ -254,7 +254,7 @@ print_reductions (FILE *out, int level, state *s) } if (yydefact[s->number] != 0) - default_rule = &rules[yydefact[s->number] - 1]; + default_reduction = &rules[yydefact[s->number] - 1]; bitset_zero (no_reduce_set); FOR_EACH_SHIFT (trans, i) @@ -263,7 +263,7 @@ print_reductions (FILE *out, int level, state *s) if (s->errs->symbols[i]) bitset_set (no_reduce_set, s->errs->symbols[i]->number); - if (default_rule) + if (default_reduction) report = true; if (reds->lookahead_tokens) @@ -276,7 +276,7 @@ print_reductions (FILE *out, int level, state *s) { if (! count) { - if (reds->rules[j] != default_rule) + if (reds->rules[j] != default_reduction) report = true; count = true; } @@ -307,7 +307,7 @@ print_reductions (FILE *out, int level, state *s) { if (! count) { - if (reds->rules[j] != default_rule) + if (reds->rules[j] != default_reduction) print_reduction (out, level + 1, symbols[i]->tag, reds->rules[j], true); else @@ -318,7 +318,7 @@ print_reductions (FILE *out, int level, state *s) { if (defaulted) print_reduction (out, level + 1, symbols[i]->tag, - default_rule, true); + default_reduction, true); defaulted = false; print_reduction (out, level + 1, symbols[i]->tag, reds->rules[j], false); @@ -326,9 +326,9 @@ print_reductions (FILE *out, int level, state *s) } } - if (default_rule) + if (default_reduction) print_reduction (out, level + 1, - "$default", default_rule, true); + "$default", default_reduction, true); xml_puts (out, level, ""); } diff --git a/src/print.c b/src/print.c index fc353993..00e0149d 100644 --- a/src/print.c +++ b/src/print.c @@ -242,7 +242,7 @@ print_reductions (FILE *out, state *s) { transitions *trans = s->transitions; reductions *reds = s->reductions; - rule *default_rule = NULL; + rule *default_reduction = NULL; size_t width = 0; int i, j; bool non_default_action = false; @@ -251,7 +251,7 @@ print_reductions (FILE *out, state *s) return; if (yydefact[s->number] != 0) - default_rule = &rules[yydefact[s->number] - 1]; + default_reduction = &rules[yydefact[s->number] - 1]; bitset_zero (no_reduce_set); FOR_EACH_SHIFT (trans, i) @@ -261,7 +261,7 @@ print_reductions (FILE *out, state *s) bitset_set (no_reduce_set, s->errs->symbols[i]->number); /* Compute the width of the lookahead token column. */ - if (default_rule) + if (default_reduction) width = strlen (_("$default")); if (reds->lookahead_tokens) @@ -274,7 +274,7 @@ print_reductions (FILE *out, state *s) { if (! count) { - if (reds->rules[j] != default_rule) + if (reds->rules[j] != default_reduction) max_length (&width, symbols[i]->tag); count = true; } @@ -306,7 +306,7 @@ print_reductions (FILE *out, state *s) { if (! count) { - if (reds->rules[j] != default_rule) + if (reds->rules[j] != default_reduction) { non_default_action = true; print_reduction (out, width, @@ -323,7 +323,7 @@ print_reductions (FILE *out, state *s) if (defaulted) print_reduction (out, width, symbols[i]->tag, - default_rule, true); + default_reduction, true); defaulted = false; print_reduction (out, width, symbols[i]->tag, @@ -332,15 +332,16 @@ print_reductions (FILE *out, state *s) } } - if (default_rule) + if (default_reduction) { - char *default_rules = muscle_percent_define_get ("lr.default_rules"); - print_reduction (out, width, _("$default"), default_rule, true); - aver (0 == strcmp (default_rules, "all") - || (0 == strcmp (default_rules, "consistent") + char *default_reductions = + muscle_percent_define_get ("lr.default_reductions"); + print_reduction (out, width, _("$default"), default_reduction, true); + aver (0 == strcmp (default_reductions, "all") + || (0 == strcmp (default_reductions, "consistent") && !non_default_action) || (reds->num == 1 && reds->rules[0]->number == 0)); - free (default_rules); + free (default_reductions); } } diff --git a/src/reader.c b/src/reader.c index f607f9ee..b6a8f16d 100644 --- a/src/reader.c +++ b/src/reader.c @@ -561,9 +561,9 @@ reader (void) muscle_percent_define_default ("lr.type", "LALR"); lr_type = muscle_percent_define_get ("lr.type"); if (0 != strcmp (lr_type, "canonical LR")) - muscle_percent_define_default ("lr.default_rules", "all"); + muscle_percent_define_default ("lr.default_reductions", "all"); else - muscle_percent_define_default ("lr.default_rules", "accepting"); + muscle_percent_define_default ("lr.default_reductions", "accepting"); free (lr_type); } @@ -571,7 +571,7 @@ reader (void) { static char const * const values[] = { "lr.type", "LALR", "IELR", "canonical LR", NULL, - "lr.default_rules", "all", "consistent", "accepting", NULL, + "lr.default_reductions", "all", "consistent", "accepting", NULL, NULL }; muscle_percent_define_check_values (values); diff --git a/src/tables.c b/src/tables.c index 9c2114da..06d6bab2 100644 --- a/src/tables.c +++ b/src/tables.c @@ -240,7 +240,7 @@ static rule * action_row (state *s) { int i; - rule *default_rule = NULL; + rule *default_reduction = NULL; reductions *reds = s->reductions; transitions *trans = s->transitions; errs *errp = s->errs; @@ -304,14 +304,15 @@ action_row (state *s) actrow[sym->number] = ACTION_NUMBER_MINIMUM; } - /* Turn off default rules where requested by the user. See + /* Turn off default reductions where requested by the user. See state_lookahead_tokens_count in lalr.c to understand when states are labeled as consistent. */ { - char *default_rules = muscle_percent_define_get ("lr.default_rules"); - if (0 != strcmp (default_rules, "all") && !s->consistent) + char *default_reductions = + muscle_percent_define_get ("lr.default_reductions"); + if (0 != strcmp (default_reductions, "all") && !s->consistent) nodefault = true; - free (default_rules); + free (default_reductions); } /* Now find the most common reduction and make it the default action @@ -320,7 +321,7 @@ action_row (state *s) if (reds->num >= 1 && !nodefault) { if (s->consistent) - default_rule = reds->rules[0]; + default_reduction = reds->rules[0]; else { int max = 0; @@ -337,7 +338,7 @@ action_row (state *s) if (count > max) { max = count; - default_rule = r; + default_reduction = r; } } @@ -351,17 +352,18 @@ action_row (state *s) { int j; for (j = 0; j < ntokens; j++) - if (actrow[j] == rule_number_as_item_number (default_rule->number) + if (actrow[j] + == rule_number_as_item_number (default_reduction->number) && ! (nondeterministic_parser && conflrow[j])) actrow[j] = 0; } } } - /* If have no default rule, the default is an error. + /* If have no default reduction, the default is an error. So replace any action which says "error" with "use default". */ - if (!default_rule) + if (!default_reduction) for (i = 0; i < ntokens; i++) if (actrow[i] == ACTION_NUMBER_MINIMUM) actrow[i] = 0; @@ -369,7 +371,7 @@ action_row (state *s) if (conflicted) conflict_row (s); - return default_rule; + return default_reduction; } @@ -450,8 +452,8 @@ token_actions (void) for (i = 0; i < nstates; ++i) { - rule *default_rule = action_row (states[i]); - yydefact[i] = default_rule ? default_rule->number + 1 : 0; + rule *default_reduction = action_row (states[i]); + yydefact[i] = default_reduction ? default_reduction->number + 1 : 0; save_row (i); /* Now that the parser was computed, we can find which rules are diff --git a/src/tables.h b/src/tables.h index b0fbe9ac..a44cdb86 100644 --- a/src/tables.h +++ b/src/tables.h @@ -1,5 +1,5 @@ /* Prepare the LALR and GLR parser tables. - Copyright (C) 2002, 2004 Free Software Foundation, Inc. + Copyright (C) 2002, 2004, 2009 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -45,9 +45,9 @@ YYSTOS[S] = the symbol number of the symbol that leads to state S. - YYDEFACT[S] = default rule to reduce with in state s, when YYTABLE - doesn't specify something else to do. Zero means the default is an - error. + YYDEFACT[S] = default reduction number in state s. Performed when + YYTABLE doesn't specify something else to do. Zero means the default + is an error. YYDEFGOTO[I] = default state to go to after a reduction of a rule that generates variable NTOKENS + I, except when YYTABLE specifies diff --git a/tests/input.at b/tests/input.at index 71adf0b7..c19b8c1e 100644 --- a/tests/input.at +++ b/tests/input.at @@ -921,20 +921,20 @@ AT_BISON_CHECK([[Input.y]], [1], [], AT_CLEANUP -## ----------------------------------------- ## -## %define lr.default_rules invalid values. ## -## ----------------------------------------- ## +## ---------------------------------------------- ## +## %define lr.default_reductions invalid values. ## +## ---------------------------------------------- ## -AT_SETUP([[%define lr.default_rules invalid values]]) +AT_SETUP([[%define lr.default_reductions invalid values]]) AT_DATA([[input.y]], -[[%define lr.default_rules "bogus" +[[%define lr.default_reductions "bogus" %% start: ; ]]) AT_BISON_CHECK([[input.y]], [[1]], [[]], -[[input.y:1.9-24: invalid value for %define variable `lr.default_rules': `bogus' +[[input.y:1.9-29: invalid value for %define variable `lr.default_reductions': `bogus' ]]) AT_CLEANUP diff --git a/tests/reduce.at b/tests/reduce.at index 6642f654..a3d1e27c 100644 --- a/tests/reduce.at +++ b/tests/reduce.at @@ -1442,33 +1442,33 @@ dnl PARSER-EXIT-VALUE, PARSER-STDOUT, PARSER-STDERR -## -------------------------- ## -## %define lr.default_rules. ## -## -------------------------- ## +## ------------------------------- ## +## %define lr.default_reductions. ## +## ------------------------------- ## -# AT_TEST_LR_DEFAULT_RULES(GRAMMAR, INPUT, TABLES) -# ------------------------------------------------ -m4_define([AT_TEST_LR_DEFAULT_RULES], +# AT_TEST_LR_DEFAULT_REDUCTIONS(GRAMMAR, INPUT, TABLES) +# ----------------------------------------------------- +m4_define([AT_TEST_LR_DEFAULT_REDUCTIONS], [ -AT_TEST_TABLES_AND_PARSE([[no %define lr.default_rules]], +AT_TEST_TABLES_AND_PARSE([[no %define lr.default_reductions]], [[all]], [[]], [[]], [$1], [$2], [[]], [$3]) -AT_TEST_TABLES_AND_PARSE([[%define lr.default_rules "all"]], +AT_TEST_TABLES_AND_PARSE([[%define lr.default_reductions "all"]], [[all]], [[]], - [[%define lr.default_rules "all"]], + [[%define lr.default_reductions "all"]], [$1], [$2], [[]], [$3]) -AT_TEST_TABLES_AND_PARSE([[%define lr.default_rules "consistent"]], +AT_TEST_TABLES_AND_PARSE([[%define lr.default_reductions "consistent"]], [[consistent]], [[]], - [[%define lr.default_rules "consistent"]], + [[%define lr.default_reductions "consistent"]], [$1], [$2], [[]], [$3]) -AT_TEST_TABLES_AND_PARSE([[%define lr.default_rules "accepting"]], +AT_TEST_TABLES_AND_PARSE([[%define lr.default_reductions "accepting"]], [[accepting]], [[]], - [[%define lr.default_rules "accepting"]], + [[%define lr.default_reductions "accepting"]], [$1], [$2], [[]], [$3]) ]) -AT_TEST_LR_DEFAULT_RULES([[ +AT_TEST_LR_DEFAULT_REDUCTIONS([[ /* The start state is consistent and has a shift on 'a' and no reductions. After pushing the b below, enter an inconsistent state that has a shift and one reduction with one lookahead. */ @@ -1484,7 +1484,7 @@ a: 'a' ; /* After the previous reduction, enter an inconsistent state that has no shift and multiple reductions. The first reduction has more lookaheads than the - second, so the first should always be preferred as the default rule if + second, so the first should always be preferred as the default reduction if enabled. The second reduction has one lookahead. */ b: ; c: ;