yysyntax_error: prepare for readability of next patches.

These are purely whitespace changes that result in ugly code
but that make the next couple of patches much easier to read.
* data/glr.c (yyreportSyntaxError): Reindent.
* data/lalr1.cc (yy::parser::yysyntax_error_): Reindent.
* data/lalr1.java (YYParser::yysyntax_error): Reindent.
* data/yacc.c (yysyntax_error): Reindent.
(cherry picked from commit b4bbc4a03c)

Conflicts:

	src/parse-gram.c
	src/parse-gram.h
This commit is contained in:
Joel E. Denny
2010-11-07 09:44:07 -05:00
parent 0e0f066b76
commit f953cb20cf
7 changed files with 483 additions and 468 deletions

View File

@@ -1,3 +1,13 @@
2010-11-07 Joel E. Denny <jdenny@clemson.edu>
yysyntax_error: prepare for readability of next patches.
These are purely whitespace changes that result in ugly code
but that make the next couple of patches much easier to read.
* data/glr.c (yyreportSyntaxError): Reindent.
* data/lalr1.cc (yy::parser::yysyntax_error_): Reindent.
* data/lalr1.java (YYParser::yysyntax_error): Reindent.
* data/yacc.c (yysyntax_error): Reindent.
2010-10-31 Joel E. Denny <joeldenny@joeldenny.org> 2010-10-31 Joel E. Denny <joeldenny@joeldenny.org>
yysyntax_error: improve invocation readability. yysyntax_error: improve invocation readability.

View File

@@ -2094,104 +2094,104 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
int yyn; int yyn;
yyn = yypact[yystackp->yytops.yystates[0]->yylrState]; yyn = yypact[yystackp->yytops.yystates[0]->yylrState];
if (YYPACT_NINF < yyn && yyn <= YYLAST) if (YYPACT_NINF < yyn && yyn <= YYLAST)
{ {
yySymbol yytoken = YYTRANSLATE (yychar); yySymbol yytoken = YYTRANSLATE (yychar);
size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken)); size_t yysize0 = yytnamerr (NULL, yytokenName (yytoken));
size_t yysize = yysize0; size_t yysize = yysize0;
size_t yysize1; size_t yysize1;
yybool yysize_overflow = yyfalse; yybool yysize_overflow = yyfalse;
char* yymsg = NULL; char* yymsg = NULL;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */ /* Internationalized format string. */
const char *yyformat = 0; const char *yyformat = 0;
/* Arguments of yyformat. */ /* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Start YYX at -YYN if negative to avoid negative indexes in /* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for this YYCHECK. In other words, skip the first -YYN actions for this
state because they are default actions. */ state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0; int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1; int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
/* Number of reported tokens (one for the "unexpected", one per /* Number of reported tokens (one for the "unexpected", one per
"expected"). */ "expected"). */
int yycount = 0; int yycount = 0;
int yyx; int yyx;
yyarg[yycount++] = yytokenName (yytoken); yyarg[yycount++] = yytokenName (yytoken);
for (yyx = yyxbegin; yyx < yyxend; ++yyx) for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn])) && !yytable_value_is_error (yytable[yyx + yyn]))
{ {
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{ {
yycount = 1; yycount = 1;
yysize = yysize0; yysize = yysize0;
break; break;
} }
yyarg[yycount++] = yytokenName (yyx); yyarg[yycount++] = yytokenName (yyx);
yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx)); yysize1 = yysize + yytnamerr (NULL, yytokenName (yyx));
yysize_overflow |= yysize1 < yysize; yysize_overflow |= yysize1 < yysize;
yysize = yysize1; yysize = yysize1;
} }
switch (yycount) switch (yycount)
{ {
#define YYCASE_(N, S) \ #define YYCASE_(N, S) \
case N: \ case N: \
yyformat = S; \ yyformat = S; \
break break
YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_ #undef YYCASE_
}
yysize1 = yysize + strlen (yyformat);
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
if (!yysize_overflow)
yymsg = (char *) YYMALLOC (yysize);
if (yymsg)
{
char *yyp = yymsg;
int yyi = 0;
while ((*yyp = *yyformat))
{
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
yyerror (]b4_lyyerror_args[yymsg);
YYFREE (yymsg);
}
else
{
yyerror (]b4_lyyerror_args[YY_("syntax error"));
yyMemoryExhausted (yystackp);
}
}
else
#endif /* YYERROR_VERBOSE */
yyerror (]b4_lyyerror_args[YY_("syntax error"));
yynerrs += 1;
} }
yysize1 = yysize + strlen (yyformat);
yysize_overflow |= yysize1 < yysize;
yysize = yysize1;
if (!yysize_overflow)
yymsg = (char *) YYMALLOC (yysize);
if (yymsg)
{
char *yyp = yymsg;
int yyi = 0;
while ((*yyp = *yyformat))
{
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
yyerror (]b4_lyyerror_args[yymsg);
YYFREE (yymsg);
}
else
{
yyerror (]b4_lyyerror_args[YY_("syntax error"));
yyMemoryExhausted (yystackp);
}
}
else
#endif /* YYERROR_VERBOSE */
yyerror (]b4_lyyerror_args[YY_("syntax error"));
yynerrs += 1;
}
} }
/* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP, /* Recover from a syntax error on *YYSTACKP, assuming that *YYSTACKP->YYTOKENP,

View File

@@ -851,62 +851,62 @@ b4_error_verbose_if([int yystate, int yytoken],
int yyn = yypact_[yystate]; int yyn = yypact_[yystate];
if (yypact_ninf_ < yyn && yyn <= yylast_) if (yypact_ninf_ < yyn && yyn <= yylast_)
{ {
/* Start YYX at -YYN if negative to avoid negative indexes in /* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for this YYCHECK. In other words, skip the first -YYN actions for
state because they are default actions. */ this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0; int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1; int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
// Number of reported tokens (one for the "unexpected", one per // Number of reported tokens (one for the "unexpected", one per
// "expected"). // "expected").
size_t yycount = 0; size_t yycount = 0;
// Its maximum. // Its maximum.
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
// Arguments of yyformat. // Arguments of yyformat.
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
yyarg[yycount++] = yytname_[yytoken]; yyarg[yycount++] = yytname_[yytoken];
for (int yyx = yyxbegin; yyx < yyxend; ++yyx) for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_ if (yycheck_[yyx + yyn] == yyx && yyx != yyterror_
&& !yy_table_value_is_error_ (yytable_[yyx + yyn])) && !yy_table_value_is_error_ (yytable_[yyx + yyn]))
{ {
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{ {
yycount = 1; yycount = 1;
break; break;
} }
else else
yyarg[yycount++] = yytname_[yyx]; yyarg[yycount++] = yytname_[yyx];
} }
char const* yyformat = 0; char const* yyformat = 0;
switch (yycount) switch (yycount)
{ {
#define YYCASE_(N, S) \ #define YYCASE_(N, S) \
case N: \ case N: \
yyformat = S; \ yyformat = S; \
break break
YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_ #undef YYCASE_
}
// Argument number.
size_t yyi = 0;
for (char const* yyp = yyformat; *yyp; ++yyp)
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
{
yyres += yytnamerr_ (yyarg[yyi++]);
++yyp;
}
else
yyres += *yyp;
} }
else // Argument number.
size_t yyi = 0;
for (char const* yyp = yyformat; *yyp; ++yyp)
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
{
yyres += yytnamerr_ (yyarg[yyi++]);
++yyp;
}
else
yyres += *yyp;
}
else
]])dnl ]])dnl
[ yyres = YY_("syntax error"); [ yyres = YY_("syntax error");
return yyres; return yyres;

View File

@@ -688,35 +688,36 @@ m4_popdef([b4_at_dollar])])dnl
{ {
StringBuffer res; StringBuffer res;
/* Start YYX at -YYN if negative to avoid negative indexes in /* Start YYX at -YYN if negative to avoid negative
YYCHECK. In other words, skip the first -YYN actions for this indexes in YYCHECK. In other words, skip the first
state because they are default actions. */ -YYN actions for this state because they are default
int yyxbegin = yyn < 0 ? -yyn : 0; actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */ /* Stay within bounds of both yycheck and yytname. */
int yychecklim = yylast_ - yyn + 1; int yychecklim = yylast_ - yyn + 1;
int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_; int yyxend = yychecklim < yyntokens_ ? yychecklim : yyntokens_;
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_ (yytable_[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
// with internationalization. // with internationalization.
res = new StringBuffer ("syntax error, unexpected "); res = new StringBuffer ("syntax error, unexpected ");
res.append (yytnamerr_ (yytname_[tok])); res.append (yytnamerr_ (yytname_[tok]));
if (count < 5) if (count < 5)
{ {
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_ (yytable_[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]));
} }
} }
return res.toString (); return res.toString ();
} }
} }

View File

@@ -986,105 +986,104 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
return 1; return 1;
else else
{
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for
this state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
int yyx;
yyarg[yycount++] = yytname[yytoken];
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
{
/* Overflow. */
*yymsg_alloc = 0;
return 2;
}
yysize = yysize1;
}
switch (yycount)
{ {
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); #define YYCASE_(N, S) \
YYSIZE_T yysize = yysize0; case N: \
YYSIZE_T yysize1; yyformat = S; \
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; break
/* Internationalized format string. */ YYCASE_(1, YY_("syntax error, unexpected %s"));
const char *yyformat = 0; YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
/* Arguments of yyformat. */ YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
/* Start YYX at -YYN if negative to avoid negative indexes in
YYCHECK. In other words, skip the first -YYN actions for this
state because they are default actions. */
int yyxbegin = yyn < 0 ? -yyn : 0;
/* Stay within bounds of both yycheck and yytname. */
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
/* Number of reported tokens (one for the "unexpected", one per
"expected"). */
int yycount = 0;
int yyx;
yyarg[yycount++] = yytname[yytoken];
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
&& !yytable_value_is_error (yytable[yyx + yyn]))
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
{
/* Overflow. */
*yymsg_alloc = 0;
return 2;
}
yysize = yysize1;
}
switch (yycount)
{
#define YYCASE_(N, S) \
case N: \
yyformat = S; \
break
YYCASE_(1, YY_("syntax error, unexpected %s"));
YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
#undef YYCASE_ #undef YYCASE_
}
yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
{
/* Overflow. */
*yymsg_alloc = 0;
return 2;
}
yysize = yysize1;
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 2;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
} }
yysize1 = yysize + yystrlen (yyformat);
if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
{
/* Overflow. */
*yymsg_alloc = 0;
return 2;
}
yysize = yysize1;
if (*yymsg_alloc < yysize)
{
*yymsg_alloc = 2 * yysize;
if (! (yysize <= *yymsg_alloc
&& *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
*yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
return 2;
}
/* Avoid sprintf, as that infringes on the user's name space.
Don't have undefined behavior even if the translation
produced a string with the wrong number of "%s"s. */
{
char *yyp = *yymsg;
int yyi = 0;
while ((*yyp = *yyformat) != '\0')
if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyformat += 2;
}
else
{
yyp++;
yyformat++;
}
}
return 0;
}
} }
#endif /* YYERROR_VERBOSE */ #endif /* YYERROR_VERBOSE */

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.1.243-8699. */ /* A Bison parser, made by GNU Bison 2.4.1.247-0e0f-dirty. */
/* Skeleton interface for Bison's Yacc-like parsers in C /* Skeleton interface for Bison's Yacc-like parsers in C
@@ -161,7 +161,7 @@
typedef union YYSTYPE typedef union YYSTYPE
{ {
/* Line 1725 of yacc.c */ /* Line 1730 of yacc.c */
#line 94 "parse-gram.y" #line 94 "parse-gram.y"
symbol *symbol; symbol *symbol;
@@ -176,7 +176,7 @@ typedef union YYSTYPE
/* Line 1725 of yacc.c */ /* Line 1730 of yacc.c */
#line 181 "parse-gram.h" #line 181 "parse-gram.h"
} YYSTYPE; } YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_TRIVIAL 1