]> git.saurik.com Git - bison.git/commitdiff
bison: catch bad symbol names.
authorAkim Demaille <demaille@gostai.com>
Mon, 4 May 2009 19:23:55 +0000 (21:23 +0200)
committerAkim Demaille <demaille@gostai.com>
Mon, 4 May 2009 19:31:07 +0000 (21:31 +0200)
* src/scan-gram.l({int}{id}): Report as an invalid identifier.
* tests/input.at: Adjust.

ChangeLog
src/scan-gram.l
tests/input.at

index ae38cf3ec64dd2a91ac9c6e3b7732b997beb61d4..db56d9748e4506d25c01fc180b098a5d20230481 100644 (file)
--- 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.
index 9bf156b2d48088b668ce4f93bfad331c36c20c9b..a22cafdcd8cf64247ee925ce207490037659c88c 100644 (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;
index 7eaafaae7089ae3df79c11b3d125ee4b3104b9fe..4345eddd36f8160646a9d78d5e4bc299d9ebed0d 100644 (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