bug-bison
[Top][All Lists]
Advanced

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

[PATCH] token value 0 is ignored


From: Dick Streefland
Subject: [PATCH] token value 0 is ignored
Date: Fri, 26 Oct 2001 18:48:17 +0200
User-agent: Mutt/1.2.5i

I tried to build openmotif, using "bison -y" instead of yacc, but one
of the tools (uil) didn't work. The problem is that the grammar file
Uil.y contains the following token definition:

  %token  UILEOF  0

Bison ignores the 0, and assigns token value 257. I think that a token
value of 0 should be possible, and this is also how it is defined in
the original yacc article from Stephen C. Johnson:

  To assign a token number to a token (including literals), the first
  appearance of the token name or literal in the declarations section
  can be immediately followed by a nonnegative integer.

Below is a small patch that fixes this. Note: I'm not subscribed to
this list.

-- 
Dick Streefland                      ////             Altium Software BV
address@hidden           (@ @)          http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------

--- bison-1.29/src/reader.c.orig        Mon Aug 27 01:36:42 2001
+++ bison-1.29/src/reader.c     Fri Oct 26 18:41:48 2001
@@ -519,6 +519,7 @@
        {
          int oldclass = symval->class;
          symbol = symval;
+         symbol->user_token_number = -1;
 
          if (symbol->class == what_is_not)
            complain (_("symbol %s redefined"), symbol->tag);
@@ -853,7 +854,7 @@
       token = lex ();          /* okay, did number, now get literal */
     }
   else
-    usrtoknum = 0;
+    usrtoknum = -1;
 
   /* process literal string token */
 
@@ -1760,7 +1761,7 @@
 
       if (bp->class == token_sym)
        {
-         if (translations && !(bp->user_token_number))
+         if (translations && bp->user_token_number == -1)
            bp->user_token_number = ++last_user_token_number;
          if (bp->user_token_number > max_user_token_number)
            max_user_token_number = bp->user_token_number;
@@ -1789,7 +1790,7 @@
        {
          if (bp->value >= ntokens)
            continue;           /* non-terminal */
-         if (bp->user_token_number == SALIAS)
+         if (bp->user_token_number == SALIAS || bp->user_token_number == -1)
            continue;
          if (token_translations[bp->user_token_number] != 2)
            complain (_("tokens %s and %s both assigned number %d"),



reply via email to

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