]> git.saurik.com Git - bison.git/commitdiff
tests: check the use of dashes and periods in symbols.
authorAkim Demaille <demaille@gostai.com>
Tue, 21 Apr 2009 20:17:25 +0000 (22:17 +0200)
committerJoel E. Denny <jdenny@ces.clemson.edu>
Thu, 30 Apr 2009 00:41:32 +0000 (20:41 -0400)
* tests/input.at (Symbol): New test group.
(cherry picked from commit 746ee38c7cff93ad1fc97da6f06f124f394fb437)

ChangeLog
tests/input.at

index 9c0502c0e6be4f325103a3101948dcb54134fa4a..d7324eec409cc4b8230156223e1fdb95d0419faa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2009-04-21  Akim Demaille  <demaille@gostai.com>
+
+       tests: check the use of dashes and periods in symbols.
+       * tests/input.at (Symbol): New test group.
+
 2009-04-24  Joel E. Denny  <jdenny@ces.clemson.edu>
 
        Document how `%define "var" "value"' is not M4-friendly.
index 6c56e2fce63453be74aa6c181fd083464935e807..05ded403b4f3f0ba97fcebde5ea6d0c554e48b10 100644 (file)
@@ -615,6 +615,65 @@ AT_BISON_CHECK([-o input.c input.y])
 AT_CLEANUP
 
 
+## -------------- ##
+## Symbol names.  ##
+## -------------- ##
+
+AT_SETUP([Symbols])
+
+# Bison once thought a character token and its alias were different
+# symbols with the same user token number.
+
+AT_DATA_GRAMMAR([input.y],
+[[%token WITH-DASH
+%token WITHOUT_DASH "WITHOUT-DASH"
+%token WITH.PERIOD
+%token WITHOUT_PERIOD "WITHOUT.PERIOD"
+%%
+start: with-dash without_dash with.period without_period;
+with-dash: WITH-DASH;
+without_dash: "WITHOUT-DASH";
+with.period: WITH.PERIOD;
+without_period: "WITHOUT.PERIOD";
+%%
+]])
+
+# POSIX Yacc accept periods, but not dashes.
+AT_BISON_CHECK([--yacc input.y], [1], [],
+[[input.y:9.8-16: POSIX Yacc forbids dashes in symbol names: WITH-DASH
+input.y:14.8-16: POSIX Yacc forbids dashes in symbol names: with-dash
+]])
+
+# So warn about them.
+AT_BISON_CHECK([-Wyacc input.y], [], [],
+[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH
+input.y:14.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash
+]])
+
+# Dashes are fine for GNU Bison.
+AT_BISON_CHECK([-o input.c input.y])
+
+# Make sure we don't export silly token identifiers with periods or dashes.
+AT_COMPILE([input.o], [-c input.c])
+
+
+# Period are genuine letters, they can start identifiers.  Dashes
+# and digits can't.
+AT_DATA_GRAMMAR([input.y],
+[[%token .good
+%token -wrong
+%token 1nv4l1d
+%%
+start: .good
+]])
+AT_BISON_CHECK([-o input.c input.y], [1], [],
+[[input.y:10.8: invalid character: `-'
+input.y:11.8: syntax error, unexpected integer, expecting char or identifier or type
+]])
+
+AT_CLEANUP
+
+
 ## --------------------- ##
 ## Unclosed constructs.  ##
 ## --------------------- ##