bison: catch bad symbol names.

* src/scan-gram.l({int}{id}): Report as an invalid identifier.
	* tests/input.at: Adjust.
This commit is contained in:
Akim Demaille
2009-05-04 21:23:55 +02:00
parent 43e6aea526
commit ecdfea9a12
3 changed files with 15 additions and 3 deletions

View File

@@ -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.

View File

@@ -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;

View File

@@ -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