]> git.saurik.com Git - bison.git/commitdiff
glr: allow spaces between "%?" and "{" in predicates
authorAkim Demaille <akim@lrde.epita.fr>
Wed, 16 Oct 2013 13:19:44 +0000 (15:19 +0200)
committerAkim Demaille <akim@lrde.epita.fr>
Wed, 16 Oct 2013 13:51:25 +0000 (15:51 +0200)
Reported by Rici Lake.
http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00004.html
http://stackoverflow.com/questions/19330171/

* src/scan-gram.l: Do not try to be too smart when diagnosing invalid
directives.
* tests/glr-regression.at (Predicates): New test.

NEWS
THANKS
src/scan-gram.l
tests/glr-regression.at

diff --git a/NEWS b/NEWS
index 7a2d4b5c2a23fbf084152e3bb65076b23ef6a4e1..e01198de323d268700ac3333bcc4f6fc3503826a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -15,6 +15,11 @@ GNU Bison NEWS
   leaves "foo" diagnostics as warnings.  Similarly, with "-Werror=foo
   -Wno-error", "foo" diagnostics are now errors.
 
+*** GLR Predicates
+
+  As demonstrated in the documentation, one can now leave spaces between
+  "%?" and its "{".
+
 * Noteworthy changes in release 3.0 (2013-07-25) [stable]
 
 ** WARNING: Future backward-incompatibilities!
diff --git a/THANKS b/THANKS
index 2d4a6a994f586f610ccfac52c944736f52d4297b..0ffa8b646f991236c3e00a55fd82de73d827b25b 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -110,6 +110,7 @@ R Blake                   blakers@mac.com
 Raja R Harinath           harinath@cs.umn.edu
 Ralf Wildenhues           Ralf.Wildenhues@gmx.de
 Richard Stallman          rms@gnu.org
+Rici Lake                 ricilake@gmail.com
 Rob Vermaas               rob.vermaas@gmail.com
 Robert Anisko             anisko_r@epita.fr
 Rob Conde                 rob.conde@ai-solutions.com
index 665e80de648989e7cff2038890361c94d4cc0219..555e695234d93dc70127f85c6b1a88371bc692bf 100644 (file)
@@ -266,7 +266,7 @@ eqopt    ([[:space:]]*=)?
   "%pure"[-_]"parser"               DEPRECATED("%pure-parser");
   "%token"[-_]"table"               DEPRECATED("%token-table");
 
-  "%"{id}|"%"{notletter}([[:graph:]])+ {
+  "%"{id} {
     complain (loc, complaint, _("invalid directive: %s"), quote (yytext));
   }
 
index 711ab7ec597fc6d588ba0527f4ab85330a30c5c0..064b37b29ddf7013f5da66dd0b39b2b89850b6b1 100644 (file)
@@ -1749,3 +1749,33 @@ Cleanup: popping token 'a' ()
 ])
 
 AT_CLEANUP
+
+
+## ----------------------------------------------------------------- ##
+## Predicates.                                                       ##
+##                                                                   ##
+## http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00004.html ##
+## ----------------------------------------------------------------- ##
+
+AT_SETUP([Predicates])
+
+# FIXME: We need genuine test cases with uses of %?.
+
+AT_DATA_GRAMMAR([input.y],
+[[%glr-parser
+%expect-rr 1
+%%
+// Exercise "%?{...}" and "%? {...}".
+widget:
+  %? {new_syntax} "widget" id new_args  { $$ = f($3, $4); }
+| %?{!new_syntax} "widget" id old_args  { $$ = f($3, $4); }
+;
+id:;
+new_args:;
+old_args:;
+%%
+]])
+
+AT_BISON_CHECK([[input.y]])
+
+AT_CLEANUP