bug-bison
[Top][All Lists]
Advanced

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

Re: [PATCH] token value 0 is ignored


From: Akim Demaille
Subject: Re: [PATCH] token value 0 is ignored
Date: 02 Nov 2001 16:26:12 +0100
User-agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence)

>>>>> "Akim" == Akim Demaille <address@hidden> writes:

Akim> Oops, then I'm sorry I misunderstood.  I seemed to have seen
Akim> that you were also changing the default numbering base.

I'm applying this to 1.30a and 1.49a.  Thanks for your report!  I
guess we could release 1.31 next week.  Shall we wait for some more
feedback?

Index: ChangeLog
from  Akim Demaille  <address@hidden>

        * src/symtab.h (SUNDEF): New.
        * src/symtab.c (bucket_new): Init user_token_number to SUNDEF to
        stand for `uninitialized', instead of 0.
        * src/reader.c (packsymbols, parse_thong_decl): Adjust.
        * src/lex.c (lex): Adjust.

        * tests/calc.at (_AT_DATA_CALC_Y): Declare a token for EOF.
        Number it 0.
        Let yylex return it instead of a plain 0.
        Reported by Dick Streefland.

Index: NEWS
===================================================================
RCS file: /cvsroot/bison/bison/NEWS,v
retrieving revision 1.21.2.17
diff -u -u -r1.21.2.17 NEWS
--- NEWS 2001/11/02 14:02:30 1.21.2.17
+++ NEWS 2001/11/02 15:24:26
@@ -6,6 +6,9 @@
 * Fixed incorrect processing of some invalid input.
 
 * Fixed CPP guards: 9foo.h uses BISON_9FOO_H instead of 9FOO_H.
+
+* %token MY_EOF 0 is supported.
+  Before, MY_EOF was silently renumbered as 257.
 
 Changes in version 1.30:
 
Index: src/lex.c
===================================================================
RCS file: /cvsroot/bison/bison/src/lex.c,v
retrieving revision 1.33.2.8
diff -u -u -r1.33.2.8 lex.c
--- src/lex.c 2001/11/01 18:03:46 1.33.2.8
+++ src/lex.c 2001/11/02 15:24:26
@@ -445,7 +445,7 @@
        token_buffer = obstack_finish (&token_obstack);
        symval = getsym (token_buffer);
        symval->class = token_sym;
-       if (!symval->user_token_number)
+       if (symval->user_token_number == SUNDEF)
          symval->user_token_number = code;
        return tok_identifier;
       }
Index: src/reader.c
===================================================================
RCS file: /cvsroot/bison/bison/src/reader.c,v
retrieving revision 1.72.2.10
diff -u -u -r1.72.2.10 reader.c
--- src/reader.c 2001/11/02 14:02:31 1.72.2.10
+++ src/reader.c 2001/11/02 15:24:26
@@ -695,7 +695,6 @@
        }
 
       prev = t;
-
     }
 }
 
@@ -821,7 +820,7 @@
   token_t token;
   struct bucket *symbol;
   char *typename = 0;
-  int usrtoknum = 0;
+  int usrtoknum = SUNDEF;
 
   token = lex ();              /* fetch typename or first token */
   if (token == tok_typename)
@@ -1689,6 +1688,9 @@
       /* A token string alias? */
       if (bp->user_token_number == SALIAS)
        continue;
+
+      assert (bp->user_token_number != SUNDEF);
+
       /* A token which translation has already been set? */
       if (token_translations[bp->user_token_number] != 2)
        complain (_("tokens %s and %s both assigned number %d"),
@@ -1775,7 +1777,7 @@
 
       if (bp->class == token_sym)
        {
-         if (bp->user_token_number == 0)
+         if (bp->user_token_number == SUNDEF)
            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;
Index: src/symtab.c
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.c,v
retrieving revision 1.13.2.2
diff -u -u -r1.13.2.2 symtab.c
--- src/symtab.c 2001/09/25 18:35:04 1.13.2.2
+++ src/symtab.c 2001/11/02 15:24:26
@@ -1,5 +1,5 @@
 /* Symbol table manager for Bison,
-   Copyright 1984, 1989, 2000 Free Software Foundation, Inc.
+   Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -58,7 +58,7 @@
   res->value = 0;
   res->prec = 0;
   res->assoc = right_assoc;
-  res->user_token_number = 0;
+  res->user_token_number = SUNDEF;
   res->alias = NULL;
   res->class = unknown_sym;
 
Index: src/symtab.h
===================================================================
RCS file: /cvsroot/bison/bison/src/symtab.h,v
retrieving revision 1.12
diff -u -u -r1.12 symtab.h
--- src/symtab.h 2000/11/07 16:28:47 1.12
+++ src/symtab.h 2001/11/02 15:24:26
@@ -1,5 +1,5 @@
 /* Definitions for symtab.c and callers, part of bison,
-   Copyright 1984, 1989, 1992, 2000 Free Software Foundation, Inc.
+   Copyright 1984, 1989, 1992, 2000, 2001  Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -33,6 +33,7 @@
   nterm_sym            /* non-terminal */
 } symbol_class;
 
+#define SUNDEF  -1              /* For undefined user number. */
 #define SALIAS -9991           /* for symbol generated with an alias */
 
 typedef struct bucket
Index: tests/calc.at
===================================================================
RCS file: /cvsroot/bison/bison/tests/calc.at,v
retrieving revision 1.5.2.7
diff -u -u -r1.5.2.7 calc.at
--- tests/calc.at 2001/10/18 16:18:54 1.5.2.7
+++ tests/calc.at 2001/11/02 15:24:26
@@ -64,7 +64,8 @@
 extern void perror (const char *s);
 %}
 
-/* BISON Declarations */
+/* Bison Declarations */
+%token CALC_EOF 0
 %token NUM
 
 %nonassoc '=' /* comparison           */
@@ -204,7 +205,7 @@
 
   /* Return end-of-file.  */
   if (c == EOF)
-    return 0;
+    return CALC_EOF;
 
   /* Return single chars. */
   return c;



reply via email to

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