bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] bison: catch bad symbol names.


From: Akim Demaille
Subject: [PATCH] bison: catch bad symbol names.
Date: Mon, 4 May 2009 21:23:55 +0200

        * 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 ae38cf3..db56d97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2009-05-04  Akim Demaille  <address@hidden>
 
+       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  <address@hidden>
+
        space changes.
        * src/scan-gram.l: Untabify to be robust to zealous editors.
 
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 9bf156b..a22cafd 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 7eaafaa..4345edd 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
-- 
1.6.2.2





reply via email to

[Prev in Thread] Current Thread [Next in Thread]