mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* 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.
This commit is contained in:
13
ChangeLog
13
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.
|
||||
|
||||
@@ -446,7 +446,7 @@ lex (void)
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -724,7 +724,6 @@ token_buffer);
|
||||
}
|
||||
|
||||
prev = t;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -852,7 +851,7 @@ parse_thong_decl (void)
|
||||
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)
|
||||
@@ -1724,6 +1723,9 @@ token_translations_init (void)
|
||||
/* 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"),
|
||||
@@ -1810,7 +1812,7 @@ packsymbols (void)
|
||||
|
||||
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;
|
||||
|
||||
@@ -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 @@ bucket_new (const char *tag, int hashval)
|
||||
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;
|
||||
|
||||
|
||||
@@ -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 @@ typedef enum
|
||||
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
|
||||
|
||||
@@ -64,7 +64,8 @@ static void yyungetc (int c);
|
||||
extern void perror (const char *s);
|
||||
%}
|
||||
|
||||
/* BISON Declarations */
|
||||
/* Bison Declarations */
|
||||
%token CALC_EOF 0
|
||||
%token NUM
|
||||
|
||||
%nonassoc '=' /* comparison */
|
||||
@@ -204,7 +205,7 @@ yylex (void)
|
||||
|
||||
/* Return end-of-file. */
|
||||
if (c == EOF)
|
||||
return 0;
|
||||
return CALC_EOF;
|
||||
|
||||
/* Return single chars. */
|
||||
return c;
|
||||
|
||||
Reference in New Issue
Block a user