bison-patches
[Top][All Lists]
Advanced

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

FYI: Both: Mixing token styles


From: Akim Demaille
Subject: FYI: Both: Mixing token styles
Date: 02 Nov 2001 15:15:08 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

I'm discovering that Bison, when being taught to number some tokens,
does not changes its algorithm to number the others.  For instance,
since we know it starts numbering with 257, just try this:

~/src/bison-1.29 % cat >/tmp/foo.y <<EOF                         nostromo 15:12
heredoc> %token A 257
heredoc> %token B 
heredoc> %%
heredoc> exp:;
heredoc> %%
heredoc> EOF
~/src/bison-1.29 % bison /tmp/foo.y                              nostromo 15:14
/tmp/foo.y:5: les jetons A et B se sont vus assigner le nombre 257
~/src/bison-1.29 % LC_ALL=C bison /tmp/foo.y                     nostromo Err 1
/tmp/foo.y:5: tokens A and B both assigned number 257

Good, at least it catches the collision.  But I'm surprised.
Conversely, I guess that when the user numbers some tokens, he knows
exactly what he is doing.

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * tests/regression.at (Mixing %token styles): New test.

Index: tests/regression.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/regression.at,v
retrieving revision 1.1.2.6
diff -u -u -r1.1.2.6 regression.at
--- tests/regression.at 2001/11/01 18:29:36 1.1.2.6
+++ tests/regression.at 2001/11/02 14:12:27
@@ -45,6 +45,29 @@
 
 
 ## ---------------------- ##
+## Mixing %token styles.  ##
+## ---------------------- ##
+
+
+AT_SETUP([Mixing %token styles])
+
+# Taken from the documentation.
+AT_DATA([input.y],
+[[%token  <operator>  OR      "||"
+%token  <operator>  LE 134  "<="
+%left  OR  "<="
+%%
+exp: ;
+%%
+]])
+
+AT_CHECK([bison -v input.y -o input.c], 0, ignore, ignore)
+
+AT_CLEANUP([input.*])
+
+
+
+## ---------------------- ##
 ## %union and --defines.  ##
 ## ---------------------- ##
 



reply via email to

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