summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TODO9
-rw-r--r--data/skeletons/yacc.c2
-rw-r--r--tests/input.at15
3 files changed, 18 insertions, 8 deletions
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