style: harmonize the labels of yyparse

* data/glr.c, data/lalr1.cc, data/yacc.c: Fix indentation and
other formatting issues.
This commit is contained in:
Akim Demaille
2018-11-20 20:41:23 +01:00
parent ebb92c0545
commit 6bc54a934e
3 changed files with 66 additions and 34 deletions

View File

@@ -1256,10 +1256,10 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
# define YY_REDUCE_PRINT(Args) # define YY_REDUCE_PRINT(Args)
#else #else
# define YY_REDUCE_PRINT(Args) \ # define YY_REDUCE_PRINT(Args) \
do { \ do { \
if (yydebug) \ if (yydebug) \
yy_reduce_print Args; \ yy_reduce_print Args; \
} while (0) } while (0)
/*----------------------------------------------------------------------. /*----------------------------------------------------------------------.
| Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. | | Report that stack #YYK of *YYSTACKP is going to be reduced by YYRULE. |

View File

@@ -793,17 +793,22 @@ b4_dollar_popdef])[]dnl
yystack_.clear (); yystack_.clear ();
yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla)); yypush_ (YY_NULLPTR, 0, YY_MOVE (yyla));
// A new symbol was pushed on the stack. /*-----------------------------------------------.
| yynewstate -- push a new symbol on the stack. |
`-----------------------------------------------*/
yynewstate: yynewstate:
YYCDEBUG << "Entering state " << yystack_[0].state << '\n'; YYCDEBUG << "Entering state " << yystack_[0].state << '\n';
// Accept? // Accept?
if (yystack_[0].state == yyfinal_) if (yystack_[0].state == yyfinal_)
goto yyacceptlab; YYACCEPT;
goto yybackup; goto yybackup;
// Backup.
/*-----------.
| yybackup. |
`-----------*/
yybackup: yybackup:
// Try to take a decision without lookahead. // Try to take a decision without lookahead.
yyn = yypact_[yystack_[0].state]; yyn = yypact_[yystack_[0].state];
@@ -856,6 +861,7 @@ b4_dollar_popdef])[]dnl
yypush_ ("Shifting", yyn, YY_MOVE (yyla)); yypush_ ("Shifting", yyn, YY_MOVE (yyla));
goto yynewstate; goto yynewstate;
/*-----------------------------------------------------------. /*-----------------------------------------------------------.
| yydefault -- do the default action for the current state. | | yydefault -- do the default action for the current state. |
`-----------------------------------------------------------*/ `-----------------------------------------------------------*/
@@ -865,8 +871,9 @@ b4_dollar_popdef])[]dnl
goto yyerrlab; goto yyerrlab;
goto yyreduce; goto yyreduce;
/*-----------------------------. /*-----------------------------.
| yyreduce -- Do a reduction. | | yyreduce -- do a reduction. |
`-----------------------------*/ `-----------------------------*/
yyreduce: yyreduce:
yylen = yyr2_[yyn]; yylen = yyr2_[yyn];
@@ -926,6 +933,7 @@ b4_dollar_popdef])[]dnl
} }
goto yynewstate; goto yynewstate;
/*--------------------------------------. /*--------------------------------------.
| yyerrlab -- here on detecting error. | | yyerrlab -- here on detecting error. |
`--------------------------------------*/ `--------------------------------------*/
@@ -963,7 +971,6 @@ b4_dollar_popdef])[]dnl
| yyerrorlab -- error raised explicitly by YYERROR. | | yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/ `---------------------------------------------------*/
yyerrorlab: yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes /* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user YYERROR and the label yyerrorlab therefore never appears in user
code. */ code. */
@@ -975,6 +982,7 @@ b4_dollar_popdef])[]dnl
yylen = 0; yylen = 0;
goto yyerrlab1; goto yyerrlab1;
/*-------------------------------------------------------------. /*-------------------------------------------------------------.
| yyerrlab1 -- common code for both syntax error and YYERROR. | | yyerrlab1 -- common code for both syntax error and YYERROR. |
`-------------------------------------------------------------*/ `-------------------------------------------------------------*/
@@ -1015,16 +1023,26 @@ b4_dollar_popdef])[]dnl
} }
goto yynewstate; goto yynewstate;
// Accept.
/*-------------------------------------.
| yyacceptlab -- YYACCEPT comes here. |
`-------------------------------------*/
yyacceptlab: yyacceptlab:
yyresult = 0; yyresult = 0;
goto yyreturn; goto yyreturn;
// Abort.
/*-----------------------------------.
| yyabortlab -- YYABORT comes here. |
`-----------------------------------*/
yyabortlab: yyabortlab:
yyresult = 1; yyresult = 1;
goto yyreturn; goto yyreturn;
/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result. |
`-----------------------------------------------------*/
yyreturn: yyreturn:
if (!yyla.empty ()) if (!yyla.empty ())
yy_destroy_ ("Cleanup: discarding lookahead", yyla); yy_destroy_ ("Cleanup: discarding lookahead", yyla);

View File

@@ -624,23 +624,23 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
#define YYRECOVERING() (!!yyerrstatus) #define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \ #define YYBACKUP(Token, Value) \
do \ do \
if (yychar == YYEMPTY) \ if (yychar == YYEMPTY) \
{ \ { \
yychar = (Token); \ yychar = (Token); \
yylval = (Value); \ yylval = (Value); \
YYPOPSTACK (yylen); \ YYPOPSTACK (yylen); \
yystate = *yyssp; \]b4_lac_if([[ yystate = *yyssp; \]b4_lac_if([[
YY_LAC_DISCARD ("YYBACKUP"); \]])[ YY_LAC_DISCARD ("YYBACKUP"); \]])[
goto yybackup; \ goto yybackup; \
} \ } \
else \ else \
{ \ { \
yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \ yyerror (]b4_yyerror_args[YY_("syntax error: cannot back up")); \
YYERROR; \ YYERROR; \
} \ } \
while (0) while (0)
/* Error token number */ /* Error token number */
#define YYTERROR 1 #define YYTERROR 1
@@ -1436,15 +1436,20 @@ b4_locations_if([[ yylsp[0] = ]b4_push_if([b4_pure_if([*])yypushed_loc], [yyllo
]])dnl ]])dnl
[ goto yysetstate; [ 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 /* In all cases, when you get here, the value and location stacks
have just been pushed. So pushing a state here evens the stacks. */ have just been pushed. So pushing a state here evens the stacks. */
yyssp++; yyssp++;
yysetstate:
/*--------------------------------------------------------------------.
| yynewstate -- set current state (the top of the stack) to yystate. |
`--------------------------------------------------------------------*/
yysetstate:
*yyssp = (yytype_int16) yystate; *yyssp = (yytype_int16) yystate;
if (yyss + yystacksize - 1 <= yyssp) 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; goto yybackup;
/*-----------. /*-----------.
| yybackup. | | yybackup. |
`-----------*/ `-----------*/
yybackup: yybackup:
/* Do appropriate processing given the current state. Read a /* Do appropriate processing given the current state. Read a
lookahead token if we need one and don't already have one. */ 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: yyreduce:
/* yyn is the number of a rule to reduce with. */ /* yyn is the number of a rule to reduce with. */
@@ -1772,7 +1777,6 @@ yyerrlab:
| yyerrorlab -- error raised explicitly by YYERROR. | | yyerrorlab -- error raised explicitly by YYERROR. |
`---------------------------------------------------*/ `---------------------------------------------------*/
yyerrorlab: yyerrorlab:
/* Pacify compilers like GCC when the user code never invokes /* Pacify compilers like GCC when the user code never invokes
YYERROR and the label yyerrorlab therefore never appears in user YYERROR and the label yyerrorlab therefore never appears in user
code. */ code. */
@@ -1848,6 +1852,7 @@ yyacceptlab:
yyresult = 0; yyresult = 0;
goto yyreturn; goto yyreturn;
/*-----------------------------------. /*-----------------------------------.
| yyabortlab -- YYABORT comes here. | | yyabortlab -- YYABORT comes here. |
`-----------------------------------*/ `-----------------------------------*/
@@ -1855,6 +1860,7 @@ yyabortlab:
yyresult = 1; yyresult = 1;
goto yyreturn; goto yyreturn;
#if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[ #if ]b4_lac_if([[1]], [[!defined yyoverflow || YYERROR_VERBOSE]])[
/*-------------------------------------------------. /*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. | | yyexhaustedlab -- memory exhaustion comes here. |
@@ -1865,6 +1871,10 @@ yyexhaustedlab:
/* Fall through. */ /* Fall through. */
#endif #endif
/*-----------------------------------------------------.
| yyreturn -- parsing is finished, return the result. |
`-----------------------------------------------------*/
yyreturn: yyreturn:
if (yychar != YYEMPTY) if (yychar != YYEMPTY)
{ {
@@ -1892,6 +1902,10 @@ yyreturn:
YYSTACK_FREE (yyes);]])b4_push_if([[ YYSTACK_FREE (yyes);]])b4_push_if([[
yyps->yynew = 1; yyps->yynew = 1;
/*-----------------------------------------.
| yypushreturn -- ask for the next token. |
`-----------------------------------------*/
yypushreturn:]])[ yypushreturn:]])[
#if YYERROR_VERBOSE #if YYERROR_VERBOSE
if (yymsg != yymsgbuf) if (yymsg != yymsgbuf)