X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/24985964740b3b28ebfa2fe1de05c0e483947fbf..847480ae0f5f105ae86d8990729916c589427552:/src/symtab.c diff --git a/src/symtab.c b/src/symtab.c index 7d18f92d..f065c80d 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -1,8 +1,7 @@ /* Symbol table manager for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006, 2007, - 2008, 2009 - Free Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000-2002, 2004-2011 Free Software + Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -69,7 +68,7 @@ symbol_new (uniqstr tag, location loc) /* If the tag is not a string (starts with a double quote), check that it is valid for Yacc. */ - if (tag[0] != '\"' && tag[0] != '\'' && strchr (tag, '-')) + if (tag[0] != '\"' && tag[0] != '\'' && mbschr (tag, '-')) yacc_at (loc, _("POSIX Yacc forbids dashes in symbol names: %s"), tag); @@ -184,24 +183,6 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc) } } -/*-----------------------------------. -| Get the CLASS associated with SYM. | -`-----------------------------------*/ - -const char * -symbol_class_get_string (symbol *sym) -{ - if (sym->class) - { - if (sym->class == token_sym) - return "terminal"; - else if (sym->class == nterm_sym) - return "nonterminal"; - } - return "unknown"; -} - - /*-----------------------------------------. | Set the DESTRUCTOR associated with SYM. | `-----------------------------------------*/ @@ -387,10 +368,11 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) if (user_token_number == 0) { endtoken = sym; - endtoken->number = 0; /* It is always mapped to 0, so it was already counted in NTOKENS. */ - --ntokens; + if (endtoken->number != NUMBER_UNDEFINED) + --ntokens; + endtoken->number = 0; } } @@ -454,7 +436,7 @@ static inline void symbol_check_alias_consistency (symbol *this) { symbol *sym = this; - symbol *str = this->alias; + symbol *str = this->alias; /* Check only the symbol in the symbol-string pair. */ if (!(this->alias @@ -514,31 +496,11 @@ symbol_check_alias_consistency_processor (void *this, static inline bool symbol_pack (symbol *this) { + aver (this->number != NUMBER_UNDEFINED); if (this->class == nterm_sym) - { - this->number += ntokens; - } - else if (this->alias) - { - /* This symbol and its alias are a single token defn. - Allocate a tokno, and assign to both check agreement of - prec and assoc fields and make both the same */ - if (this->number == NUMBER_UNDEFINED) - { - if (this == endtoken || this->alias == endtoken) - this->number = this->alias->number = 0; - else - { - aver (this->alias->number != NUMBER_UNDEFINED); - this->number = this->alias->number; - } - } - /* Do not do processing below for USER_NUMBER_HAS_STRING_ALIASes. */ - if (this->user_token_number == USER_NUMBER_HAS_STRING_ALIAS) - return true; - } - else /* this->class == token_sym */ - aver (this->number != NUMBER_UNDEFINED); + this->number += ntokens; + else if (this->user_token_number == USER_NUMBER_HAS_STRING_ALIAS) + return true; symbols[this->number] = this; return true;