[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
style: comments changes about error handling
From: |
Akim Demaille |
Subject: |
style: comments changes about error handling |
Date: |
Thu, 16 Apr 2020 08:37:16 +0200 |
commit c4c25e091cf5a3fded4c58d0e4918b6e750be305
Author: Akim Demaille <address@hidden>
Date: Wed Apr 15 08:44:08 2020 +0200
style: comments changes about error handling
* data/skeletons/glr.c, data/skeletons/lalr1.cc, data/skeletons/lalr1.d,
* data/skeletons/lalr1.java, data/skeletons/yacc.c: here.
* data/skeletons/lalr1.cc: Reduce scope.
diff --git a/data/skeletons/glr.c b/data/skeletons/glr.c
index 630b4cc7..0f2336ef 100644
--- a/data/skeletons/glr.c
+++ b/data/skeletons/glr.c
@@ -2353,7 +2353,7 @@ yyrecoverSyntaxError (yyGLRStack*
yystackp]b4_user_formals[)
yycompressStack (yystackp);
}
- /* Now pop stack until we find a state that shifts the error token. */
+ /* Pop stack until we find a state that shifts the error token. */
yystackp->yyerrState = 3;
while (yystackp->yytops.yystates[0] != YY_NULLPTR)
{
diff --git a/data/skeletons/lalr1.cc b/data/skeletons/lalr1.cc
index dd9d97e4..587c280f 100644
--- a/data/skeletons/lalr1.cc
+++ b/data/skeletons/lalr1.cc
@@ -1124,32 +1124,33 @@ b4_dollar_popdef])[]dnl
`-------------------------------------------------------------*/
yyerrlab1:
yyerrstatus_ = 3; // Each real token shifted decrements this.
- {
- stack_symbol_type error_token;
- for (;;)
- {
- yyn = yypact_[+yystack_[0].state];
- if (!yy_pact_value_is_default_ (yyn))
- {
- yyn += symbol_kind::]b4_symbol_prefix[YYERROR;
- if (0 <= yyn && yyn <= yylast_
- && yycheck_[yyn] == symbol_kind::]b4_symbol_prefix[YYERROR)
- {
- yyn = yytable_[yyn];
- if (0 < yyn)
- break;
- }
- }
+ // Pop stack until we find a state that shifts the error token.
+ for (;;)
+ {
+ yyn = yypact_[+yystack_[0].state];
+ if (!yy_pact_value_is_default_ (yyn))
+ {
+ yyn += symbol_kind::]b4_symbol_prefix[YYERROR;
+ if (0 <= yyn && yyn <= yylast_
+ && yycheck_[yyn] == symbol_kind::]b4_symbol_prefix[YYERROR)
+ {
+ yyn = yytable_[yyn];
+ if (0 < yyn)
+ break;
+ }
+ }
- // Pop the current state because it cannot handle the error token.
- if (yystack_.size () == 1)
- YYABORT;
+ // Pop the current state because it cannot handle the error token.
+ if (yystack_.size () == 1)
+ YYABORT;
]b4_locations_if([[
- yyerror_range[1].location = yystack_[0].location;]])[
- yy_destroy_ ("Error: popping", yystack_[0]);
- yypop_ ();
- YY_STACK_PRINT ();
- }
+ yyerror_range[1].location = yystack_[0].location;]])[
+ yy_destroy_ ("Error: popping", yystack_[0]);
+ yypop_ ();
+ YY_STACK_PRINT ();
+ }
+ {
+ stack_symbol_type error_token;
]b4_locations_if([[
yyerror_range[2].location = yyla.location;
YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);]])[
diff --git a/data/skeletons/lalr1.d b/data/skeletons/lalr1.d
index 04528257..a61b683d 100644
--- a/data/skeletons/lalr1.d
+++ b/data/skeletons/lalr1.d
@@ -618,6 +618,7 @@ m4_popdef([b4_at_dollar])])dnl
case YYERRLAB1:
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
+ // Pop stack until we find a state that shifts the error token.
for (;;)
{
yyn = yypact_[yystate];
diff --git a/data/skeletons/lalr1.java b/data/skeletons/lalr1.java
index 96676454..7e9c4da2 100644
--- a/data/skeletons/lalr1.java
+++ b/data/skeletons/lalr1.java
@@ -726,6 +726,7 @@ b4_dollar_popdef[]dnl
case YYERRLAB1:
yyerrstatus_ = 3; /* Each real token shifted decrements this. */
+ // Pop stack until we find a state that shifts the error token.
for (;;)
{
yyn = yypact_[yystate];
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 3487cd66..5225dd69 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -1998,6 +1998,7 @@ yyerrorlab:
yyerrlab1:
yyerrstatus = 3; /* Each real token shifted decrements this. */
+ // Pop stack until we find a state that shifts the error token.
for (;;)
{
yyn = yypact[yystate];
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- style: comments changes about error handling,
Akim Demaille <=