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/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c:
Adjust YYDEFACT and yydefact_ documentation.
* 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.
This commit is contained in:
Joel E. Denny
2009-04-23 03:18:03 -04:00
parent 34a6c2d19b
commit 620b572773
17 changed files with 339 additions and 302 deletions

View File

@@ -1,3 +1,33 @@
2009-04-23 Joel E. Denny <jdenny@ces.clemson.edu>
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/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c:
Adjust YYDEFACT and yydefact_ documentation.
* 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 Joel E. Denny <jdenny@ces.clemson.edu> 2009-04-21 Joel E. Denny <jdenny@ces.clemson.edu>
Document %define lr.type and lr.default_rules. Document %define lr.type and lr.default_rules.

9
NEWS
View File

@@ -24,10 +24,11 @@ Bison News
%define lr.type "IELR" %define lr.type "IELR"
%define lr.type "canonical LR" %define lr.type "canonical LR"
The default rules optimization in the parser tables can also be The default reduction optimization in the parser tables can also be
adjusted using `%define lr.default_rules'. See the documentation for adjusted using `%define lr.default_reductions'. See the documentation
`%define lr.type' and `%define lr.default_rules' in the section `Bison for `%define lr.type' and `%define lr.default_reductions' in the
Declaration Summary' in the Bison manual for the details. section `Bison Declaration Summary' in the Bison manual for the
details.
These features are experimental. More user feedback will help to These features are experimental. More user feedback will help to
stabilize them. stabilize them.

View File

@@ -1,8 +1,8 @@
-*- C -*- -*- C -*-
# GLR skeleton for Bison # GLR skeleton for Bison
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free
# Foundation, Inc. # Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -150,7 +150,7 @@ m4_changecom()
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_parser_file_name@)@ @output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison GLR parsers in C], 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. */ /* C GLR parser skeleton written by Paul Hilfinger. */
@@ -412,9 +412,9 @@ static const ]b4_int_type_for([b4_merger])[ yymerger[] =
]b4_merger[ ]b4_merger[
}; };
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE /* YYDEFACT[S] -- default reduction number in state S. Performed when
doesn't specify something else to do. Zero means the default is an YYTABLE doesn't specify something else to do. Zero means the default
error. */ is an error. */
static const ]b4_int_type_for([b4_defact])[ yydefact[] = static const ]b4_int_type_for([b4_defact])[ yydefact[] =
{ {
]b4_defact[ ]b4_defact[
@@ -2639,7 +2639,7 @@ m4_if(b4_skeleton, ["glr.c"],
[b4_defines_if( [b4_defines_if(
[@output(b4_spec_defines_file@)@ [@output(b4_spec_defines_file@)@
b4_copyright([Skeleton interface for Bison GLR parsers in C], 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 b4_shared_declarations

View File

@@ -1,6 +1,6 @@
# C++ skeleton for Bison # C++ skeleton for Bison
# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 # Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
# Free Software Foundation, Inc. # Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@@ -35,7 +35,7 @@ m4_divert_push(0)dnl
b4_defines_if( b4_defines_if(
[@output(b4_spec_defines_file@)@ [@output(b4_spec_defines_file@)@
b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++], b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++],
[2002, 2003, 2004, 2005, 2006, 2007, 2008]) [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
dnl FIXME: This is wrong, we want computed header guards. dnl FIXME: This is wrong, we want computed header guards.
[ [
/* C++ LALR(1) parser skeleton written by Akim Demaille. */ /* C++ LALR(1) parser skeleton written by Akim Demaille. */
@@ -197,7 +197,7 @@ b4_error_verbose_if([, int tok])[);
static const ]b4_int_type_for([b4_pact])[ yypact_[]; static const ]b4_int_type_for([b4_pact])[ yypact_[];
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_; static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
/// For a state, default rule to reduce. /// For a state, default reduction number.
/// Unless\a yytable_ specifies something else to do. /// Unless\a yytable_ specifies something else to do.
/// Zero means the default is an error. /// Zero means the default is an error.
static const ]b4_int_type_for([b4_defact])[ yydefact_[]; static const ]b4_int_type_for([b4_defact])[ yydefact_[];
@@ -300,7 +300,7 @@ b4_percent_code_get([[provides]])[]dnl
])dnl ])dnl
@output(b4_parser_file_name@)@ @output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++], b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
[2002, 2003, 2004, 2005, 2006, 2007, 2008]) [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
b4_percent_code_get([[top]])[]dnl b4_percent_code_get([[top]])[]dnl
m4_if(b4_prefix, [yy], [], m4_if(b4_prefix, [yy], [],
[ [
@@ -889,9 +889,9 @@ b4_error_verbose_if([, int tok])[)
]b4_pact[ ]b4_pact[
}; };
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE /* YYDEFACT[S] -- default reduction number in state S. Performed when
doesn't specify something else to do. Zero means the default is an YYTABLE doesn't specify something else to do. Zero means the
error. */ default is an error. */
const ]b4_int_type_for([b4_defact])[ const ]b4_int_type_for([b4_defact])[
]b4_parser_class_name[::yydefact_[] = ]b4_parser_class_name[::yydefact_[] =
{ {
@@ -1057,7 +1057,7 @@ b4_error_verbose_if([, int tok])[)
dnl dnl
@output(b4_dir_prefix[]stack.hh@)@ @output(b4_dir_prefix[]stack.hh@)@
b4_copyright([Stack handling for Bison parsers in C++], b4_copyright([Stack handling for Bison parsers in C++],
[2002, 2003, 2004, 2005, 2006, 2007, 2008])[ [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])[
#ifndef BISON_STACK_HH #ifndef BISON_STACK_HH
# define BISON_STACK_HH # define BISON_STACK_HH

View File

@@ -1,6 +1,6 @@
# Java skeleton for Bison -*- autoconf -*- # Java skeleton for Bison -*- autoconf -*-
# Copyright (C) 2007, 2008 Free Software Foundation, Inc. # Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -25,7 +25,7 @@ m4_ifval(m4_defn([b4_symbol_destructors]),
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_parser_file_name@)@ @output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java], 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]); b4_percent_define_ifdef([package], [package b4_percent_define_get([package]);
])[/* First part of user declarations. */ ])[/* First part of user declarations. */
@@ -732,9 +732,9 @@ m4_popdef([b4_at_dollar])])dnl
]b4_pact[ ]b4_pact[
}; };
/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE /* YYDEFACT[S] -- default reduction number in state S. Performed when
doesn't specify something else to do. Zero means the default is an YYTABLE doesn't specify something else to do. Zero means the
error. */ default is an error. */
private static final ]b4_int_type_for([b4_defact])[ yydefact_[] = private static final ]b4_int_type_for([b4_defact])[ yydefact_[] =
{ {
]b4_defact[ ]b4_defact[

View File

@@ -3,7 +3,7 @@
# Yacc compatible skeleton for Bison # Yacc compatible skeleton for Bison
# Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, # Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
# 2007, 2008 Free Software Foundation, Inc. # 2007, 2008, 2009 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@@ -155,7 +155,8 @@ m4_changecom()
m4_divert_push(0)dnl m4_divert_push(0)dnl
@output(b4_parser_file_name@)@ @output(b4_parser_file_name@)@
b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl ' b4_copyright([Skeleton implementation for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006])[ [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009])[
/* C LALR(1) parser skeleton written by Richard Stallman, by /* C LALR(1) parser skeleton written by Richard Stallman, by
simplifying the original so-called "semantic" parser. */ simplifying the original so-called "semantic" parser. */
@@ -547,8 +548,8 @@ static const ]b4_int_type_for([b4_r2])[ yyr2[] =
]b4_r2[ ]b4_r2[
}; };
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
STATE-NUM when YYTABLE doesn't specify something else to do. Zero Performed when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */ means the default is an error. */
static const ]b4_int_type_for([b4_defact])[ yydefact[] = static const ]b4_int_type_for([b4_defact])[ yydefact[] =
{ {
@@ -1676,7 +1677,8 @@ yypushreturn:
b4_defines_if( b4_defines_if(
[@output(b4_spec_defines_file@)@ [@output(b4_spec_defines_file@)@
b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl ' b4_copyright([Skeleton interface for Bison's Yacc-like parsers in C],dnl '
[1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006]) [1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009])
b4_percent_code_get([[requires]])[]dnl b4_percent_code_get([[requires]])[]dnl

View File

@@ -4899,9 +4899,9 @@ More user feedback will help to stabilize it.)
@item Default Value: @code{"pull"} @item Default Value: @code{"pull"}
@end itemize @end itemize
@item lr.default_rules @item lr.default_reductions
@cindex default rules @cindex default reductions
@findex %define lr.default_rules @findex %define lr.default_reductions
@cindex delayed syntax errors @cindex delayed syntax errors
@cindex syntax errors delayed @cindex syntax errors delayed
@@ -4909,15 +4909,14 @@ More user feedback will help to stabilize it.)
@item Language(s): all @item Language(s): all
@item Purpose: Specifies the kind of states that are permitted to @item Purpose: Specifies the kind of states that are permitted to
contain default rules. contain default reductions.
That is, in such a state, Bison declares the rule with the largest That is, in such a state, Bison declares the reduction with the largest
lookahead set to be the default rule by which to reduce and then removes lookahead set to be the default reduction and then removes that
that lookahead set. lookahead set.
The advantages of default rules are discussed below. The advantages of default reductions are discussed below.
The disadvantage is that, when the generated parser encounters a The disadvantage is that, when the generated parser encounters a
syntactically unacceptable token, the parser might then perform syntactically unacceptable token, the parser might then perform
unnecessary reductions by default rules before it can detect the syntax unnecessary default reductions before it can detect the syntax error.
error.
(This feature is experimental. (This feature is experimental.
More user feedback will help to stabilize it.) More user feedback will help to stabilize it.)
@@ -4927,14 +4926,14 @@ More user feedback will help to stabilize it.)
@item @code{"all"}. @item @code{"all"}.
For @acronym{LALR} and @acronym{IELR} parsers (@pxref{Decl For @acronym{LALR} and @acronym{IELR} parsers (@pxref{Decl
Summary,,lr.type}) by default, all states are permitted to contain 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 advantage is that parser table sizes can be significantly reduced.
The reason Bison does not by default attempt to address the disadvantage The reason Bison does not by default attempt to address the disadvantage
of delayed syntax error detection is that this disadvantage is already of delayed syntax error detection is that this disadvantage is already
inherent in @acronym{LALR} and @acronym{IELR} parser tables. inherent in @acronym{LALR} and @acronym{IELR} parser tables.
That is, unlike a canonical @acronym{LR} state, an @acronym{LALR} or That is, unlike in a canonical @acronym{LR} state, the lookahead sets of
@acronym{IELR} state can contain syntactically incorrect tokens in the reductions in an @acronym{LALR} or @acronym{IELR} state can contain
lookahead sets of its rules. tokens that are syntactically incorrect for some left contexts.
@item @code{"consistent"}. @item @code{"consistent"}.
@cindex consistent states @cindex consistent states
@@ -4942,16 +4941,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 If that action is a reduction, then the parser does not need to request
a lookahead token from the scanner before performing that action. a lookahead token from the scanner before performing that action.
However, the parser only recognizes the ability to ignore the lookahead However, the parser only recognizes the ability to ignore the lookahead
token when such a reduction is encoded as a default rule. token when such a reduction is encoded as a default reduction.
Thus, if default rules are permitted in and only in consistent states, Thus, if default reductions are permitted in and only in consistent
then a canonical @acronym{LR} parser reports a syntax error as soon as states, then a canonical @acronym{LR} parser reports a syntax error as
it @emph{needs} the syntactically unacceptable token from the scanner. soon as it @emph{needs} the syntactically unacceptable token from the
scanner.
@item @code{"accepting"}. @item @code{"accepting"}.
@cindex accepting state @cindex accepting state
By default, the only default rule permitted in a canonical @acronym{LR} By default, the only default reduction permitted in a canonical
parser is the accept rule in the accepting state, which the parser @acronym{LR} parser is the accept action in the accepting state, which
reaches only after reading all tokens from the input. the parser reaches only after reading all tokens from the input.
Thus, the default canonical @acronym{LR} parser reports a syntax error Thus, the default canonical @acronym{LR} parser reports a syntax error
as soon as it @emph{reaches} the syntactically unacceptable token as soon as it @emph{reaches} the syntactically unacceptable token
without performing any extra reductions. without performing any extra reductions.
@@ -5028,8 +5028,8 @@ While Bison generates @acronym{LALR} parser tables by default for
historical reasons, @acronym{IELR} or canonical @acronym{LR} is almost historical reasons, @acronym{IELR} or canonical @acronym{LR} is almost
always preferable for deterministic parsers. always preferable for deterministic parsers.
The trouble is that @acronym{LALR} parser tables can suffer from The trouble is that @acronym{LALR} parser tables can suffer from
mysterious conflicts and may not accept the full set of sentences that mysterious conflicts and thus may not accept the full set of sentences
@acronym{IELR} and canonical @acronym{LR} accept. that @acronym{IELR} and canonical @acronym{LR} accept.
@xref{Mystery Conflicts}, for details. @xref{Mystery Conflicts}, for details.
However, there are at least two scenarios where @acronym{LALR} may be However, there are at least two scenarios where @acronym{LALR} may be
worthwhile: worthwhile:
@@ -5039,8 +5039,8 @@ worthwhile:
do not resolve any conflicts statically (for example, with @code{%left} do not resolve any conflicts statically (for example, with @code{%left}
or @code{%prec}), then the parser explores all potential parses of any or @code{%prec}), then the parser explores all potential parses of any
given input. given input.
Thus, the use of @acronym{LALR} parser tables is guaranteed not to alter In this case, the use of @acronym{LALR} parser tables is guaranteed not
the language accepted by the parser. to alter the language accepted by the parser.
@acronym{LALR} parser tables are the smallest parser tables Bison can @acronym{LALR} parser tables are the smallest parser tables Bison can
currently generate, so they may be preferable. currently generate, so they may be preferable.
@@ -5069,13 +5069,14 @@ This can significantly reduce the complexity of developing of a grammar.
@item @code{"canonical LR"}. @item @code{"canonical LR"}.
@cindex delayed syntax errors @cindex delayed syntax errors
@cindex syntax errors delayed @cindex syntax errors delayed
The only advantage of canonical @acronym{LR} over @acronym{IELR} is that The only advantage of canonical @acronym{LR} over @acronym{IELR} is
every canonical @acronym{LR} state encodes that state's exact set of that, for every left context of every canonical @acronym{LR} state, the
syntactically acceptable tokens. set of tokens accepted by that state is the exact set of tokens that is
The only difference in parsing behavior is then that the canonical 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 @acronym{LR} parser can report a syntax error as soon as possible
without performing any unnecessary reductions. 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, Even when canonical @acronym{LR} behavior is ultimately desired,
@acronym{IELR}'s elimination of duplicate conflicts should still @acronym{IELR}'s elimination of duplicate conflicts should still
facilitate the development of a grammar. facilitate the development of a grammar.
@@ -10341,7 +10342,7 @@ committee document contributing to what became the Algol 60 report.
@item Consistent State @item Consistent State
A state containing only one possible action. A state containing only one possible action.
@xref{Decl Summary,,lr.default_rules}. @xref{Decl Summary,,lr.default_reductions}.
@item Context-free grammars @item Context-free grammars
Grammars specified as rules that can be applied regardless of context. Grammars specified as rules that can be applied regardless of context.
@@ -10350,12 +10351,13 @@ expression, integers are allowed @emph{anywhere} an expression is
permitted. @xref{Language and Grammar, ,Languages and Context-Free permitted. @xref{Language and Grammar, ,Languages and Context-Free
Grammars}. Grammars}.
@item Default Rule @item Default Reduction
The rule by which a parser should reduce if the current parser state The reduction that a parser should perform if the current parser state
contains no other action for the lookahead token. contains no other action for the lookahead token.
In permitted parser states, Bison declares the rule with the largest In permitted parser states, Bison declares the reduction with the
lookahead set to be the default rule and removes that lookahead set. largest lookahead set to be the default reduction and removes that
@xref{Decl Summary,,lr.default_rules}. lookahead set.
@xref{Decl Summary,,lr.default_reductions}.
@item Dynamic allocation @item Dynamic allocation
Allocation of memory that occurs during execution, rather than at Allocation of memory that occurs during execution, rather than at

View File

@@ -328,7 +328,7 @@ compute_lookahead_tokens (void)
`----------------------------------------------------*/ `----------------------------------------------------*/
static int 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; int n_lookahead_tokens = 0;
reductions *rp = s->reductions; 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 /* We need a lookahead either to distinguish different reductions
(i.e., there are two or more), or to distinguish a reduction from a (i.e., there are two or more), or to distinguish a reduction from a
shift. Otherwise, it is straightforward, and the state is shift. Otherwise, it is straightforward, and the state is
`consistent'. However, for states that have any rules, treat only `consistent'. However, treat only the accepting state as
the accepting state as consistent (since there is never a lookahead consistent (because there is never a lookahead token that makes
token that makes sense there, and so no lookahead token should be sense there, and so no lookahead token should be read) if the user
read) if the user has otherwise disabled default rules. */ has otherwise disabled default reductions. */
if (rp->num > 1 if (rp->num > 1
|| (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0)) || (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0))
|| (rp->num == 1 && rp->rules[0]->number != 0 || (rp->num == 1 && rp->rules[0]->number != 0
&& default_rule_only_for_accept)) && default_reduction_only_for_accept))
n_lookahead_tokens += rp->num; n_lookahead_tokens += rp->num;
else else
s->consistent = 1; s->consistent = 1;
@@ -369,18 +369,21 @@ initialize_LA (void)
{ {
state_number i; state_number i;
bitsetv pLA; bitsetv pLA;
bool default_rule_only_for_accept; bool default_reduction_only_for_accept;
{ {
char *default_rules = muscle_percent_define_get ("lr.default_rules"); char *default_reductions =
default_rule_only_for_accept = 0 == strcmp (default_rules, "accepting"); muscle_percent_define_get ("lr.default_reductions");
free (default_rules); default_reduction_only_for_accept =
0 == strcmp (default_reductions, "accepting");
free (default_reductions);
} }
/* Compute the total number of reductions requiring a lookahead. */ /* Compute the total number of reductions requiring a lookahead. */
nLA = 0; nLA = 0;
for (i = 0; i < nstates; i++) for (i = 0; i < nstates; i++)
nLA += 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. */ /* Avoid having to special case 0. */
if (!nLA) if (!nLA)
nLA = 1; nLA = 1;
@@ -392,7 +395,8 @@ initialize_LA (void)
for (i = 0; i < nstates; i++) for (i = 0; i < nstates; i++)
{ {
int count = 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) if (count)
{ {
states[i]->reductions->lookahead_tokens = pLA; states[i]->reductions->lookahead_tokens = pLA;

View File

@@ -1,10 +1,9 @@
/* A Bison parser, made by GNU Bison 2.4.1.49-783b. */
/* A Bison parser, made by GNU Bison 2.4.4-738cd. */
/* Skeleton implementation for Bison's Yacc-like parsers in C /* Skeleton implementation for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Free Software Foundation, Inc. 2007, 2008, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -46,7 +45,7 @@
#define YYBISON 1 #define YYBISON 1
/* Bison version. */ /* Bison version. */
#define YYBISON_VERSION "2.4.4-738cd" #define YYBISON_VERSION "2.4.1.49-783b"
/* Skeleton name. */ /* Skeleton name. */
#define YYSKELETON_NAME "yacc.c" #define YYSKELETON_NAME "yacc.c"
@@ -75,7 +74,7 @@
/* Copy the first part of user declarations. */ /* Copy the first part of user declarations. */
/* Line 189 of yacc.c */ /* Line 190 of yacc.c */
#line 1 "parse-gram.y" #line 1 "parse-gram.y"
/* Bison Grammar Parser -*- C -*- /* Bison Grammar Parser -*- C -*-
@@ -150,8 +149,8 @@ static int current_prec = 0;
#define YYTYPE_UINT8 uint_fast8_t #define YYTYPE_UINT8 uint_fast8_t
/* Line 189 of yacc.c */ /* Line 190 of yacc.c */
#line 155 "parse-gram.c" #line 154 "parse-gram.c"
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
@@ -299,7 +298,7 @@ static int current_prec = 0;
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 222 of yacc.c */ /* Line 223 of yacc.c */
#line 92 "parse-gram.y" #line 92 "parse-gram.y"
symbol *symbol; symbol *symbol;
@@ -313,8 +312,8 @@ typedef union YYSTYPE
/* Line 222 of yacc.c */ /* Line 223 of yacc.c */
#line 318 "parse-gram.c" #line 317 "parse-gram.c"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -338,8 +337,8 @@ typedef struct YYLTYPE
/* Copy the second part of user declarations. */ /* Copy the second part of user declarations. */
/* Line 264 of yacc.c */ /* Line 265 of yacc.c */
#line 343 "parse-gram.c" #line 342 "parse-gram.c"
#ifdef short #ifdef short
# undef short # undef short
@@ -754,8 +753,8 @@ static const yytype_uint8 yyr2[] =
1, 1, 1, 1, 0, 2 1, 1, 1, 1, 0, 2
}; };
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state /* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
STATE-NUM when YYTABLE doesn't specify something else to do. Zero Performed when YYTABLE doesn't specify something else to do. Zero
means the default is an error. */ means the default is an error. */
static const yytype_uint8 yydefact[] = static const yytype_uint8 yydefact[] =
{ {
@@ -1029,147 +1028,147 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
{ {
case 3: /* "\"string\"" */ case 3: /* "\"string\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 180 "parse-gram.y" #line 180 "parse-gram.y"
{ fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); }; { fputs (quotearg_style (c_quoting_style, (yyvaluep->chars)), stderr); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1038 "parse-gram.c" #line 1037 "parse-gram.c"
break; break;
case 4: /* "\"integer\"" */ case 4: /* "\"integer\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 191 "parse-gram.y" #line 191 "parse-gram.y"
{ fprintf (stderr, "%d", (yyvaluep->integer)); }; { fprintf (stderr, "%d", (yyvaluep->integer)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1047 "parse-gram.c" #line 1046 "parse-gram.c"
break; break;
case 43: /* "\"{...}\"" */ case 43: /* "\"{...}\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 182 "parse-gram.y" #line 182 "parse-gram.y"
{ fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); }; { fprintf (stderr, "{\n%s\n}", (yyvaluep->code)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1056 "parse-gram.c" #line 1055 "parse-gram.c"
break; break;
case 44: /* "\"char\"" */ case 44: /* "\"char\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 174 "parse-gram.y" #line 174 "parse-gram.y"
{ fputs (char_name ((yyvaluep->character)), stderr); }; { fputs (char_name ((yyvaluep->character)), stderr); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1065 "parse-gram.c" #line 1064 "parse-gram.c"
break; break;
case 45: /* "\"epilogue\"" */ case 45: /* "\"epilogue\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 182 "parse-gram.y" #line 182 "parse-gram.y"
{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1074 "parse-gram.c" #line 1073 "parse-gram.c"
break; break;
case 47: /* "\"identifier\"" */ case 47: /* "\"identifier\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 187 "parse-gram.y" #line 187 "parse-gram.y"
{ fputs ((yyvaluep->uniqstr), stderr); }; { fputs ((yyvaluep->uniqstr), stderr); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1083 "parse-gram.c" #line 1082 "parse-gram.c"
break; break;
case 48: /* "\"identifier:\"" */ case 48: /* "\"identifier:\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 188 "parse-gram.y" #line 188 "parse-gram.y"
{ fprintf (stderr, "%s:", (yyvaluep->uniqstr)); }; { fprintf (stderr, "%s:", (yyvaluep->uniqstr)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1092 "parse-gram.c" #line 1091 "parse-gram.c"
break; break;
case 51: /* "\"%{...%}\"" */ case 51: /* "\"%{...%}\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 182 "parse-gram.y" #line 182 "parse-gram.y"
{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1101 "parse-gram.c" #line 1100 "parse-gram.c"
break; break;
case 53: /* "\"type\"" */ case 53: /* "\"type\"" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 186 "parse-gram.y" #line 186 "parse-gram.y"
{ fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); }; { fprintf (stderr, "<%s>", (yyvaluep->uniqstr)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1110 "parse-gram.c" #line 1109 "parse-gram.c"
break; break;
case 82: /* "variable" */ case 82: /* "variable" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 187 "parse-gram.y" #line 187 "parse-gram.y"
{ fputs ((yyvaluep->uniqstr), stderr); }; { fputs ((yyvaluep->uniqstr), stderr); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1119 "parse-gram.c" #line 1118 "parse-gram.c"
break; break;
case 83: /* "content.opt" */ case 83: /* "content.opt" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 182 "parse-gram.y" #line 182 "parse-gram.y"
{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1128 "parse-gram.c" #line 1127 "parse-gram.c"
break; break;
case 84: /* "braceless" */ case 84: /* "braceless" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 182 "parse-gram.y" #line 182 "parse-gram.y"
{ fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); }; { fprintf (stderr, "{\n%s\n}", (yyvaluep->chars)); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1137 "parse-gram.c" #line 1136 "parse-gram.c"
break; break;
case 85: /* "id" */ case 85: /* "id" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 194 "parse-gram.y" #line 194 "parse-gram.y"
{ fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1146 "parse-gram.c" #line 1145 "parse-gram.c"
break; break;
case 86: /* "id_colon" */ case 86: /* "id_colon" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 195 "parse-gram.y" #line 195 "parse-gram.y"
{ fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); }; { fprintf (stderr, "%s:", (yyvaluep->symbol)->tag); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1155 "parse-gram.c" #line 1154 "parse-gram.c"
break; break;
case 87: /* "symbol" */ case 87: /* "symbol" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 194 "parse-gram.y" #line 194 "parse-gram.y"
{ fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1164 "parse-gram.c" #line 1163 "parse-gram.c"
break; break;
case 88: /* "string_as_id" */ case 88: /* "string_as_id" */
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 194 "parse-gram.y" #line 194 "parse-gram.y"
{ fprintf (stderr, "%s", (yyvaluep->symbol)->tag); }; { fprintf (stderr, "%s", (yyvaluep->symbol)->tag); };
/* Line 715 of yacc.c */ /* Line 716 of yacc.c */
#line 1173 "parse-gram.c" #line 1172 "parse-gram.c"
break; break;
default: default:
break; break;
@@ -1688,7 +1687,7 @@ YYLTYPE yylloc;
/* User initialization code. */ /* User initialization code. */
/* Line 1248 of yacc.c */ /* Line 1249 of yacc.c */
#line 84 "parse-gram.y" #line 84 "parse-gram.y"
{ {
/* Bison's grammar can initial empty locations, hence a default /* Bison's grammar can initial empty locations, hence a default
@@ -1697,8 +1696,8 @@ YYLTYPE yylloc;
boundary_set (&yylloc.end, current_file, 1, 1); boundary_set (&yylloc.end, current_file, 1, 1);
} }
/* Line 1248 of yacc.c */ /* Line 1249 of yacc.c */
#line 1702 "parse-gram.c" #line 1701 "parse-gram.c"
yylsp[0] = yylloc; yylsp[0] = yylloc;
goto yysetstate; goto yysetstate;
@@ -1885,7 +1884,7 @@ yyreduce:
{ {
case 6: case 6:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 218 "parse-gram.y" #line 218 "parse-gram.y"
{ {
code_props plain_code; code_props plain_code;
@@ -1900,14 +1899,14 @@ yyreduce:
case 7: case 7:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 227 "parse-gram.y" #line 227 "parse-gram.y"
{ debug_flag = true; } { debug_flag = true; }
break; break;
case 8: case 8:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 229 "parse-gram.y" #line 229 "parse-gram.y"
{ {
muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars)); muscle_percent_define_insert ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars));
@@ -1916,14 +1915,14 @@ yyreduce:
case 9: case 9:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 232 "parse-gram.y" #line 232 "parse-gram.y"
{ defines_flag = true; } { defines_flag = true; }
break; break;
case 10: case 10:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 234 "parse-gram.y" #line 234 "parse-gram.y"
{ {
defines_flag = true; defines_flag = true;
@@ -1933,42 +1932,42 @@ yyreduce:
case 11: case 11:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 238 "parse-gram.y" #line 238 "parse-gram.y"
{ error_verbose = true; } { error_verbose = true; }
break; break;
case 12: case 12:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 239 "parse-gram.y" #line 239 "parse-gram.y"
{ expected_sr_conflicts = (yyvsp[(2) - (2)].integer); } { expected_sr_conflicts = (yyvsp[(2) - (2)].integer); }
break; break;
case 13: case 13:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 240 "parse-gram.y" #line 240 "parse-gram.y"
{ expected_rr_conflicts = (yyvsp[(2) - (2)].integer); } { expected_rr_conflicts = (yyvsp[(2) - (2)].integer); }
break; break;
case 14: case 14:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 241 "parse-gram.y" #line 241 "parse-gram.y"
{ spec_file_prefix = (yyvsp[(2) - (2)].chars); } { spec_file_prefix = (yyvsp[(2) - (2)].chars); }
break; break;
case 15: case 15:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 242 "parse-gram.y" #line 242 "parse-gram.y"
{ spec_file_prefix = (yyvsp[(3) - (3)].chars); } { spec_file_prefix = (yyvsp[(3) - (3)].chars); }
break; break;
case 16: case 16:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 244 "parse-gram.y" #line 244 "parse-gram.y"
{ {
nondeterministic_parser = true; nondeterministic_parser = true;
@@ -1978,7 +1977,7 @@ yyreduce:
case 17: case 17:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 249 "parse-gram.y" #line 249 "parse-gram.y"
{ {
code_props action; code_props action;
@@ -1992,80 +1991,77 @@ yyreduce:
case 18: case 18:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 257 "parse-gram.y" #line 257 "parse-gram.y"
{ language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); } { language_argmatch ((yyvsp[(2) - (2)].chars), grammar_prio, (yylsp[(1) - (2)])); }
/* Line 1457 of yacc.c */
#line 2036 "../../../src/parse-gram.c"
break; break;
case 19: case 19:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 258 "parse-gram.y" #line 258 "parse-gram.y"
{ add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } { add_param ("lex_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
break; break;
case 20: case 20:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 259 "parse-gram.y" #line 259 "parse-gram.y"
{ locations_flag = true; } { locations_flag = true; }
break; break;
case 21: case 21:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 260 "parse-gram.y" #line 260 "parse-gram.y"
{ spec_name_prefix = (yyvsp[(2) - (2)].chars); } { spec_name_prefix = (yyvsp[(2) - (2)].chars); }
break; break;
case 22: case 22:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 261 "parse-gram.y" #line 261 "parse-gram.y"
{ spec_name_prefix = (yyvsp[(3) - (3)].chars); } { spec_name_prefix = (yyvsp[(3) - (3)].chars); }
break; break;
case 23: case 23:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 262 "parse-gram.y" #line 262 "parse-gram.y"
{ no_lines_flag = true; } { no_lines_flag = true; }
break; break;
case 24: case 24:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 263 "parse-gram.y" #line 263 "parse-gram.y"
{ nondeterministic_parser = true; } { nondeterministic_parser = true; }
break; break;
case 25: case 25:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 264 "parse-gram.y" #line 264 "parse-gram.y"
{ spec_outfile = (yyvsp[(2) - (2)].chars); } { spec_outfile = (yyvsp[(2) - (2)].chars); }
break; break;
case 26: case 26:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 265 "parse-gram.y" #line 265 "parse-gram.y"
{ spec_outfile = (yyvsp[(3) - (3)].chars); } { spec_outfile = (yyvsp[(3) - (3)].chars); }
break; break;
case 27: case 27:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 266 "parse-gram.y" #line 266 "parse-gram.y"
{ add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } { add_param ("parse_param", (yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
break; break;
case 28: case 28:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 268 "parse-gram.y" #line 268 "parse-gram.y"
{ {
/* %pure-parser is deprecated in favor of `%define api.pure', so use /* %pure-parser is deprecated in favor of `%define api.pure', so use
@@ -2083,14 +2079,14 @@ yyreduce:
case 29: case 29:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 280 "parse-gram.y" #line 280 "parse-gram.y"
{ version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); } { version_check (&(yylsp[(2) - (2)]), (yyvsp[(2) - (2)].chars)); }
break; break;
case 30: case 30:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 282 "parse-gram.y" #line 282 "parse-gram.y"
{ {
char const *skeleton_user = (yyvsp[(2) - (2)].chars); char const *skeleton_user = (yyvsp[(2) - (2)].chars);
@@ -2119,28 +2115,28 @@ yyreduce:
case 31: case 31:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 305 "parse-gram.y" #line 305 "parse-gram.y"
{ token_table_flag = true; } { token_table_flag = true; }
break; break;
case 32: case 32:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 306 "parse-gram.y" #line 306 "parse-gram.y"
{ report_flag |= report_states; } { report_flag |= report_states; }
break; break;
case 33: case 33:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 307 "parse-gram.y" #line 307 "parse-gram.y"
{ yacc_flag = true; } { yacc_flag = true; }
break; break;
case 37: case 37:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 315 "parse-gram.y" #line 315 "parse-gram.y"
{ {
grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); grammar_start_symbol_set ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]));
@@ -2149,7 +2145,7 @@ yyreduce:
case 38: case 38:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 319 "parse-gram.y" #line 319 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
@@ -2161,7 +2157,7 @@ yyreduce:
case 39: case 39:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 326 "parse-gram.y" #line 326 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
@@ -2173,7 +2169,7 @@ yyreduce:
case 40: case 40:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 333 "parse-gram.y" #line 333 "parse-gram.y"
{ {
default_prec = true; default_prec = true;
@@ -2182,7 +2178,7 @@ yyreduce:
case 41: case 41:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 337 "parse-gram.y" #line 337 "parse-gram.y"
{ {
default_prec = false; default_prec = false;
@@ -2191,7 +2187,7 @@ yyreduce:
case 42: case 42:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 341 "parse-gram.y" #line 341 "parse-gram.y"
{ {
/* Do not invoke muscle_percent_code_grow here since it invokes /* Do not invoke muscle_percent_code_grow here since it invokes
@@ -2203,7 +2199,7 @@ yyreduce:
case 43: case 43:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 348 "parse-gram.y" #line 348 "parse-gram.y"
{ {
muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)])); muscle_percent_code_grow ((yyvsp[(2) - (3)].uniqstr), (yylsp[(2) - (3)]), (yyvsp[(3) - (3)].chars), (yylsp[(3) - (3)]));
@@ -2213,21 +2209,21 @@ yyreduce:
case 44: case 44:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 362 "parse-gram.y" #line 362 "parse-gram.y"
{} {}
break; break;
case 45: case 45:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 363 "parse-gram.y" #line 363 "parse-gram.y"
{ muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } { muscle_code_grow ("union_name", (yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 46: case 46:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 368 "parse-gram.y" #line 368 "parse-gram.y"
{ {
union_seen = true; union_seen = true;
@@ -2238,14 +2234,14 @@ yyreduce:
case 47: case 47:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 379 "parse-gram.y" #line 379 "parse-gram.y"
{ current_class = nterm_sym; } { current_class = nterm_sym; }
break; break;
case 48: case 48:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 380 "parse-gram.y" #line 380 "parse-gram.y"
{ {
current_class = unknown_sym; current_class = unknown_sym;
@@ -2255,14 +2251,14 @@ yyreduce:
case 49: case 49:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 384 "parse-gram.y" #line 384 "parse-gram.y"
{ current_class = token_sym; } { current_class = token_sym; }
break; break;
case 50: case 50:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 385 "parse-gram.y" #line 385 "parse-gram.y"
{ {
current_class = unknown_sym; current_class = unknown_sym;
@@ -2272,7 +2268,7 @@ yyreduce:
case 51: case 51:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 390 "parse-gram.y" #line 390 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
@@ -2285,7 +2281,7 @@ yyreduce:
case 52: case 52:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 401 "parse-gram.y" #line 401 "parse-gram.y"
{ {
symbol_list *list; symbol_list *list;
@@ -2302,126 +2298,126 @@ yyreduce:
case 53: case 53:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 415 "parse-gram.y" #line 415 "parse-gram.y"
{ (yyval.assoc) = left_assoc; } { (yyval.assoc) = left_assoc; }
break; break;
case 54: case 54:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 416 "parse-gram.y" #line 416 "parse-gram.y"
{ (yyval.assoc) = right_assoc; } { (yyval.assoc) = right_assoc; }
break; break;
case 55: case 55:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 417 "parse-gram.y" #line 417 "parse-gram.y"
{ (yyval.assoc) = non_assoc; } { (yyval.assoc) = non_assoc; }
break; break;
case 56: case 56:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 421 "parse-gram.y" #line 421 "parse-gram.y"
{ current_type = NULL; } { current_type = NULL; }
break; break;
case 57: case 57:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 422 "parse-gram.y" #line 422 "parse-gram.y"
{ current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; } { current_type = (yyvsp[(1) - (1)].uniqstr); tag_seen = true; }
break; break;
case 58: case 58:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 428 "parse-gram.y" #line 428 "parse-gram.y"
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
break; break;
case 59: case 59:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 430 "parse-gram.y" #line 430 "parse-gram.y"
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
break; break;
case 60: case 60:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 434 "parse-gram.y" #line 434 "parse-gram.y"
{ (yyval.symbol) = (yyvsp[(1) - (1)].symbol); } { (yyval.symbol) = (yyvsp[(1) - (1)].symbol); }
break; break;
case 61: case 61:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 435 "parse-gram.y" #line 435 "parse-gram.y"
{ (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); } { (yyval.symbol) = (yyvsp[(1) - (2)].symbol); symbol_user_token_number_set ((yyvsp[(1) - (2)].symbol), (yyvsp[(2) - (2)].integer), (yylsp[(2) - (2)])); }
break; break;
case 62: case 62:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 441 "parse-gram.y" #line 441 "parse-gram.y"
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
break; break;
case 63: case 63:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 443 "parse-gram.y" #line 443 "parse-gram.y"
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); } { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), symbol_list_sym_new ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)]))); }
break; break;
case 64: case 64:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 447 "parse-gram.y" #line 447 "parse-gram.y"
{ (yyval.list) = (yyvsp[(1) - (1)].list); } { (yyval.list) = (yyvsp[(1) - (1)].list); }
break; break;
case 65: case 65:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 448 "parse-gram.y" #line 448 "parse-gram.y"
{ (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); } { (yyval.list) = symbol_list_prepend ((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].list)); }
break; break;
case 66: case 66:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 452 "parse-gram.y" #line 452 "parse-gram.y"
{ (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); } { (yyval.list) = symbol_list_sym_new ((yyvsp[(1) - (1)].symbol), (yylsp[(1) - (1)])); }
break; break;
case 67: case 67:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 453 "parse-gram.y" #line 453 "parse-gram.y"
{ (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } { (yyval.list) = symbol_list_type_new ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 68: case 68:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 454 "parse-gram.y" #line 454 "parse-gram.y"
{ (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); } { (yyval.list) = symbol_list_default_tagged_new ((yylsp[(1) - (1)])); }
break; break;
case 69: case 69:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 455 "parse-gram.y" #line 455 "parse-gram.y"
{ (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); } { (yyval.list) = symbol_list_default_tagless_new ((yylsp[(1) - (1)])); }
break; break;
case 70: case 70:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 461 "parse-gram.y" #line 461 "parse-gram.y"
{ {
current_type = (yyvsp[(1) - (1)].uniqstr); current_type = (yyvsp[(1) - (1)].uniqstr);
@@ -2431,7 +2427,7 @@ yyreduce:
case 71: case 71:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 466 "parse-gram.y" #line 466 "parse-gram.y"
{ {
symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true); symbol_class_set ((yyvsp[(1) - (1)].symbol), current_class, (yylsp[(1) - (1)]), true);
@@ -2441,7 +2437,7 @@ yyreduce:
case 72: case 72:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 471 "parse-gram.y" #line 471 "parse-gram.y"
{ {
symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
@@ -2452,7 +2448,7 @@ yyreduce:
case 73: case 73:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 477 "parse-gram.y" #line 477 "parse-gram.y"
{ {
symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true); symbol_class_set ((yyvsp[(1) - (2)].symbol), current_class, (yylsp[(1) - (2)]), true);
@@ -2463,7 +2459,7 @@ yyreduce:
case 74: case 74:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 483 "parse-gram.y" #line 483 "parse-gram.y"
{ {
symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true); symbol_class_set ((yyvsp[(1) - (3)].symbol), current_class, (yylsp[(1) - (3)]), true);
@@ -2475,7 +2471,7 @@ yyreduce:
case 81: case 81:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 513 "parse-gram.y" #line 513 "parse-gram.y"
{ {
yyerrok; yyerrok;
@@ -2484,77 +2480,77 @@ yyreduce:
case 82: case 82:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 519 "parse-gram.y" #line 519 "parse-gram.y"
{ current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); } { current_lhs = (yyvsp[(1) - (1)].symbol); current_lhs_location = (yylsp[(1) - (1)]); }
break; break;
case 84: case 84:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 523 "parse-gram.y" #line 523 "parse-gram.y"
{ grammar_current_rule_end ((yylsp[(1) - (1)])); } { grammar_current_rule_end ((yylsp[(1) - (1)])); }
break; break;
case 85: case 85:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 524 "parse-gram.y" #line 524 "parse-gram.y"
{ grammar_current_rule_end ((yylsp[(3) - (3)])); } { grammar_current_rule_end ((yylsp[(3) - (3)])); }
break; break;
case 87: case 87:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 530 "parse-gram.y" #line 530 "parse-gram.y"
{ grammar_current_rule_begin (current_lhs, current_lhs_location); } { grammar_current_rule_begin (current_lhs, current_lhs_location); }
break; break;
case 88: case 88:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 532 "parse-gram.y" #line 532 "parse-gram.y"
{ grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); } { grammar_current_rule_symbol_append ((yyvsp[(2) - (2)].symbol), (yylsp[(2) - (2)])); }
break; break;
case 89: case 89:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 534 "parse-gram.y" #line 534 "parse-gram.y"
{ grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); } { grammar_current_rule_action_append ((yyvsp[(2) - (2)].code), (yylsp[(2) - (2)])); }
break; break;
case 90: case 90:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 536 "parse-gram.y" #line 536 "parse-gram.y"
{ grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); } { grammar_current_rule_prec_set ((yyvsp[(3) - (3)].symbol), (yylsp[(3) - (3)])); }
break; break;
case 91: case 91:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 538 "parse-gram.y" #line 538 "parse-gram.y"
{ grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); } { grammar_current_rule_dprec_set ((yyvsp[(3) - (3)].integer), (yylsp[(3) - (3)])); }
break; break;
case 92: case 92:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 540 "parse-gram.y" #line 540 "parse-gram.y"
{ grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); } { grammar_current_rule_merge_set ((yyvsp[(3) - (3)].uniqstr), (yylsp[(3) - (3)])); }
break; break;
case 94: case 94:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 550 "parse-gram.y" #line 550 "parse-gram.y"
{ (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); } { (yyval.uniqstr) = uniqstr_new ((yyvsp[(1) - (1)].chars)); }
break; break;
case 95: case 95:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 556 "parse-gram.y" #line 556 "parse-gram.y"
{ {
(yyval.chars) = ""; (yyval.chars) = "";
@@ -2563,7 +2559,7 @@ yyreduce:
case 97: case 97:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 569 "parse-gram.y" #line 569 "parse-gram.y"
{ {
code_props plain_code; code_props plain_code;
@@ -2577,14 +2573,14 @@ yyreduce:
case 98: case 98:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 589 "parse-gram.y" #line 589 "parse-gram.y"
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 99: case 99:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 591 "parse-gram.y" #line 591 "parse-gram.y"
{ {
(yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)])); (yyval.symbol) = symbol_get (char_name ((yyvsp[(1) - (1)].character)), (yylsp[(1) - (1)]));
@@ -2595,14 +2591,14 @@ yyreduce:
case 100: case 100:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 599 "parse-gram.y" #line 599 "parse-gram.y"
{ (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); } { (yyval.symbol) = symbol_from_uniqstr ((yyvsp[(1) - (1)].uniqstr), (yylsp[(1) - (1)])); }
break; break;
case 103: case 103:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 611 "parse-gram.y" #line 611 "parse-gram.y"
{ {
(yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)])); (yyval.symbol) = symbol_get (quotearg_style (c_quoting_style, (yyvsp[(1) - (1)].chars)), (yylsp[(1) - (1)]));
@@ -2612,7 +2608,7 @@ yyreduce:
case 105: case 105:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 620 "parse-gram.y" #line 620 "parse-gram.y"
{ {
code_props plain_code; code_props plain_code;
@@ -2626,8 +2622,8 @@ yyreduce:
/* Line 1455 of yacc.c */ /* Line 1456 of yacc.c */
#line 2628 "parse-gram.c" #line 2627 "parse-gram.c"
default: break; default: break;
} }
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
@@ -2845,7 +2841,7 @@ yyreturn:
/* Line 1675 of yacc.c */ /* Line 1676 of yacc.c */
#line 630 "parse-gram.y" #line 630 "parse-gram.y"

View File

@@ -1,10 +1,9 @@
/* A Bison parser, made by GNU Bison 2.4.1.49-783b. */
/* A Bison parser, made by GNU Bison 2.4.4-738cd. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
Free Software Foundation, Inc. 2007, 2008, 2009 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify 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 it under the terms of the GNU General Public License as published by
@@ -160,7 +159,7 @@
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 1740 of yacc.c */ /* Line 1742 of yacc.c */
#line 92 "parse-gram.y" #line 92 "parse-gram.y"
symbol *symbol; symbol *symbol;
@@ -174,8 +173,8 @@ typedef union YYSTYPE
/* Line 1740 of yacc.c */ /* Line 1742 of yacc.c */
#line 179 "parse-gram.h" #line 178 "parse-gram.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define yystype YYSTYPE /* obsolescent; will be withdrawn */

View File

@@ -1,6 +1,6 @@
/* Print an xml on generated parser, for Bison, /* 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. 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; transitions *trans = s->transitions;
reductions *reds = s->reductions; reductions *reds = s->reductions;
rule *default_rule = NULL; rule *default_reduction = NULL;
int report = false; int report = false;
int i, j; int i, j;
@@ -254,7 +254,7 @@ print_reductions (FILE *out, int level, state *s)
} }
if (yydefact[s->number] != 0) if (yydefact[s->number] != 0)
default_rule = &rules[yydefact[s->number] - 1]; default_reduction = &rules[yydefact[s->number] - 1];
bitset_zero (no_reduce_set); bitset_zero (no_reduce_set);
FOR_EACH_SHIFT (trans, i) FOR_EACH_SHIFT (trans, i)
@@ -263,7 +263,7 @@ print_reductions (FILE *out, int level, state *s)
if (s->errs->symbols[i]) if (s->errs->symbols[i])
bitset_set (no_reduce_set, s->errs->symbols[i]->number); bitset_set (no_reduce_set, s->errs->symbols[i]->number);
if (default_rule) if (default_reduction)
report = true; report = true;
if (reds->lookahead_tokens) if (reds->lookahead_tokens)
@@ -276,7 +276,7 @@ print_reductions (FILE *out, int level, state *s)
{ {
if (! count) if (! count)
{ {
if (reds->rules[j] != default_rule) if (reds->rules[j] != default_reduction)
report = true; report = true;
count = true; count = true;
} }
@@ -307,7 +307,7 @@ print_reductions (FILE *out, int level, state *s)
{ {
if (! count) if (! count)
{ {
if (reds->rules[j] != default_rule) if (reds->rules[j] != default_reduction)
print_reduction (out, level + 1, symbols[i]->tag, print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], true); reds->rules[j], true);
else else
@@ -318,7 +318,7 @@ print_reductions (FILE *out, int level, state *s)
{ {
if (defaulted) if (defaulted)
print_reduction (out, level + 1, symbols[i]->tag, print_reduction (out, level + 1, symbols[i]->tag,
default_rule, true); default_reduction, true);
defaulted = false; defaulted = false;
print_reduction (out, level + 1, symbols[i]->tag, print_reduction (out, level + 1, symbols[i]->tag,
reds->rules[j], false); 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, print_reduction (out, level + 1,
"$default", default_rule, true); "$default", default_reduction, true);
xml_puts (out, level, "</reductions>"); xml_puts (out, level, "</reductions>");
} }

View File

@@ -242,7 +242,7 @@ print_reductions (FILE *out, state *s)
{ {
transitions *trans = s->transitions; transitions *trans = s->transitions;
reductions *reds = s->reductions; reductions *reds = s->reductions;
rule *default_rule = NULL; rule *default_reduction = NULL;
size_t width = 0; size_t width = 0;
int i, j; int i, j;
bool non_default_action = false; bool non_default_action = false;
@@ -251,7 +251,7 @@ print_reductions (FILE *out, state *s)
return; return;
if (yydefact[s->number] != 0) if (yydefact[s->number] != 0)
default_rule = &rules[yydefact[s->number] - 1]; default_reduction = &rules[yydefact[s->number] - 1];
bitset_zero (no_reduce_set); bitset_zero (no_reduce_set);
FOR_EACH_SHIFT (trans, i) 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); bitset_set (no_reduce_set, s->errs->symbols[i]->number);
/* Compute the width of the lookahead token column. */ /* Compute the width of the lookahead token column. */
if (default_rule) if (default_reduction)
width = strlen (_("$default")); width = strlen (_("$default"));
if (reds->lookahead_tokens) if (reds->lookahead_tokens)
@@ -274,7 +274,7 @@ print_reductions (FILE *out, state *s)
{ {
if (! count) if (! count)
{ {
if (reds->rules[j] != default_rule) if (reds->rules[j] != default_reduction)
max_length (&width, symbols[i]->tag); max_length (&width, symbols[i]->tag);
count = true; count = true;
} }
@@ -306,7 +306,7 @@ print_reductions (FILE *out, state *s)
{ {
if (! count) if (! count)
{ {
if (reds->rules[j] != default_rule) if (reds->rules[j] != default_reduction)
{ {
non_default_action = true; non_default_action = true;
print_reduction (out, width, print_reduction (out, width,
@@ -323,7 +323,7 @@ print_reductions (FILE *out, state *s)
if (defaulted) if (defaulted)
print_reduction (out, width, print_reduction (out, width,
symbols[i]->tag, symbols[i]->tag,
default_rule, true); default_reduction, true);
defaulted = false; defaulted = false;
print_reduction (out, width, print_reduction (out, width,
symbols[i]->tag, 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"); char *default_reductions =
print_reduction (out, width, _("$default"), default_rule, true); muscle_percent_define_get ("lr.default_reductions");
aver (0 == strcmp (default_rules, "all") print_reduction (out, width, _("$default"), default_reduction, true);
|| (0 == strcmp (default_rules, "consistent") aver (0 == strcmp (default_reductions, "all")
|| (0 == strcmp (default_reductions, "consistent")
&& !non_default_action) && !non_default_action)
|| (reds->num == 1 && reds->rules[0]->number == 0)); || (reds->num == 1 && reds->rules[0]->number == 0));
free (default_rules); free (default_reductions);
} }
} }

View File

@@ -561,9 +561,9 @@ reader (void)
muscle_percent_define_default ("lr.type", "LALR"); muscle_percent_define_default ("lr.type", "LALR");
lr_type = muscle_percent_define_get ("lr.type"); lr_type = muscle_percent_define_get ("lr.type");
if (0 != strcmp (lr_type, "canonical LR")) if (0 != strcmp (lr_type, "canonical LR"))
muscle_percent_define_default ("lr.default_rules", "all"); muscle_percent_define_default ("lr.default_reductions", "all");
else else
muscle_percent_define_default ("lr.default_rules", "accepting"); muscle_percent_define_default ("lr.default_reductions", "accepting");
free (lr_type); free (lr_type);
} }
@@ -571,7 +571,7 @@ reader (void)
{ {
static char const * const values[] = { static char const * const values[] = {
"lr.type", "LALR", "IELR", "canonical LR", NULL, "lr.type", "LALR", "IELR", "canonical LR", NULL,
"lr.default_rules", "all", "consistent", "accepting", NULL, "lr.default_reductions", "all", "consistent", "accepting", NULL,
NULL NULL
}; };
muscle_percent_define_check_values (values); muscle_percent_define_check_values (values);

View File

@@ -240,7 +240,7 @@ static rule *
action_row (state *s) action_row (state *s)
{ {
int i; int i;
rule *default_rule = NULL; rule *default_reduction = NULL;
reductions *reds = s->reductions; reductions *reds = s->reductions;
transitions *trans = s->transitions; transitions *trans = s->transitions;
errs *errp = s->errs; errs *errp = s->errs;
@@ -304,14 +304,15 @@ action_row (state *s)
actrow[sym->number] = ACTION_NUMBER_MINIMUM; 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 state_lookahead_tokens_count in lalr.c to understand when states are
labeled as consistent. */ labeled as consistent. */
{ {
char *default_rules = muscle_percent_define_get ("lr.default_rules"); char *default_reductions =
if (0 != strcmp (default_rules, "all") && !s->consistent) muscle_percent_define_get ("lr.default_reductions");
if (0 != strcmp (default_reductions, "all") && !s->consistent)
nodefault = true; nodefault = true;
free (default_rules); free (default_reductions);
} }
/* Now find the most common reduction and make it the default action /* 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 (reds->num >= 1 && !nodefault)
{ {
if (s->consistent) if (s->consistent)
default_rule = reds->rules[0]; default_reduction = reds->rules[0];
else else
{ {
int max = 0; int max = 0;
@@ -337,7 +338,7 @@ action_row (state *s)
if (count > max) if (count > max)
{ {
max = count; max = count;
default_rule = r; default_reduction = r;
} }
} }
@@ -351,17 +352,18 @@ action_row (state *s)
{ {
int j; int j;
for (j = 0; j < ntokens; 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])) && ! (nondeterministic_parser && conflrow[j]))
actrow[j] = 0; 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". */ So replace any action which says "error" with "use default". */
if (!default_rule) if (!default_reduction)
for (i = 0; i < ntokens; i++) for (i = 0; i < ntokens; i++)
if (actrow[i] == ACTION_NUMBER_MINIMUM) if (actrow[i] == ACTION_NUMBER_MINIMUM)
actrow[i] = 0; actrow[i] = 0;
@@ -369,7 +371,7 @@ action_row (state *s)
if (conflicted) if (conflicted)
conflict_row (s); conflict_row (s);
return default_rule; return default_reduction;
} }
@@ -450,8 +452,8 @@ token_actions (void)
for (i = 0; i < nstates; ++i) for (i = 0; i < nstates; ++i)
{ {
rule *default_rule = action_row (states[i]); rule *default_reduction = action_row (states[i]);
yydefact[i] = default_rule ? default_rule->number + 1 : 0; yydefact[i] = default_reduction ? default_reduction->number + 1 : 0;
save_row (i); save_row (i);
/* Now that the parser was computed, we can find which rules are /* Now that the parser was computed, we can find which rules are

View File

@@ -1,5 +1,5 @@
/* Prepare the LALR and GLR parser tables. /* 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. 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. 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 YYDEFACT[S] = default reduction number in state s. Performed when
doesn't specify something else to do. Zero means the default is an YYTABLE doesn't specify something else to do. Zero means the default
error. is an error.
YYDEFGOTO[I] = default state to go to after a reduction of a rule YYDEFGOTO[I] = default state to go to after a reduction of a rule
that generates variable NTOKENS + I, except when YYTABLE specifies that generates variable NTOKENS + I, except when YYTABLE specifies

View File

@@ -867,20 +867,20 @@ AT_BISON_CHECK([[Input.y]], [1], [],
AT_CLEANUP 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]], AT_DATA([[input.y]],
[[%define lr.default_rules "bogus" [[%define lr.default_reductions "bogus"
%% %%
start: ; start: ;
]]) ]])
AT_BISON_CHECK([[input.y]], [[1]], [[]], 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 AT_CLEANUP

View File

@@ -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) # AT_TEST_LR_DEFAULT_REDUCTIONS(GRAMMAR, INPUT, TABLES)
# ------------------------------------------------ # -----------------------------------------------------
m4_define([AT_TEST_LR_DEFAULT_RULES], 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]], [[]], [[all]], [[]],
[[]], [[]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default_rules "all"]], AT_TEST_TABLES_AND_PARSE([[%define lr.default_reductions "all"]],
[[all]], [[]], [[all]], [[]],
[[%define lr.default_rules "all"]], [[%define lr.default_reductions "all"]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default_rules "consistent"]], AT_TEST_TABLES_AND_PARSE([[%define lr.default_reductions "consistent"]],
[[consistent]], [[]], [[consistent]], [[]],
[[%define lr.default_rules "consistent"]], [[%define lr.default_reductions "consistent"]],
[$1], [$2], [[]], [$3]) [$1], [$2], [[]], [$3])
AT_TEST_TABLES_AND_PARSE([[%define lr.default_rules "accepting"]], AT_TEST_TABLES_AND_PARSE([[%define lr.default_reductions "accepting"]],
[[accepting]], [[]], [[accepting]], [[]],
[[%define lr.default_rules "accepting"]], [[%define lr.default_reductions "accepting"]],
[$1], [$2], [[]], [$3]) [$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. /* 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 After pushing the b below, enter an inconsistent state that has a shift and
one reduction with one lookahead. */ one reduction with one lookahead. */
@@ -1484,7 +1484,7 @@ a: 'a' ;
/* After the previous reduction, enter an inconsistent state that has no shift /* After the previous reduction, enter an inconsistent state that has no shift
and multiple reductions. The first reduction has more lookaheads than the 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. */ enabled. The second reduction has one lookahead. */
b: ; b: ;
c: ; c: ;