[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] Pass the token type to yysyntax_error.
From: |
Akim Demaille |
Subject: |
[PATCH] Pass the token type to yysyntax_error. |
Date: |
Thu, 11 Dec 2008 09:48:49 +0100 |
* data/yacc.c (yysyntax_error): Take the transated token instead
of the raw number.
Adjust callers.
* TODO: Update.
---
ChangeLog | 8 ++++++++
TODO | 4 ----
data/yacc.c | 13 ++++++-------
3 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 77e23d8..46d4d5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2008-12-11 Akim Demaille <address@hidden>
+ Pass the token type to yysyntax_error.
+ * data/yacc.c (yysyntax_error): Take the transated token instead
+ of the raw number.
+ Adjust callers.
+ * TODO: Update.
+
+2008-12-11 Akim Demaille <address@hidden>
+
Formatting changes.
* data/glr.c: Formatting changes.
diff --git a/TODO b/TODO
index b12a039..5ae4f70 100644
--- a/TODO
+++ b/TODO
@@ -157,10 +157,6 @@ management is performed once instead of three times). I
suggest that
we do the same in yacc.c.
** yysyntax_error
-In lalr1.cc we invoke it with the translated lookahead (yytoken), and
-yacc.c uses yychar. I don't see why.
-
-** yysyntax_error
The code bw glr.c and yacc.c is really alike, we can certainly factor
some parts.
diff --git a/data/yacc.c b/data/yacc.c
index da7c72c..7a20cbb 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -822,14 +822,14 @@ yytnamerr (char *yyres, const char *yystr)
# endif
/* Copy into YYRESULT an error message about the unexpected token
- YYCHAR while in state YYSTATE. Return the number of bytes copied,
+ YYTOKEN while in state YYSTATE. Return the number of bytes copied,
including the terminating null byte. If YYRESULT is null, do not
copy anything; just return the number of bytes that would be
copied. As a special case, return 0 if an ordinary "syntax error"
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
size calculation. */
static YYSIZE_T
-yysyntax_error (char *yyresult, int yystate, int yychar)
+yysyntax_error (char *yyresult, int yystate, int yytoken)
{
int yyn = yypact[yystate];
@@ -837,8 +837,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
return 0;
else
{
- int yytype = YYTRANSLATE (yychar);
- YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
+ YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
int yysize_overflow = 0;
@@ -860,7 +859,7 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
int yycount = 0;
int yyx;
- yyarg[yycount++] = yytname[yytype];
+ yyarg[yycount++] = yytname[yytoken];
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
@@ -1417,7 +1416,7 @@ yyerrlab:
yyerror (]b4_yyerror_args[YY_("syntax error"));
#else
{
- YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
+ YYSIZE_T yysize = yysyntax_error (0, yystate, yytoken);
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
{
YYSIZE_T yyalloc = 2 * yysize;
@@ -1437,7 +1436,7 @@ yyerrlab:
if (0 < yysize && yysize <= yymsg_alloc)
{
- (void) yysyntax_error (yymsg, yystate, yychar);
+ (void) yysyntax_error (yymsg, yystate, yytoken);
yyerror (]b4_yyerror_args[yymsg);
}
else
--
1.6.0.4.790.gaa14a
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [PATCH] Pass the token type to yysyntax_error.,
Akim Demaille <=