X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f16b08196c780556cbf50691e2944960aebc46f6..b3a28fd4e9759a31a71cce19f12a6fb49ebb0ff4:/src/symtab.c?ds=sidebyside diff --git a/src/symtab.c b/src/symtab.c index 83851351..13b75549 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -1,7 +1,7 @@ /* Symbol table manager for Bison. - Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free - Software Foundation, Inc. + Copyright (C) 1984, 1989, 2000, 2001, 2002, 2004, 2005, 2006, 2007, 2008 + Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -168,6 +168,23 @@ 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. | @@ -341,8 +358,6 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc) { int *user_token_numberp; - aver (sym->class == token_sym); - if (sym->user_token_number != USER_NUMBER_ALIAS) user_token_numberp = &sym->user_token_number; else @@ -821,9 +836,8 @@ symbols_token_translations_init (void) token_translations = xnmalloc (max_user_token_number + 1, sizeof *token_translations); - /* Initialize all entries for literal tokens to 2, the internal - token number for $undefined, which represents all invalid inputs. - */ + /* Initialize all entries for literal tokens to the internal token + number for $undefined, which represents all invalid inputs. */ for (i = 0; i < max_user_token_number + 1; i++) token_translations[i] = undeftoken->number; symbols_do (symbol_translation_processor, NULL);