From: Akim Demaille Date: Mon, 10 Jun 2002 08:38:10 +0000 (+0000) Subject: * src/symtab.c (symbol_user_token_number_set): Don't complain when X-Git-Tag: BISON-1_49b~198 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/5e424082ced49dcbe89b76aed509161b4e914cee * 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. --- diff --git a/ChangeLog b/ChangeLog index 77ce89f5..d50b1e87 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2002-06-10 Akim Demaille + + * 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 * src/symtab.c, src/symtab.c (symbol_class_set) diff --git a/src/lex.c b/src/lex.c index d43403ce..62afbee5 100644 --- a/src/lex.c +++ b/src/lex.c @@ -1,5 +1,6 @@ /* 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. @@ -364,13 +365,8 @@ lex (void) 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; } @@ -378,7 +374,7 @@ lex (void) /* 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 ". */ @@ -392,12 +388,7 @@ lex (void) 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; } diff --git a/src/reader.c b/src/reader.c index 5587c32a..f2bc42e7 100644 --- a/src/reader.c +++ b/src/reader.c @@ -656,13 +656,7 @@ parse_assoc_decl (associativity assoc) 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); @@ -671,7 +665,7 @@ parse_assoc_decl (associativity assoc) case tok_number: if (prev == tok_identifier) { - symval->user_token_number = numval; + symbol_user_token_number_set (symval, numval); } else { diff --git a/src/symtab.c b/src/symtab.c index c921133d..1c45965e 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -115,7 +115,8 @@ symbol_user_token_number_set (symbol_t *symbol, int user_token_number) { 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;