[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison 3.0: semantic predicates are mis-scanned as invalid directives
From: |
Akim Demaille |
Subject: |
Re: Bison 3.0: semantic predicates are mis-scanned as invalid directives |
Date: |
Thu, 17 Oct 2013 14:07:39 +0200 |
[resent to be public]
Le 16 oct. 2013 à 15:39, Rici Lake <address@hidden> a écrit :
> Hi, Akim.
>
> I really think my fix is better. Rearranging the patterns will still allow
> the error pattern to win if it is longer, such as:
>
> %?{safe_mode}
>
> I don't believe there is a requirement that { be followed by a space, even if
> most of us would do that.
You do have a point, thanks for catching this! However, really,
I do not want
exp?: exp{ "+" exp{
to become valid: "?" and "{" are _not_ letters.
Well, I think I tried too hard to have nice messages for unexpected
"%" combinations, such as "%'" or whatever, but it's simpler and
safer to leave the code do its jobs as it did before.
The catch-all case will handle such errors.
$ cat /tmp/foo.yy
%!
%%
exp:
$ LC_ALL=C ./_build/48s/tests/bison /tmp/foo.yy
/tmp/foo.yy:1.1: error: invalid character: '%'
%!
^
/tmp/foo.yy:1.2: error: invalid character: '!'
%!
^
Here's the second version of patch (until you come with another bug
report :).
commit 071863b3d88c232c10348b7c38378c47d363857c
Author: Akim Demaille <address@hidden>
Date: Wed Oct 16 15:19:44 2013 +0200
glr: allow spaces between "%?" and "{" in predicates
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.
diff --git a/NEWS b/NEWS
index 7a2d4b5..e01198d 100644
--- 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 2d4a6a9..0ffa8b6 100644
--- a/THANKS
+++ b/THANKS
@@ -110,6 +110,7 @@ R Blake address@hidden
Raja R Harinath address@hidden
Ralf Wildenhues address@hidden
Richard Stallman address@hidden
+Rici Lake address@hidden
Rob Vermaas address@hidden
Robert Anisko address@hidden
Rob Conde address@hidden
diff --git a/src/scan-gram.l b/src/scan-gram.l
index 665e80d..555e695 100644
--- a/src/scan-gram.l
+++ b/src/scan-gram.l
@@ -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));
}
diff --git a/tests/glr-regression.at b/tests/glr-regression.at
index 711ab7e..064b37b 100644
--- a/tests/glr-regression.at
+++ b/tests/glr-regression.at
@@ -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