/* 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-2012 Free Software
+ Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
#include "system.h"
#include <hash.h>
-#include <quotearg.h>
#include "complain.h"
#include "gram.h"
/* 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);
}
}
-/*-----------------------------------.
-| 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. |
`-----------------------------------------*/
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;
}
}
symbol_make_alias (symbol *sym, symbol *str, location loc)
{
if (str->alias)
- warn_at (loc, _("symbol `%s' used more than once as a literal string"),
- str->tag);
+ warn_at (loc, _("symbol %s used more than once as a literal string"),
+ str->tag);
else if (sym->alias)
- warn_at (loc, _("symbol `%s' given more than one literal string"),
- sym->tag);
+ warn_at (loc, _("symbol %s given more than one literal string"),
+ sym->tag);
else
{
str->class = token_sym;
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