+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.
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;
}
}
prev = t;
-
}
}
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)
/* 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"),
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;
/* 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.
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;
/* 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.
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
extern void perror (const char *s);
%}
-/* BISON Declarations */
+/* Bison Declarations */
+%token CALC_EOF 0
%token NUM
%nonassoc '=' /* comparison */
/* Return end-of-file. */
if (c == EOF)
- return 0;
+ return CALC_EOF;
/* Return single chars. */
return c;