mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
* data/glr.c, yacc.c (YYDSYMPRINT): Remove, not used.
(YYDSYMPRINTF): Rename as... (YY_SYMBOL_PRINT): this. * data/lalr1.cc (YY_SYMBOL_PRINT): New, modeled after the previous two. Use it instead of direct symprint_ calls. (yybackup): Tweak the "Now at end of input" case to match yacc.c's one.
This commit is contained in:
11
ChangeLog
11
ChangeLog
@@ -1,3 +1,14 @@
|
|||||||
|
2004-09-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
|
* data/glr.c, yacc.c (YYDSYMPRINT): Remove, not used.
|
||||||
|
(YYDSYMPRINTF): Rename as...
|
||||||
|
(YY_SYMBOL_PRINT): this.
|
||||||
|
* data/lalr1.cc (YY_SYMBOL_PRINT): New, modeled after the previous
|
||||||
|
two.
|
||||||
|
Use it instead of direct symprint_ calls.
|
||||||
|
(yybackup): Tweak the "Now at end of input" case to match yacc.c's
|
||||||
|
one.
|
||||||
|
|
||||||
2004-09-02 Akim Demaille <akim@epita.fr>
|
2004-09-02 Akim Demaille <akim@epita.fr>
|
||||||
|
|
||||||
* data/lalr1.cc (b4_yysymprint_generate): New.
|
* data/lalr1.cc (b4_yysymprint_generate): New.
|
||||||
|
|||||||
34
data/glr.c
34
data/glr.c
@@ -479,19 +479,13 @@ do { \
|
|||||||
|
|
||||||
]b4_yysymprint_generate([b4_c_ansi_function_def])[
|
]b4_yysymprint_generate([b4_c_ansi_function_def])[
|
||||||
|
|
||||||
# define YYDSYMPRINT(Args) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
|
||||||
if (yydebug) \
|
|
||||||
yysymprint Args; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
# define YYDSYMPRINTF(Title, Token, Value, Location) \
|
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
{ \
|
{ \
|
||||||
YYFPRINTF (stderr, "%s ", Title); \
|
YYFPRINTF (stderr, "%s ", Title); \
|
||||||
yysymprint (stderr, \
|
yysymprint (stderr, \
|
||||||
Token, Value]b4_location_if([, Location])[); \
|
Type, Value]b4_location_if([, Location])[); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -502,10 +496,8 @@ int yydebug;
|
|||||||
|
|
||||||
#else /* !YYDEBUG */
|
#else /* !YYDEBUG */
|
||||||
|
|
||||||
/* Avoid empty `if' bodies. */
|
|
||||||
# define YYDPRINTF(Args)
|
# define YYDPRINTF(Args)
|
||||||
# define YYDSYMPRINT(Args)
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||||
# define YYDSYMPRINTF(Title, Token, Value, Location)
|
|
||||||
|
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
||||||
|
|
||||||
@@ -1568,7 +1560,7 @@ yyprocessOneStack (yyGLRStack* yystack, int yyk,
|
|||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((stderr, "Reading a token: "));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
*yytokenp = YYTRANSLATE (yychar);
|
*yytokenp = YYTRANSLATE (yychar);
|
||||||
YYDSYMPRINTF ("Next token is", *yytokenp, yylvalp, yyllocp);
|
YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
|
||||||
}
|
}
|
||||||
yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
|
yygetLRActions (yystate, *yytokenp, &yyaction, &yyconflicts);
|
||||||
|
|
||||||
@@ -1706,9 +1698,9 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
while (yystack->yytops.yystates[0] != NULL)
|
while (yystack->yytops.yystates[0] != NULL)
|
||||||
{
|
{
|
||||||
yyGLRState *yys = yystack->yytops.yystates[0];
|
yyGLRState *yys = yystack->yytops.yystates[0];
|
||||||
YYDSYMPRINTF ("Error: popping",
|
YY_SYMBOL_PRINT ("Error: popping",
|
||||||
yystos[yys->yylrState],
|
yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval, &yys->yyloc);
|
&yys->yysemantics.yysval, &yys->yyloc);
|
||||||
yydestruct (yystos[yys->yylrState],
|
yydestruct (yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||||
yystack->yytops.yystates[0] = yys->yypred;
|
yystack->yytops.yystates[0] = yys->yypred;
|
||||||
@@ -1719,13 +1711,13 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
}
|
}
|
||||||
if (*yytokenp != YYEMPTY)
|
if (*yytokenp != YYEMPTY)
|
||||||
{
|
{
|
||||||
YYDSYMPRINTF ("Error: discarding", *yytokenp, yylvalp, yyllocp);
|
YY_SYMBOL_PRINT ("Error: discarding", *yytokenp, yylvalp, yyllocp);
|
||||||
yydestruct (*yytokenp, yylvalp]b4_location_if([, yyllocp])[);
|
yydestruct (*yytokenp, yylvalp]b4_location_if([, yyllocp])[);
|
||||||
}
|
}
|
||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((stderr, "Reading a token: "));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
*yytokenp = YYTRANSLATE (yychar);
|
*yytokenp = YYTRANSLATE (yychar);
|
||||||
YYDSYMPRINTF ("Next token is", *yytokenp, yylvalp, yyllocp);
|
YY_SYMBOL_PRINT ("Next token is", *yytokenp, yylvalp, yyllocp);
|
||||||
yyj = yypact[yystack->yytops.yystates[0]->yylrState];
|
yyj = yypact[yystack->yytops.yystates[0]->yylrState];
|
||||||
if (yyis_pact_ninf (yyj))
|
if (yyis_pact_ninf (yyj))
|
||||||
return;
|
return;
|
||||||
@@ -1768,9 +1760,9 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
YYDSYMPRINTF ("Error: popping",
|
YY_SYMBOL_PRINT ("Error: popping",
|
||||||
yystos[yys->yylrState],
|
yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval, &yys->yyloc);
|
&yys->yysemantics.yysval, &yys->yyloc);
|
||||||
yydestruct (yystos[yys->yylrState],
|
yydestruct (yystos[yys->yylrState],
|
||||||
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
&yys->yysemantics.yysval]b4_location_if([, &yys->yyloc])[);
|
||||||
yystack->yytops.yystates[0] = yys->yypred;
|
yystack->yytops.yystates[0] = yys->yypred;
|
||||||
@@ -1863,7 +1855,7 @@ yyrecoverSyntaxError (yyGLRStack* yystack,
|
|||||||
YYDPRINTF ((stderr, "Reading a token: "));
|
YYDPRINTF ((stderr, "Reading a token: "));
|
||||||
yychar = YYLEX;
|
yychar = YYLEX;
|
||||||
yytoken = YYTRANSLATE (yychar);
|
yytoken = YYTRANSLATE (yychar);
|
||||||
YYDSYMPRINTF ("Next token is", yytoken, yylvalp, yyllocp);
|
YY_SYMBOL_PRINT ("Next token is", yytoken, yylvalp, yyllocp);
|
||||||
}
|
}
|
||||||
yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
|
yygetLRActions (yystate, yytoken, &yyaction, &yyconflicts);
|
||||||
if (*yyconflicts != 0)
|
if (*yyconflicts != 0)
|
||||||
|
|||||||
@@ -316,8 +316,8 @@ namespace yy
|
|||||||
|
|
||||||
/* Even more tables. */
|
/* Even more tables. */
|
||||||
static inline TokenNumberType translate_ (int token);
|
static inline TokenNumberType translate_ (int token);
|
||||||
static inline void destruct_ (int yytype, SemanticType *yyvaluep,
|
inline void destruct_ (int yytype, SemanticType *yyvaluep,
|
||||||
LocationType *yylocationp);
|
LocationType *yylocationp);
|
||||||
|
|
||||||
/* Constants. */
|
/* Constants. */
|
||||||
static const int eof_;
|
static const int eof_;
|
||||||
@@ -378,21 +378,40 @@ m4_if(b4_defines_flag, 0, [], [#include @output_header_name@])[
|
|||||||
|
|
||||||
/* Enable debugging if requested. */
|
/* Enable debugging if requested. */
|
||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
# define YYCDEBUG if (debug_) cdebug_
|
|
||||||
|
# define YYCDEBUG \
|
||||||
|
if (debug_) \
|
||||||
|
cdebug_
|
||||||
|
|
||||||
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
|
do { \
|
||||||
|
if (debug_) \
|
||||||
|
{ \
|
||||||
|
cdebug_ << (Title) << ' '; \
|
||||||
|
symprint_ ((Type), (Value), (Location)); \
|
||||||
|
cdebug_ << std::endl; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
# define YY_REDUCE_PRINT(Rule) \
|
# define YY_REDUCE_PRINT(Rule) \
|
||||||
do { \
|
do { \
|
||||||
if (debug_) \
|
if (debug_) \
|
||||||
reduce_print_ (Rule); \
|
reduce_print_ (Rule); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define YY_STACK_PRINT() \
|
# define YY_STACK_PRINT() \
|
||||||
do { \
|
do { \
|
||||||
if (debug_) \
|
if (debug_) \
|
||||||
stack_print_ (); \
|
stack_print_ (); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else /* !YYDEBUG */
|
#else /* !YYDEBUG */
|
||||||
|
|
||||||
# define YYCDEBUG if (0) cdebug_
|
# define YYCDEBUG if (0) cdebug_
|
||||||
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||||
# define YY_REDUCE_PRINT(Rule)
|
# define YY_REDUCE_PRINT(Rule)
|
||||||
# define YY_STACK_PRINT()
|
# define YY_STACK_PRINT()
|
||||||
|
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
||||||
|
|
||||||
#define YYACCEPT goto yyacceptlab
|
#define YYACCEPT goto yyacceptlab
|
||||||
@@ -448,23 +467,15 @@ yy::]b4_parser_class_name[::parse ()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert token to internal form. */
|
/* Convert token to internal form. */
|
||||||
if (looka_ <= 0)
|
if (looka_ <= eof_)
|
||||||
{
|
{
|
||||||
looka_ = eof_;
|
looka_ = ilooka_ = eof_;
|
||||||
ilooka_ = 0;
|
|
||||||
YYCDEBUG << "Now at end of input." << std::endl;
|
YYCDEBUG << "Now at end of input." << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ilooka_ = translate_ (looka_);
|
ilooka_ = translate_ (looka_);
|
||||||
#if YYDEBUG
|
YY_SYMBOL_PRINT ("Next token is", ilooka_, &value, &location);
|
||||||
if (debug_)
|
|
||||||
{
|
|
||||||
cdebug_ << "Next token is ";
|
|
||||||
symprint_ (ilooka_, &value, &location);
|
|
||||||
cdebug_ << std::endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the proper action on seeing token ILOOKA_ is to reduce or to
|
/* If the proper action on seeing token ILOOKA_ is to reduce or to
|
||||||
@@ -579,7 +590,7 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
/*------------------------------------.
|
/*------------------------------------.
|
||||||
| yyerrlab -- here on detecting error |
|
| yyerrlab -- here on detecting error |
|
||||||
`------------------------------------*/
|
`------------------------------------*/
|
||||||
yyerrlab:
|
yyerrlab:
|
||||||
/* If not already recovering from an error, report this error. */
|
/* If not already recovering from an error, report this error. */
|
||||||
report_syntax_error_ ();
|
report_syntax_error_ ();
|
||||||
|
|
||||||
@@ -603,31 +614,18 @@ b4_syncline([@oline@], [@ofile@])[
|
|||||||
location_stack_.pop ();
|
location_stack_.pop ();
|
||||||
if (state_stack_.height () == 1)
|
if (state_stack_.height () == 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
#if YYDEBUG
|
YY_SYMBOL_PRINT ("Error: popping",
|
||||||
if (debug_)
|
stos_[state_stack_[0]],
|
||||||
{
|
&semantic_stack_[0],
|
||||||
cdebug_ << "Error: popping ";
|
&location_stack_[0]);
|
||||||
symprint_ (stos_[state_stack_[0]],
|
destruct_ (stos_[state_stack_[0]],
|
||||||
&semantic_stack_[0],
|
|
||||||
&location_stack_[0]);
|
|
||||||
cdebug_ << std::endl;
|
|
||||||
}
|
|
||||||
#endif // YYDEBUG
|
|
||||||
destruct_ (stos_[state_stack_[0]],
|
|
||||||
&semantic_stack_[0],
|
&semantic_stack_[0],
|
||||||
&location_stack_[0]);
|
&location_stack_[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if YYDEBUG
|
YY_SYMBOL_PRINT ("Error: discarding", ilooka_, &value, &location);
|
||||||
if (debug_)
|
|
||||||
{
|
|
||||||
cdebug_ << "Error: discarding ";
|
|
||||||
symprint_ (ilooka_, &value, &location);
|
|
||||||
cdebug_ << std::endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
destruct_ (ilooka_, &value, &location);
|
destruct_ (ilooka_, &value, &location);
|
||||||
looka_ = empty_;
|
looka_ = empty_;
|
||||||
}
|
}
|
||||||
@@ -681,14 +679,9 @@ yyerrlab1:
|
|||||||
if (state_stack_.height () == 1)
|
if (state_stack_.height () == 1)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
#if YYDEBUG
|
YY_SYMBOL_PRINT ("Error: popping",
|
||||||
if (debug_)
|
stos_[state_],
|
||||||
{
|
&semantic_stack_[0], &location_stack_[0]);
|
||||||
cdebug_ << "Error: popping ";
|
|
||||||
symprint_ (stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
|
||||||
cdebug_ << std::endl;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
destruct_ (stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
destruct_ (stos_[state_], &semantic_stack_[0], &location_stack_[0]);
|
||||||
error_start_ = location_stack_[0].begin;
|
error_start_ = location_stack_[0].begin;
|
||||||
|
|
||||||
@@ -716,11 +709,11 @@ yyerrlab1:
|
|||||||
goto yynewstate;
|
goto yynewstate;
|
||||||
|
|
||||||
/* Accept. */
|
/* Accept. */
|
||||||
yyacceptlab:
|
yyacceptlab:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Abort. */
|
/* Abort. */
|
||||||
yyabortlab:
|
yyabortlab:
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
22
data/yacc.c
22
data/yacc.c
@@ -537,19 +537,13 @@ do { \
|
|||||||
YYFPRINTF Args; \
|
YYFPRINTF Args; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
# define YYDSYMPRINT(Args) \
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||||
do { \
|
|
||||||
if (yydebug) \
|
|
||||||
yysymprint Args; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
# define YYDSYMPRINTF(Title, Token, Value, Location) \
|
|
||||||
do { \
|
do { \
|
||||||
if (yydebug) \
|
if (yydebug) \
|
||||||
{ \
|
{ \
|
||||||
YYFPRINTF (stderr, "%s ", Title); \
|
YYFPRINTF (stderr, "%s ", Title); \
|
||||||
yysymprint (stderr, \
|
yysymprint (stderr, \
|
||||||
Token, Value]b4_location_if([, Location])[); \
|
Type, Value]b4_location_if([, Location])[); \
|
||||||
YYFPRINTF (stderr, "\n"); \
|
YYFPRINTF (stderr, "\n"); \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
@@ -604,8 +598,7 @@ do { \
|
|||||||
int yydebug;
|
int yydebug;
|
||||||
#else /* !YYDEBUG */
|
#else /* !YYDEBUG */
|
||||||
# define YYDPRINTF(Args)
|
# define YYDPRINTF(Args)
|
||||||
# define YYDSYMPRINT(Args)
|
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
|
||||||
# define YYDSYMPRINTF(Title, Token, Value, Location)
|
|
||||||
# define YY_STACK_PRINT(Bottom, Top)
|
# define YY_STACK_PRINT(Bottom, Top)
|
||||||
# define YY_REDUCE_PRINT(Rule)
|
# define YY_REDUCE_PRINT(Rule)
|
||||||
#endif /* !YYDEBUG */
|
#endif /* !YYDEBUG */
|
||||||
@@ -932,7 +925,7 @@ yybackup:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
yytoken = YYTRANSLATE (yychar);
|
yytoken = YYTRANSLATE (yychar);
|
||||||
YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
/* If the proper action on seeing token YYTOKEN is to reduce or to
|
||||||
@@ -1121,13 +1114,14 @@ yyerrlab:
|
|||||||
YYPOPSTACK;
|
YYPOPSTACK;
|
||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
YY_SYMBOL_PRINT ("Error: popping",
|
||||||
|
yystos[*yyssp], yyvsp, yylsp);
|
||||||
yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
yydestruct (yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
|
YY_SYMBOL_PRINT ("Error: discarding", yytoken, &yylval, &yylloc);
|
||||||
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
|
yydestruct (yytoken, &yylval]b4_location_if([, &yylloc])[);
|
||||||
yychar = YYEMPTY;
|
yychar = YYEMPTY;
|
||||||
]b4_location_if([ *++yylerrsp = yylloc;])[
|
]b4_location_if([ *++yylerrsp = yylloc;])[
|
||||||
@@ -1184,7 +1178,7 @@ yyerrlab1:
|
|||||||
if (yyssp == yyss)
|
if (yyssp == yyss)
|
||||||
YYABORT;
|
YYABORT;
|
||||||
|
|
||||||
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
YY_SYMBOL_PRINT ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
|
||||||
yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
yydestruct (yystos[yystate], yyvsp]b4_location_if([, yylsp])[);
|
||||||
YYPOPSTACK;
|
YYPOPSTACK;
|
||||||
yystate = *yyssp;
|
yystate = *yyssp;
|
||||||
|
|||||||
Reference in New Issue
Block a user