[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
maint: yacc.c: make sure we properly propagated the user's number for er
From: |
Akim Demaille |
Subject: |
maint: yacc.c: make sure we properly propagated the user's number for error |
Date: |
Sun, 8 Mar 2020 08:08:00 +0100 |
commit 87664b8ff6be4eb9ae90d2cdb6789ea3097c4f0e
Author: Akim Demaille <address@hidden>
Date: Sun Mar 8 07:56:39 2020 +0100
yacc.c: make sure we properly propagated the user's number for error
* data/skeletons/yacc.c (YYERRCODE): Be truthful.
* tests/input.at (Redefining the error token): Check that.
diff --git a/TODO b/TODO
index 7a3580cc..a7b7b948 100644
--- a/TODO
+++ b/TODO
@@ -315,13 +315,8 @@ It would be a very nice source of inspiration for the
other languages.
Valentin Tolmer is working on this.
** YYERRCODE
-Defined to 256, but not used, not documented. Probably the token
-number for the error token, which POSIX wants to be 256, but which
-Bison might renumber if the user used number 256. Keep fix and doc?
-Throw away?
-
-Also, why don't we output the token name of the error token in the
-output? It is explicitly skipped:
+Why don't we output the token name of the error token in the output? It is
+explicitly skipped:
/* Skip error token and tokens without identifier. */
if (sym != errtoken && id)
diff --git a/data/skeletons/yacc.c b/data/skeletons/yacc.c
index 9a083037..add94351 100644
--- a/data/skeletons/yacc.c
+++ b/data/skeletons/yacc.c
@@ -673,7 +673,7 @@ static const ]b4_int_type_for([b4_toknum])[ yytoknum[] =
/* Error token number */
#define YYTERROR 1
-#define YYERRCODE 256
+#define YYERRCODE ]b4_symbol(1, user_number)[
]b4_locations_if([[
]b4_yylloc_default_define[
diff --git a/tests/input.at b/tests/input.at
index dd5af739..ccab6844 100644
--- a/tests/input.at
+++ b/tests/input.at
@@ -326,6 +326,21 @@ input.y:2.14-16: error: redefining user token number of
error
| ^~~
]])
+# While at it, make sure we properly used the user's number for
+# "error".
+AT_DATA([input.y],
+[[%token error 123
+%%
+exp:
+]])
+
+AT_BISON_CHECK([input.y])
+
+AT_CHECK([$EGREP -E '123|256' input.tab.c], [],
+[[ 0, 123, 257
+#define YYERRCODE 123
+]])
+
AT_CLEANUP
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- maint: yacc.c: make sure we properly propagated the user's number for error,
Akim Demaille <=