From d5eb0826afb8ede89bfe314671f2b37db55bd817 Mon Sep 17 00:00:00 2001 From: "Joel E. Denny" Date: Tue, 25 Aug 2009 19:41:49 -0400 Subject: [PATCH] More fixes related to last two patches. * data/c.m4 (b4_table_value_equals): Comment that YYID must be defined. * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Fix yytable comments: zero indicates syntax error not default action. * data/glr.c (yyis_pact_ninf): Rename to... (yypact_value_is_default): ... this. (yyisDefaultedState): Update for rename. (yyis_table_ninf): Rename to... (yytable_value_is_error): ... this, and check for value zero besides just YYTABLE_NINF. (yygetLRActions): Check for default value from yypact. It appears that this check is always performed before this function is invoked, and so adding the check here is probably redundant. However, the code may evolve after this subtlety is forgotten. Also, update for rename to yytable_value_is_error. Because that macro now checks for zero, a different but equivalent branch of the if-then-else here is evaluated. (yyreportSyntaxError): Update for rename to yytable_value_is_error. The zero condition was mishandled before. (yyrecoverSyntaxError): Update for renames. No behavioral changes. * data/lalr1.cc, data/lalr1.java (yy_pact_value_is_default_): New function. (yy_table_value_is_error_): New function. (parse): Use new functions where possible. No behavioral changes. (yysyntax_error_, yysyntax_error): Use yy_table_value_is_error_. The zero condition was mishandled before. * data/yacc.c (yyis_pact_ninf): Rename to... (yypact_value_is_default): ... this. (yyis_table_ninf): Rename to... (yytable_value_is_error): ... this, and check for value zero besides just YYTABLE_NINF. (yysyntax_error): Update for rename to yytable_value_is_error. The zero condition was mishandled before. (yyparse): Update for renames. No behavioral changes. * src/tables.h: Improve comments about yypact, yytable, etc. more. Most importantly, say yytable value of zero means syntax error not default action. (cherry picked from commit f2b30bdf3713e6fa9fafd0fc6caed68e38248ebc) Conflicts: data/bison.m4 data/lalr1.cc data/lalr1.java data/yacc.c src/parse-gram.c src/parse-gram.h --- ChangeLog | 45 +++++++++++++++++++++++++++++++++++++ data/c.m4 | 3 ++- data/glr.c | 25 +++++++++++---------- data/lalr1.cc | 35 +++++++++++++++++++++++------ data/lalr1.java | 29 +++++++++++++++++++----- data/yacc.c | 18 +++++++-------- src/parse-gram.c | 22 +++++++++--------- src/parse-gram.h | 2 +- src/tables.h | 58 ++++++++++++++++++++++++++---------------------- 9 files changed, 163 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index f872f3ff..008aca7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,48 @@ +2009-08-25 Joel E. Denny + + More fixes related to last two patches. + * data/c.m4 (b4_table_value_equals): Comment that YYID must be + defined. + * data/glr.c, data/lalr1.cc, data/lalr1.java, data/yacc.c: Fix + yytable comments: zero indicates syntax error not default + action. + * data/glr.c (yyis_pact_ninf): Rename to... + (yypact_value_is_default): ... this. + (yyisDefaultedState): Update for rename. + (yyis_table_ninf): Rename to... + (yytable_value_is_error): ... this, and check for value zero + besides just YYTABLE_NINF. + (yygetLRActions): Check for default value from yypact. It + appears that this check is always performed before this function + is invoked, and so adding the check here is probably redundant. + However, the code may evolve after this subtlety is forgotten. + Also, update for rename to yytable_value_is_error. Because that + macro now checks for zero, a different but equivalent branch of + the if-then-else here is evaluated. + (yyreportSyntaxError): Update for rename to + yytable_value_is_error. The zero condition was mishandled + before. + (yyrecoverSyntaxError): Update for renames. No behavioral + changes. + * data/lalr1.cc, data/lalr1.java (yy_pact_value_is_default_): + New function. + (yy_table_value_is_error_): New function. + (parse): Use new functions where possible. No behavioral + changes. + (yysyntax_error_, yysyntax_error): Use yy_table_value_is_error_. + The zero condition was mishandled before. + * data/yacc.c (yyis_pact_ninf): Rename to... + (yypact_value_is_default): ... this. + (yyis_table_ninf): Rename to... + (yytable_value_is_error): ... this, and check for value zero + besides just YYTABLE_NINF. + (yysyntax_error): Update for rename to yytable_value_is_error. + The zero condition was mishandled before. + (yyparse): Update for renames. No behavioral changes. + * src/tables.h: Improve comments about yypact, yytable, etc. + more. Most importantly, say yytable value of zero means syntax + error not default action. + 2009-08-25 Joel E. Denny Fix %error-verbose for conflicts resolved by %nonassoc. diff --git a/data/c.m4 b/data/c.m4 index 33b1d4b0..bfa534b5 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -138,7 +138,8 @@ m4_define([b4_int_type_for], # -------------------------------------------- # Without inducing a comparison warning from the compiler, check if the # literal value LITERAL equals VALUE from table TABLE, which must have -# TABLE_min and TABLE_max defined. +# TABLE_min and TABLE_max defined. YYID must be defined as an identity +# function that suppresses warnings about constant conditions. m4_define([b4_table_value_equals], [m4_if(m4_eval($3 < m4_indir([b4_]$1[_min]) || m4_indir([b4_]$1[_max]) < $3), [1], diff --git a/data/glr.c b/data/glr.c index 41cb607b..8d013906 100644 --- a/data/glr.c +++ b/data/glr.c @@ -442,8 +442,7 @@ static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero or YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF ]b4_table_ninf[ static const ]b4_int_type_for([b4_table])[ yytable[] = { @@ -1013,7 +1012,7 @@ yylhsNonterm (yyRuleNum yyrule) return yyr1[yyrule]; } -#define yyis_pact_ninf(yystate) \ +#define yypact_value_is_default(yystate) \ ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ /** True iff LR state STATE has only a default reduction (regardless @@ -1021,7 +1020,7 @@ yylhsNonterm (yyRuleNum yyrule) static inline yybool yyisDefaultedState (yyStateNum yystate) { - return yyis_pact_ninf (yypact[yystate]); + return yypact_value_is_default (yypact[yystate]); } /** The default reduction for STATE, assuming it has one. */ @@ -1031,8 +1030,9 @@ yydefaultAction (yyStateNum yystate) return yydefact[yystate]; } -#define yyis_table_ninf(yytable_value) \ - ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ +#define yytable_value_is_error(yytable_value) \ + (]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. * Result R means @@ -1047,12 +1047,13 @@ yygetLRActions (yyStateNum yystate, int yytoken, int* yyaction, const short int** yyconflicts) { int yyindex = yypact[yystate] + yytoken; - if (yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) + if (yypact_value_is_default (yypact[yystate]) + || yyindex < 0 || YYLAST < yyindex || yycheck[yyindex] != yytoken) { *yyaction = -yydefact[yystate]; *yyconflicts = yyconfl; } - else if (! yyis_table_ninf (yytable[yyindex])) + else if (! yytable_value_is_error (yytable[yyindex])) { *yyaction = yytable[yyindex]; *yyconflicts = yyconfl + yyconflp[yyindex]; @@ -2129,7 +2130,7 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[) for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yyis_table_ninf (yytable[yyx + yyn])) + && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { @@ -2230,7 +2231,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); } yyj = yypact[yystackp->yytops.yystates[0]->yylrState]; - if (yyis_pact_ninf (yyj)) + if (yypact_value_is_default (yyj)) return; yyj += yytoken; if (yyj < 0 || YYLAST < yyj || yycheck[yyj] != yytoken) @@ -2238,7 +2239,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) if (yydefact[yystackp->yytops.yystates[0]->yylrState] != 0) return; } - else if (yytable[yyj] != 0 && ! yyis_table_ninf (yytable[yyj])) + else if (! yytable_value_is_error (yytable[yyj])) return; } @@ -2259,7 +2260,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[) { yyGLRState *yys = yystackp->yytops.yystates[0]; yyj = yypact[yys->yylrState]; - if (! yyis_pact_ninf (yyj)) + if (! yypact_value_is_default (yyj)) { yyj += YYTERROR; if (0 <= yyj && yyj <= YYLAST && yycheck[yyj] == YYTERROR diff --git a/data/lalr1.cc b/data/lalr1.cc index 945ddcd0..f0e81002 100644 --- a/data/lalr1.cc +++ b/data/lalr1.cc @@ -190,6 +190,14 @@ b4_error_verbose_if([, int tok])[); /// The location stack. location_stack_type yylocation_stack_; + /// Whether the given \c yypact_ value indicates a defaulted state. + /// \param yyvalue the value to check + static bool yy_pact_value_is_default_ (int yyvalue); + + /// Whether the given \c yytable_ value indicates a syntax error. + /// \param yyvalue the value to check + static bool yy_table_value_is_error_ (int yyvalue); + /// Internal symbol numbers. typedef ]b4_int_type_for([b4_translate])[ token_number_type; /* Tables. */ @@ -518,6 +526,18 @@ do { \ } #endif + inline bool + ]b4_parser_class_name[::yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + inline bool + ]b4_parser_class_name[::yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == 0 || yyvalue == yytable_ninf_; + } + int ]b4_parser_class_name[::parse () { @@ -584,7 +604,7 @@ m4_popdef([b4_at_dollar])])dnl /* Try to take a decision without lookahead. */ yyn = yypact_[yystate]; - if (yyn == yypact_ninf_) + if (yy_pact_value_is_default_ (yyn)) goto yydefault; /* Read a lookahead token. */ @@ -620,8 +640,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param))[; yyn = yytable_[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == yytable_ninf_) - goto yyerrlab; + if (yy_table_value_is_error_ (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -762,7 +782,7 @@ b4_error_verbose_if([, yytoken])[)); for (;;) { yyn = yypact_[yystate]; - if (yyn != yypact_ninf_) + if (!yy_pact_value_is_default_ (yyn)) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) @@ -851,7 +871,7 @@ b4_error_verbose_if([, int tok])[) int count = 0; for (int x = yyxbegin; x < yyxend; ++x) if (yycheck_[x + yyn] == x && x != yyterror_ - && yytable_[x + yyn] != yytable_ninf_) + && !yy_table_value_is_error_ (yytable_[x + yyn])) ++count; // FIXME: This method of building the message is not compatible @@ -869,7 +889,7 @@ b4_error_verbose_if([, int tok])[) count = 0; for (int x = yyxbegin; x < yyxend; ++x) if (yycheck_[x + yyn] == x && x != yyterror_ - && yytable_[x + yyn] != yytable_ninf_) + && !yy_table_value_is_error_ (yytable_[x + yyn])) { res += (!count++) ? ", expecting " : " or "; res += yytnamerr_ (yytname_[x]); @@ -917,7 +937,8 @@ b4_error_verbose_if([, int tok])[) /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. */ + number is the opposite. If zero or YYTABLE_NINF_, syntax + error. */ const ]b4_int_type(b4_table_ninf, b4_table_ninf) b4_parser_class_name::yytable_ninf_ = b4_table_ninf[; const ]b4_int_type_for([b4_table])[ ]b4_parser_class_name[::yytable_[] = diff --git a/data/lalr1.java b/data/lalr1.java index 950a515c..5010ba6a 100644 --- a/data/lalr1.java +++ b/data/lalr1.java @@ -489,7 +489,7 @@ m4_popdef([b4_at_dollar])])dnl /* Take a decision. First try without lookahead. */ yyn = yypact_[yystate]; - if (yyn == yypact_ninf_) + if (yy_pact_value_is_default_ (yyn)) { label = YYDEFAULT; break; @@ -528,7 +528,7 @@ m4_popdef([b4_at_dollar])])dnl /* <= 0 means reduce or error. */ else if ((yyn = yytable_[yyn]) <= 0) { - if (yyn == 0 || yyn == yytable_ninf_) + if (yy_table_value_is_error_ (yyn)) label = YYFAIL; else { @@ -632,7 +632,7 @@ m4_popdef([b4_at_dollar])])dnl for (;;) { yyn = yypact_[yystate]; - if (yyn != yypact_ninf_) + if (!yy_pact_value_is_default_ (yyn)) { yyn += yyterror_; if (0 <= yyn && yyn <= yylast_ && yycheck_[yyn] == yyterror_) @@ -701,7 +701,7 @@ m4_popdef([b4_at_dollar])])dnl int count = 0; for (int x = yyxbegin; x < yyxend; ++x) if (yycheck_[x + yyn] == x && x != yyterror_ - && yycheck_[x + yyn] != yytable_ninf_) + && !yy_table_value_is_error_ (yycheck_[x + yyn])) ++count; // FIXME: This method of building the message is not compatible @@ -713,7 +713,7 @@ m4_popdef([b4_at_dollar])])dnl count = 0; for (int x = yyxbegin; x < yyxend; ++x) if (yycheck_[x + yyn] == x && x != yyterror_ - && yycheck_[x + yyn] != yytable_ninf_) + && !yy_table_value_is_error_ (yycheck_[x + yyn])) { res.append (count++ == 0 ? ", expecting " : " or "); res.append (yytnamerr_ (yytname_[x])); @@ -726,6 +726,23 @@ m4_popdef([b4_at_dollar])])dnl return "syntax error"; } + /** + * Whether the given yypact_ value indicates a defaulted state. + * @@param yyvalue the value to check + */ + private static boolean yy_pact_value_is_default_ (int yyvalue) + { + return yyvalue == yypact_ninf_; + } + + /** + * Whether the given yytable_ value indicates a syntax error. + * @@param yyvalue the value to check + */ + private static boolean yy_table_value_is_error_ (int yyvalue) + { + return yyvalue == 0 || yyvalue == yytable_ninf_; + } /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ @@ -758,7 +775,7 @@ m4_popdef([b4_at_dollar])])dnl /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. */ + number is the opposite. If zero or YYTABLE_NINF_, syntax error. */ private static final ]b4_int_type_for([b4_table])[ yytable_ninf_ = ]b4_table_ninf[; private static final ]b4_int_type_for([b4_table])[ yytable_[] = diff --git a/data/yacc.c b/data/yacc.c index c12dfdaa..9f997e84 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -578,19 +578,19 @@ static const ]b4_int_type_for([b4_pgoto])[ yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero or YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF ]b4_table_ninf[ static const ]b4_int_type_for([b4_table])[ yytable[] = { ]b4_table[ }; -#define yyis_pact_ninf(yystate) \ +#define yypact_value_is_default(yystate) \ ]b4_table_value_equals([[pact]], [[yystate]], [b4_pact_ninf])[ -#define yyis_table_ninf(yytable_value) \ - ]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ +#define yytable_value_is_error(yytable_value) \ + (]b4_table_value_equals([[table]], [[yytable_value]], [b4_table_ninf])[ \ + || ]b4_table_value_equals([[table]], [[yytable_value]], [[0]])[) static const ]b4_int_type_for([b4_check])[ yycheck[] = { @@ -954,7 +954,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar) for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yyis_table_ninf (yytable[yyx + yyn])) + && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { @@ -1355,7 +1355,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyis_pact_ninf (yyn)) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1405,7 +1405,7 @@ yyread_pushed_token:]])[ yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyis_table_ninf (yyn)) + if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; @@ -1589,7 +1589,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (!yyis_pact_ninf (yyn)) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) diff --git a/src/parse-gram.c b/src/parse-gram.c index 15db818c..92a8e4ab 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.4.1.120-890ab. */ +/* A Bison parser, made by GNU Bison 2.4.1.122-1fa3-dirty. */ /* Skeleton implementation for Bison's Yacc-like parsers in C @@ -45,7 +45,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.1.120-890ab" +#define YYBISON_VERSION "2.4.1.122-1fa3-dirty" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -823,8 +823,7 @@ static const yytype_int16 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If zero or YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -107 static const yytype_int16 yytable[] = { @@ -846,11 +845,12 @@ static const yytype_int16 yytable[] = 44, 39, 129, 40, 41, 95, 104, 114, 141, 42 }; -#define yyis_pact_ninf(yystate) \ +#define yypact_value_is_default(yystate) \ ((yystate) == (-60)) -#define yyis_table_ninf(yytable_value) \ - YYID (0) +#define yytable_value_is_error(yytable_value) \ + (YYID (0) \ + || ((yytable_value) == (0))) static const yytype_uint8 yycheck[] = { @@ -1476,7 +1476,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar) for (yyx = yyxbegin; yyx < yyxend; ++yyx) if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR - && !yyis_table_ninf (yytable[yyx + yyn])) + && !yytable_value_is_error (yytable[yyx + yyn])) { if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) { @@ -1810,7 +1810,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyis_pact_ninf (yyn)) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1841,7 +1841,7 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyis_table_ninf (yyn)) + if (yytable_value_is_error (yyn)) goto yyerrlab; yyn = -yyn; goto yyreduce; @@ -2782,7 +2782,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (!yyis_pact_ninf (yyn)) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) diff --git a/src/parse-gram.h b/src/parse-gram.h index c586262f..3b21e0ea 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 2.4.1.120-890ab. */ +/* A Bison parser, made by GNU Bison 2.4.1.122-1fa3-dirty. */ /* Skeleton interface for Bison's Yacc-like parsers in C diff --git a/src/tables.h b/src/tables.h index b21fa7b0..9b52f092 100644 --- a/src/tables.h +++ b/src/tables.h @@ -45,6 +45,24 @@ YYSTOS[S] = the symbol number of the symbol that leads to state S. + YYFINAL = the state number of the termination state. + + YYTABLE = a vector filled with portions for different uses, found + via YYPACT and YYPGOTO. + + YYLAST ( = high) the number of the last element of YYTABLE, i.e., + sizeof (YYTABLE) - 1. + + YYCHECK = a vector indexed in parallel with YYTABLE. It indicates, + in a roundabout way, the bounds of the portion you are trying to + examine. + + Suppose that the portion of YYTABLE starts at index P and the index + to be examined within the portion is I. Then if YYCHECK[P+I] != I, + I is outside the bounds of what is actually allocated, and the + default (from YYDEFACT or YYDEFGOTO) should be used. Otherwise, + YYTABLE[P+I] should be used. + 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. @@ -58,10 +76,10 @@ YYTABLE to find out what action to perform. If YYPACT[S] == YYPACT_NINF, if YYPACT[S] + I is outside the bounds - of YYTABLE (from 0 to YYLAST), or if YYCHECK indicates that I is - outside the bounds of the portion for S, then the default action - (from YYDEFACT and YYDEFGOTO) should be used instead of YYTABLE. - Otherwise, the value YYTABLE[YYPACT[S] + I] should be used even if + of YYTABLE (from 0 to YYLAST), or I is outside the bounds for portion + S (that is, YYCHECK[YYPACT[S] + I] != I), then the default action + (that is, YYDEFACT[S]) should be used instead of YYTABLE. Otherwise, + the value YYTABLE[YYPACT[S] + I] should be used even if YYPACT[S] < 0. If the value in YYTABLE is positive, we shift the token and go to @@ -69,33 +87,19 @@ If the value is negative, it is minus a rule number to reduce by. - If the value is zero, the default action from YYDEFACT[S] is used. - - If the value is YYTABLE_NINF, it's a syntax error. + If the value is zero or YYTABLE_NINF, it's a syntax error. YYPGOTO[I] = the index in YYTABLE of the portion describing what to do after reducing a rule that derives variable I + NTOKENS. This portion is indexed by the parser state number, S, as of before the - text for this nonterminal was read. The value from YYTABLE is the - state to go to if the corresponding value in YYCHECK is S. - - YYTABLE = a vector filled with portions for different uses, found - via YYPACT and YYPGOTO. - - YYCHECK = a vector indexed in parallel with YYTABLE. It indicates, - in a roundabout way, the bounds of the portion you are trying to - examine. - - Suppose that the portion of YYTABLE starts at index P and the index - to be examined within the portion is I. Then if YYCHECK[P+I] != I, - I is outside the bounds of what is actually allocated, and the - default (from YYDEFACT or YYDEFGOTO) should be used. Otherwise, - YYTABLE[P+I] should be used. - - YYFINAL = the state number of the termination state. - - YYLAST ( = high) the number of the last element of YYTABLE, i.e., - sizeof (YYTABLE) - 1. */ + text for this nonterminal was read. + + If YYPGOTO[I] + S is outside the bounds of YYTABLE (from 0 to YYLAST) + or if S is outside the bounds of the portion for I (that is, + YYCHECK[YYPGOTO[I] + S] != S), then the default state (that is, + YYDEFGOTO[I]) should be used instead of YYTABLE. Otherwise, + YYTABLE[YYPGOTO[I] + S] is the state to go to even if YYPGOTO[I] < 0. +*/ extern int nvectors; -- 2.45.2