summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkim Demaille <akim.demaille@gmail.com>2018-11-20 20:41:23 +0100
committerAkim Demaille <akim.demaille@gmail.com>2018-11-20 20:52:58 +0100
commit6bc54a934eba1f2b187c4dd0407d21e52b2a903d (patch)
tree2b84cd1eb64d177d3d05859d695ad935d57b7def
parentebb92c0545a20a46b8b7a9be5652ef64bd1c3425 (diff)
downloadbison-6bc54a934eba1f2b187c4dd0407d21e52b2a903d.tar.gz
style: harmonize the labels of yyparse
* data/glr.c, data/lalr1.cc, data/yacc.c: Fix indentation and other formatting issues.
-rw-r--r--data/glr.c8
-rw-r--r--data/lalr1.cc32
-rw-r--r--data/yacc.c60
3 files changed, 66 insertions, 34 deletions
diff --git a/data/glr.c b/data/glr.c
index 8f71c527..437677d8 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -1256,10 +1256,10 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
# define YY_REDUCE_PRINT(Args)
#else
# define YY_REDUCE_PRINT(Args) \
-do { \
- if (yydebug) \
- yy_reduce_print Args; \
-} while (0)
+ do { \
+ if (yydebug) \
+ yy_reduce_print Args; \
+ } while (0)
/*----------------------------------------------------------------------.
| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |
diff --git a/data/lalr1.cc b/data/lalr1.cc
index a23bf60c..8486f9e8 100644
--- a/data/lalr1.cc
+++ b/data/lalr1.cc
@@ -793,17 +793,22 @@ b4_dollar_popdef])[]dnl
yystack_.clear ();
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
- // A new symbol was pushed on the stack.
+ /*-----------------------------------------------.
+ | yynewstate -- push a new symbol on the stack. |
+ `-----------------------------------------------*/
yynewstate:
YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
// Accept?
if (yystack_[0].state == yyfinal_)
- goto yyacceptlab;
+ YYACCEPT;
goto yybackup;
- // Backup.
+
+ /*-----------.
+ | yybackup. |
+ `-----------*/
yybackup:
// Try to take a decision without lookahead.
yyn = yypact_[yystack_[0].state];
@@ -856,6 +861,7 @@ b4_dollar_popdef])[]dnl
yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate;
+
/*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/
@@ -865,8 +871,9 @@ b4_dollar_popdef])[]dnl
goto yyerrlab;
goto yyreduce;
+
/*-----------------------------.
- | yyreduce -- Do a reduction. |
+ | yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
yylen = yyr2_[yyn];
@@ -926,6 +933,7 @@ b4_dollar_popdef])[]dnl
}
goto yynewstate;
+
/*--------------------------------------.
| yyerrlab -- here on detecting error. |
`--------------------------------------*/
@@ -963,7 +971,6 @@ b4_dollar_popdef])[]dnl
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
@@ -975,6 +982,7 @@ b4_dollar_popdef])[]dnl
yylen = 0;
goto yyerrlab1;
+
/*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/
@@ -1015,16 +1023,26 @@ b4_dollar_popdef])[]dnl
}
goto yynewstate;
- // Accept.
+
+ /*-------------------------------------.
+ | yyacceptlab -- YYACCEPT comes here. |
+ `-------------------------------------*/
yyacceptlab:
yyresult = 0;
goto yyreturn;
- // Abort.
+
+ /*-----------------------------------.
+ | yyabortlab -- YYABORT comes here. |
+ `-----------------------------------*/
yyabortlab:
yyresult = 1;
goto yyreturn;
+
+ /*-----------------------------------------------------.
+ | yyreturn -- parsing is finished, return the result. |
+ `-----------------------------------------------------*/
yyreturn:
if (!yyla.empty ())
yy_destroy_ ("Cleanup: discarding lookahead", yyla);
diff --git a/data/yacc.c b/data/yacc.c
index 0ba48bef..dc8d38e7 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -624,23 +624,23 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- YYPOPSTACK (yylen); \
- yystate = *yyssp; \]b4_lac_if([[
- YY_LAC_DISCARD ("YYBACKUP"); \]])[
- goto yybackup; \
- } \
- else \
- { \
- yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
- YYERROR; \
- } \
-while (0)
+#define YYBACKUP(Token, Value) \
+ do \
+ if (yychar == YYEMPTY) \
+ { \
+ yychar = (Token); \
+ yylval = (Value); \
+ YYPOPSTACK (yylen); \
+ yystate = *yyssp; \]b4_lac_if([[
+ YY_LAC_DISCARD ("YYBACKUP"); \]])[
+ goto yybackup; \
+ } \
+ else \
+ { \
+ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
+ YYERROR; \
+ } \
+ while (0)
/* Error token number */
#define YYTERROR 1
@@ -1436,15 +1436,20 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
]])dnl
[ goto yysetstate;
+
/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
+| yynewstate -- push a new state, which is found in yystate. |
`------------------------------------------------------------*/
- yynewstate:
+yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */
yyssp++;
- yysetstate:
+
+/*--------------------------------------------------------------------.
+| yynewstate -- set current state (the top of the stack) to yystate. |
+`--------------------------------------------------------------------*/
+yysetstate:
*yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp)
@@ -1519,11 +1524,11 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
goto yybackup;
+
/*-----------.
| yybackup. |
`-----------*/
yybackup:
-
/* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */
@@ -1621,7 +1626,7 @@ yydefault:
/*-----------------------------.
-| yyreduce -- Do a reduction. |
+| yyreduce -- do a reduction. |
`-----------------------------*/
yyreduce:
/* yyn is the number of a rule to reduce with. */
@@ -1772,7 +1777,6 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/
yyerrorlab:
-
/* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user
code. */
@@ -1848,6 +1852,7 @@ yyacceptlab:
yyresult = 0;
goto yyreturn;
+
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
@@ -1855,6 +1860,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
+
#if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
@@ -1865,6 +1871,10 @@ yyexhaustedlab:
/* Fall through. */
#endif
+
+/*-----------------------------------------------------.
+| yyreturn -- parsing is finished, return the result. |
+`-----------------------------------------------------*/
yyreturn:
if (yychar != YYEMPTY)
{
@@ -1892,6 +1902,10 @@ yyreturn:
YYSTACK_FREE (yyes);]])b4_push_if([[
yyps->yynew = 1;
+
+/*-----------------------------------------.
+| yypushreturn -- ask for the next token. |
+`-----------------------------------------*/
yypushreturn:]])[
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)