+2002-06-10 Akim Demaille <akim@epita.fr>
+
+ * src/symtab.c (symbol_user_token_number_set): Don't complain when
+ assigning twice the same user number to a token, so that we can
+ use it in...
+ * src/lex.c (lex): here.
+ Also use `symbol_class_set' instead of hand written code.
+ * src/reader.c (parse_assoc_decl): Likewise.
+
2002-06-10 Akim Demaille <akim@epita.fr>
* src/symtab.c, src/symtab.c (symbol_class_set)
/* Token-reader for Bison's input parser,
- Copyright 1984, 1986, 1989, 1992, 2000, 2001 Free Software Foundation, Inc.
+ Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
+ Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
obstack_1grow (&token_obstack, '\0');
token_buffer = obstack_finish (&token_obstack);
symval = getsym (token_buffer);
- if (symval->number == NUMBER_UNDEFINED)
- {
- symval->number = ntokens++;
- symval->class = token_sym;
- if (symval->user_token_number == USER_NUMBER_UNDEFINED)
- symval->user_token_number = code;
- }
+ symbol_class_set (symval, token_sym);
+ symbol_user_token_number_set (symval, code);
return tok_identifier;
}
/* parse the literal string token and treat as an identifier */
{
- int code; /* ignored here */
+ int code;
obstack_1grow (&token_obstack, '\"');
/* Read up to and including ". */
token_buffer = obstack_finish (&token_obstack);
symval = getsym (token_buffer);
- if (symval->number == NUMBER_UNDEFINED)
- {
- symval->number = ntokens++;
- symval->class = token_sym;
- }
-
+ symbol_class_set (symval, token_sym);
return tok_identifier;
}
break;
case tok_identifier:
- if (symval->class == nterm_sym)
- complain (_("symbol %s redefined"), symval->tag);
- if (symval->number == NUMBER_UNDEFINED)
- {
- symval->number = ntokens++;
- symval->class = token_sym;
- }
+ symbol_class_set (symval, token_sym);
symbol_precedence_set (symval, lastprec, assoc);
if (name)
symbol_type_set (symval, name);
case tok_number:
if (prev == tok_identifier)
{
- symval->user_token_number = numval;
+ symbol_user_token_number_set (symval, numval);
}
else
{
{
assert (symbol->class == token_sym);
- if (symbol->user_token_number != USER_NUMBER_UNDEFINED)
+ if (symbol->user_token_number != USER_NUMBER_UNDEFINED
+ && symbol->user_token_number != user_token_number)
complain (_("redefining user token number of %s"), symbol->tag);
symbol->user_token_number = user_token_number;