summaryrefslogtreecommitdiff
path: root/tests/named-refs.at
diff options
context:
space:
mode:
authorJoel E. Denny <joeldenny@joeldenny.org>2011-01-09 18:06:19 -0500
committerJoel E. Denny <joeldenny@joeldenny.org>2011-01-09 18:14:45 -0500
commit8cbbf1786f23176c25f058beff0d5779341022fa (patch)
treee5d2409e75e8d06b542b0711b9e85e235925350f /tests/named-refs.at
parent354303787cfbdc0839e6d55c9956c5e664aa625a (diff)
downloadbison-8cbbf1786f23176c25f058beff0d5779341022fa.tar.gz
Improve error messages for `$' or `@' followed by `.' or `-'.
Previously, for this special case of an invalid reference, the usual "symbol not found in production:" was printed. However, because the symbol name was parsed as the empty string, that message was followed immediately by a newline instead of a symbol name. In reality, this is a syntax error, so the reference is invalid regardless of the symbols actually appearing in the production. Discussed at <http://lists.gnu.org/archive/html/bison-patches/2011-01/msg00012.html>. * src/scan-code.l (parse_ref): Report the above case as a syntax error. Other than that, continue to handle this case like any other invalid reference that Bison manages to parse because "possibly meant" messages can still be helpful to the user. * tests/named-refs.at ($ or @ followed by . or -): New test group. (cherry picked from commit 5c9efc755e61e47011a71b022ad232e28af67bd0)
Diffstat (limited to 'tests/named-refs.at')
-rw-r--r--tests/named-refs.at29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/named-refs.at b/tests/named-refs.at
index 25af97de..f818e094 100644
--- a/tests/named-refs.at
+++ b/tests/named-refs.at
@@ -561,3 +561,32 @@ test.y:57.8-17: invalid reference: `$<aa>[sym]'
test.y:54.1-57.21: symbol not found in production: sym
]])
AT_CLEANUP
+
+#######################################################################
+
+AT_SETUP([[$ or @ followed by . or -]])
+AT_DATA([[test.y]],
+[[
+%%
+start:
+ .field { $.field; }
+| -field { @-field; }
+| 'a' { @.field; }
+| 'a' { $-field; }
+;
+.field: ;
+-field: ;
+]])
+AT_BISON_CHECK([[test.y]], [[1]], [],
+[[test.y:4.12-18: invalid reference: `$.field'
+test.y:4.13: syntax error after `$', expecting integer, letter, `_', `@<:@', or `$'
+test.y:4.3-8: possibly meant: $[.field] at $1
+test.y:5.12-18: invalid reference: `@-field'
+test.y:5.13: syntax error after `@', expecting integer, letter, `_', `@<:@', or `$'
+test.y:5.3-8: possibly meant: @[-field] at $1
+test.y:6.12-18: invalid reference: `@.field'
+test.y:6.13: syntax error after `@', expecting integer, letter, `_', `@<:@', or `$'
+test.y:7.12-18: invalid reference: `$-field'
+test.y:7.13: syntax error after `$', expecting integer, letter, `_', `@<:@', or `$'
+]])
+AT_CLEANUP