From ecdfea9a128a309e27a8ffb50da3a1ddd13387d2 Mon Sep 17 00:00:00 2001 From: Akim Demaille <demaille@gostai.com> Date: Mon, 4 May 2009 21:23:55 +0200 Subject: [PATCH] bison: catch bad symbol names. * src/scan-gram.l({int}{id}): Report as an invalid identifier. * tests/input.at: Adjust. --- ChangeLog | 6 ++++++ src/scan-gram.l | 6 ++++++ tests/input.at | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ae38cf3e..db56d974 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2009-05-04 Akim Demaille <demaille@gostai.com> + + bison: catch bad symbol names. + * src/scan-gram.l({int}{id}): Report as an invalid identifier. + * tests/input.at: Adjust. + 2009-05-04 Akim Demaille <demaille@gostai.com> space changes. diff --git a/src/scan-gram.l b/src/scan-gram.l index 9bf156b2..a22cafdc 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -208,6 +208,12 @@ splice (\\[ \f\t\v]*\n)* complain_at (*loc, _("invalid directive: %s"), quote (yytext)); } + /* Identifiers may not start with a digit. Yet, don't silently + accept "1FOO" as "1 FOO". */ + {int}{id} { + complain_at (*loc, _("invalid identifier: %s"), quote (yytext)); + } + "=" return EQUAL; "|" return PIPE; ";" return SEMICOLON; diff --git a/tests/input.at b/tests/input.at index 7eaafaae..4345eddd 100644 --- a/tests/input.at +++ b/tests/input.at @@ -662,13 +662,13 @@ AT_COMPILE([input.o], [-c input.c]) # Digits cannot. AT_DATA_GRAMMAR([input.y], [[%token .GOOD -%token -GOOD -%token 1NV4L1D + -GOOD + 1NV4L1D %% start: .GOOD -GOOD ]]) AT_BISON_CHECK([-o input.c input.y], [1], [], -[[input.y:11.8: syntax error, unexpected integer, expecting char or identifier or type +[[input.y:11.10-16: invalid identifier: `1NV4L1D' ]]) AT_CLEANUP -- 2.47.2