]> git.saurik.com Git - bison.git/commitdiff
* src/symtab.h (SUNDEF): New.
authorAkim Demaille <akim@epita.fr>
Fri, 2 Nov 2001 15:26:33 +0000 (15:26 +0000)
committerAkim Demaille <akim@epita.fr>
Fri, 2 Nov 2001 15:26:33 +0000 (15:26 +0000)
* 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.

ChangeLog
NEWS
src/lex.c
src/reader.c
src/symtab.c
src/symtab.h
tests/calc.at

index 8d585fe62c9ccde34127ae017ea26a3ffdb18568..3784234d2f10b953a6df5a15a19278eb98807f34 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2001-11-02  Akim Demaille  <akim@epita.fr>
+
+       * 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.
+
 2001-11-02  Akim Demaille  <akim@epita.fr>
 
        * tests/regression.at (Mixing %token styles): New test.
 2001-11-02  Akim Demaille  <akim@epita.fr>
 
        * tests/regression.at (Mixing %token styles): New test.
diff --git a/NEWS b/NEWS
index 662c129b6aa82bb6a29ee7c6b08a7b7fb9493a9b..99fb25f319359abe95579700915194868d0991cd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,9 @@ Changes in version 1.30a:
 * Fixed incorrect processing of some invalid input.
 
 * Fixed CPP guards: 9foo.h uses BISON_9FOO_H instead of 9FOO_H.
 * 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.
 \f
 Changes in version 1.30:
 
 \f
 Changes in version 1.30:
 
index 6d1ec27e1a3810891188904b8f0e9ba7ddd2cdde..a9c0b0d51e532a22c69defbf4c4bbaa4937b90e2 100644 (file)
--- a/src/lex.c
+++ b/src/lex.c
@@ -445,7 +445,7 @@ lex (void)
        token_buffer = obstack_finish (&token_obstack);
        symval = getsym (token_buffer);
        symval->class = token_sym;
        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;
       }
          symval->user_token_number = code;
        return tok_identifier;
       }
index 6c7a9eec7699ceadbe1184c4a121594f18f97b33..4d87026ff1c02dafca66c127ac817964e013d5d9 100644 (file)
@@ -695,7 +695,6 @@ token_buffer);
        }
 
       prev = t;
        }
 
       prev = t;
-
     }
 }
 
     }
 }
 
@@ -821,7 +820,7 @@ parse_thong_decl (void)
   token_t token;
   struct bucket *symbol;
   char *typename = 0;
   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)
 
   token = lex ();              /* fetch typename or first token */
   if (token == tok_typename)
@@ -1689,6 +1688,9 @@ token_translations_init (void)
       /* A token string alias? */
       if (bp->user_token_number == SALIAS)
        continue;
       /* 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"),
       /* 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 @@ packsymbols (void)
 
       if (bp->class == token_sym)
        {
 
       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;
            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 6e5d5ea9b7f13acccb4a50b00e37a44cb29df5ed..455e74e2310ec00727a8f68034e406d3f7fd17a9 100644 (file)
@@ -1,5 +1,5 @@
 /* Symbol table manager for Bison,
 /* 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.
 
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -58,7 +58,7 @@ bucket_new (const char *tag, int hashval)
   res->value = 0;
   res->prec = 0;
   res->assoc = right_assoc;
   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;
 
   res->alias = NULL;
   res->class = unknown_sym;
 
index 909b24f5aebb109c432d164cb4206ce48c17c2f8..b98902e14015b1e210cd307b99fc0f24aaaab010 100644 (file)
@@ -1,5 +1,5 @@
 /* Definitions for symtab.c and callers, part of bison,
 /* 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.
 
 
    This file is part of Bison, the GNU Compiler Compiler.
 
@@ -33,6 +33,7 @@ typedef enum
   nterm_sym            /* non-terminal */
 } symbol_class;
 
   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
 #define SALIAS -9991           /* for symbol generated with an alias */
 
 typedef struct bucket
index f1064634cfa2a57fa937ac781530082300f246c6..a366cd859d656860e4e8897e002630bf663f306f 100644 (file)
@@ -64,7 +64,8 @@ static void yyungetc (int c);
 extern void perror (const char *s);
 %}
 
 extern void perror (const char *s);
 %}
 
-/* BISON Declarations */
+/* Bison Declarations */
+%token CALC_EOF 0
 %token NUM
 
 %nonassoc '=' /* comparison           */
 %token NUM
 
 %nonassoc '=' /* comparison           */
@@ -204,7 +205,7 @@ yylex (void)
 
   /* Return end-of-file.  */
   if (c == EOF)
 
   /* Return end-of-file.  */
   if (c == EOF)
-    return 0;
+    return CALC_EOF;
 
   /* Return single chars. */
   return c;
 
   /* Return single chars. */
   return c;