Actually handle the yytable zero value correctly this time.

* data/bison.m4 (b4_integral_parser_tables_map): Don't mention
zero values in the YYTABLE comments.
* data/glr.c (yytable_value_is_error): Don't check for zero
value.
* data/lalr1.cc (yy_table_value_is_error_): Likewise.
* data/yacc.c (yytable_value_is_error): Likewise.
* data/lalr1.java (yy_table_value_is_error_): Likewise.
(yysyntax_error): Fix typo in code: use yytable_ not yycheck_.
* src/tables.h: In header comments, explain why it's useless to
check for a zero value in yytable.
This commit is contained in:
Joel E. Denny
2009-08-26 02:40:38 -04:00
parent f2b30bdf37
commit aa0cb40d61
10 changed files with 353 additions and 332 deletions

View File

@@ -1,3 +1,17 @@
2009-08-26 Joel E. Denny <jdenny@clemson.edu>
Actually handle the yytable zero value correctly this time.
* data/bison.m4 (b4_integral_parser_tables_map): Don't mention
zero values in the YYTABLE comments.
* data/glr.c (yytable_value_is_error): Don't check for zero
value.
* data/lalr1.cc (yy_table_value_is_error_): Likewise.
* data/yacc.c (yytable_value_is_error): Likewise.
* data/lalr1.java (yy_table_value_is_error_): Likewise.
(yysyntax_error): Fix typo in code: use yytable_ not yycheck_.
* src/tables.h: In header comments, explain why it's useless to
check for a zero value in yytable.
2009-08-25 Joel E. Denny <jdenny@clemson.edu> 2009-08-25 Joel E. Denny <jdenny@clemson.edu>
More fixes related to last two patches. More fixes related to last two patches.

View File

@@ -266,7 +266,7 @@ $1([defgoto], [b4_defgoto], [[YYDEFGOTO[NTERM-NUM].]])
$1([table], [b4_table], $1([table], [b4_table],
[[YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If [[YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
positive, shift that token. If negative, reduce the rule which positive, shift that token. If negative, reduce the rule which
number is the opposite. If zero or YYTABLE_NINF, syntax error.]]) number is the opposite. If YYTABLE_NINF, syntax error.]])
$1([check], [b4_check]) $1([check], [b4_check])

View File

@@ -972,8 +972,7 @@ yydefaultAction (yyStateNum yystate)
} }
#define yytable_value_is_error(yytable_value) \ #define yytable_value_is_error(yytable_value) \
(]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ \ ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
|| ]b4_table_value_equals([[table]], [[yytable_value]], [[0]])[)
/** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN. /** Set *YYACTION to the action to take in YYSTATE on seeing YYTOKEN.
* Result R means * Result R means

View File

@@ -668,7 +668,7 @@ b4_percent_code_get[]dnl
inline bool inline bool
]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue)
{ {
return yyvalue == 0 || yyvalue == yytable_ninf_; return yyvalue == yytable_ninf_;
} }
int int

View File

@@ -745,7 +745,7 @@ m4_popdef([b4_at_dollar])])dnl
int count = 0; int count = 0;
for (int x = yyxbegin; x < yyxend; ++x) for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_ if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yycheck_[x + yyn])) && !yy_table_value_is_error_ (yytable_[x + yyn]))
++count; ++count;
// FIXME: This method of building the message is not compatible // FIXME: This method of building the message is not compatible
@@ -757,7 +757,7 @@ m4_popdef([b4_at_dollar])])dnl
count = 0; count = 0;
for (int x = yyxbegin; x < yyxend; ++x) for (int x = yyxbegin; x < yyxend; ++x)
if (yycheck_[x + yyn] == x && x != yyterror_ if (yycheck_[x + yyn] == x && x != yyterror_
&& !yy_table_value_is_error_ (yycheck_[x + yyn])) && !yy_table_value_is_error_ (yytable_[x + yyn]))
{ {
res.append (count++ == 0 ? ", expecting " : " or "); res.append (count++ == 0 ? ", expecting " : " or ");
res.append (yytnamerr_ (yytname_[x])); res.append (yytnamerr_ (yytname_[x]));
@@ -785,7 +785,7 @@ m4_popdef([b4_at_dollar])])dnl
*/ */
private static boolean yy_table_value_is_error_ (int yyvalue) private static boolean yy_table_value_is_error_ (int yyvalue)
{ {
return yyvalue == 0 || yyvalue == yytable_ninf_; return yyvalue == yytable_ninf_;
} }
private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[; private static final ]b4_int_type_for([b4_pact])[ yypact_ninf_ = ]b4_pact_ninf[;

View File

@@ -531,8 +531,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
#define YYTABLE_NINF ]b4_table_ninf[ #define YYTABLE_NINF ]b4_table_ninf[
#define yytable_value_is_error(yytable_value) \ #define yytable_value_is_error(yytable_value) \
(]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ \ ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[
|| ]b4_table_value_equals([[table]], [[yytable_value]], [[0]])[)
]b4_parser_tables_define[ ]b4_parser_tables_define[

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.4.388-53f03. */ /* A Bison parser, made by GNU Bison 2.4.390-0aaa. */
/* Interface for Bison's Yacc-like parsers in C /* Interface for Bison's Yacc-like parsers in C
@@ -157,7 +157,7 @@
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 1609 of yacc.c */ /* Line 1608 of yacc.c */
#line 94 "parse-gram.y" #line 94 "parse-gram.y"
symbol *symbol; symbol *symbol;
@@ -171,7 +171,7 @@ typedef union YYSTYPE
named_ref *named_ref; named_ref *named_ref;
/* Line 1609 of yacc.c */ /* Line 1608 of yacc.c */
#line 176 "src/parse-gram.h" #line 176 "src/parse-gram.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1

View File

@@ -126,7 +126,7 @@ static int table_size = 32768;
base_number *table; base_number *table;
base_number *check; base_number *check;
/* The value used in TABLE to denote explicit syntax errors /* The value used in TABLE to denote explicit syntax errors
(%nonassoc), a negative infinite. First defaults to ACTION_NUMBER_MININUM, (%nonassoc), a negative infinite. First defaults to ACTION_NUMBER_MINIMUM,
but in order to keep small tables, renumbered as TABLE_ERROR, which but in order to keep small tables, renumbered as TABLE_ERROR, which
is the smallest (non error) value minus 1. */ is the smallest (non error) value minus 1. */
base_number table_ninf = 0; base_number table_ninf = 0;

View File

@@ -48,7 +48,7 @@
YYFINAL = the state number of the termination state. YYFINAL = the state number of the termination state.
YYTABLE = a vector filled with portions for different uses, found YYTABLE = a vector filled with portions for different uses, found
via YYPACT and YYPGOTO. via YYPACT and YYPGOTO, described below.
YYLAST ( = high) the number of the last element of YYTABLE, i.e., YYLAST ( = high) the number of the last element of YYTABLE, i.e.,
sizeof (YYTABLE) - 1. sizeof (YYTABLE) - 1.
@@ -87,7 +87,7 @@
If the value is negative, it is minus a rule number to reduce by. If the value is negative, it is minus a rule number to reduce by.
If the value is zero or YYTABLE_NINF, it's a syntax error. If the value is YYTABLE_NINF, it's a syntax error.
YYPGOTO[I] = the index in YYTABLE of the portion describing what to YYPGOTO[I] = the index in YYTABLE of the portion describing what to
do after reducing a rule that derives variable I + NTOKENS. This do after reducing a rule that derives variable I + NTOKENS. This
@@ -99,6 +99,16 @@
YYCHECK[YYPGOTO[I] + S] != S), then the default state (that is, YYCHECK[YYPGOTO[I] + S] != S), then the default state (that is,
YYDEFGOTO[I]) should be used instead of YYTABLE. Otherwise, YYDEFGOTO[I]) should be used instead of YYTABLE. Otherwise,
YYTABLE[YYPGOTO[I] + S] is the state to go to even if YYPGOTO[I] < 0. YYTABLE[YYPGOTO[I] + S] is the state to go to even if YYPGOTO[I] < 0.
When the above YYPACT, YYPGOTO, and YYCHECK tests determine that a
value from YYTABLE should be used, that value is never zero, so it is
useless to check for zero. When those tests indicate that the value
from YYDEFACT or YYDEFGOTO should be used instead, the value from
YYTABLE *might* be zero, which, as a consequence of the way in which
the tables are constructed, also happens to indicate that YYDEFACT or
YYDEFGOTO should be used. However, the YYTABLE value cannot be
trusted when the YYDEFACT or YYDEFGOTO value should be used. In
summary, forget about zero values in YYTABLE.
*/ */
extern int nvectors; extern int nvectors;