From ff50f6f223777c910ad5b2c4d7da542db0f1006d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 12 Apr 2020 12:12:01 +0200 Subject: [PATCH] skeletons: use "invalid token" instead of "$undefined" * src/output.c (prepare_symbol_names): Also handle undeftoken. * tests/actions.at, tests/calc.at, tests/regression.at: Adjust. --- src/output.c | 5 +++++ src/parse-gram.c | 2 +- tests/actions.at | 6 +++--- tests/calc.at | 2 +- tests/regression.at | 10 +++++----- 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/output.c b/src/output.c index 5348aac4..1a7aa906 100644 --- a/src/output.c +++ b/src/output.c @@ -225,6 +225,11 @@ prepare_symbol_names (char const *muscle_name) tag = "\"end of file\""; translatable = with_translations; } + else if (symbols[i]->content == undeftoken->content) + { + tag = "\"invalid token\""; + translatable = with_translations; + } char *cp = tag[0] == '"' && !quote diff --git a/src/parse-gram.c b/src/parse-gram.c index 993ad11a..be7e599d 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -643,7 +643,7 @@ yysymbol_name (yysymbol_kind_t yysymbol) { static const char *const yy_sname[] = { - N_("end of file"), "error", "$undefined", N_("string"), + N_("end of file"), "error", N_("invalid token"), N_("string"), N_("translatable string"), "%token", "%nterm", "%type", "%destructor", "%printer", "%left", "%right", "%nonassoc", "%precedence", "%prec", "%dprec", "%merge", "%code", "%default-prec", "%define", "%defines", diff --git a/tests/actions.at b/tests/actions.at index 4a167690..46761c25 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1493,7 +1493,7 @@ Shifting token 'b' ('b') Entering state 5 Stack now 0 1 3 5 Reading a token -Next token is token $undefined () +Next token is token "invalid token" () Error: popping token 'b' ('b') DESTROY 'b' Stack now 0 1 3 @@ -1502,8 +1502,8 @@ Stack now 0 1 Shifting token error () Entering state 3 Stack now 0 1 3 -Next token is token $undefined () -Error: discarding token $undefined () +Next token is token "invalid token" () +Error: discarding token "invalid token" () Error: popping token error () Stack now 0 1 Shifting token error () diff --git a/tests/calc.at b/tests/calc.at index 8a3122aa..3a2830eb 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -935,7 +935,7 @@ _AT_CHECK_CALC_ERROR([$1], [1], [1//2], _AT_CHECK_CALC_ERROR([$1], [1], [error], [[final: 0 0 1]], [5], - [AT_JAVA_IF([1.1-1.2], [1.1])[: syntax error on token [$undefined] (expected: [number] ['-'] ['\n'] ['('] ['!'])]]) + [AT_JAVA_IF([1.1-1.2], [1.1])[: syntax error on token [invalid token] (expected: [number] ['-'] ['\n'] ['('] ['!'])]]) _AT_CHECK_CALC_ERROR([$1], [1], [1 = 2 = 3], [[final: 0 0 1]], [30], diff --git a/tests/regression.at b/tests/regression.at index 52c88e98..67866d20 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -701,7 +701,7 @@ static const yytype_int8 yyrline[] = }; static const char *const yytname[] = { - "\"end of file\"", "error", "$undefined", "\"if\"", "\"const\"", + "\"end of file\"", "error", "\"invalid token\"", "\"if\"", "\"const\"", "\"then\"", "\"else\"", "$accept", "statement", "struct_stat", "if", "else", YY_NULLPTR }; @@ -1461,14 +1461,14 @@ AT_PARSER_CHECK([[input --debug]], [[2]], [], Entering state 0 Stack now 0 Reading a token -Next token is token $undefined () -LAC: initial context established for $undefined -LAC: checking lookahead $undefined: Always Err +Next token is token "invalid token" () +LAC: initial context established for "invalid token" +LAC: checking lookahead "invalid token": Always Err Constructing syntax error message LAC: checking lookahead "end of file": R2 G3 R2 G5 R2 G6 R2 G7 R2 G8 R2 G9 R2 G10 R2 G11 R2 (max size exceeded) syntax error memory exhausted -Cleanup: discarding lookahead token $undefined () +Cleanup: discarding lookahead token "invalid token" () Stack now 0 ]])