mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-17 08:13:02 +00:00
* src/symtab.h (SALIAS, SUNDEF): Rename as...
(USER_NUMBER_ALIAS, USER_NUMBER_UNDEFINED): these. Adjust dependencies. * src/output.c (token_definitions_output): Be sure not to output a `#define 'a'' when fed with `%token 'a' "a"'. * tests/regression.at (Token definitions): New.
This commit is contained in:
29
src/output.c
29
src/output.c
@@ -582,21 +582,25 @@ token_definitions_output (FILE *out)
|
||||
symbol_t *symbol = symbols[i];
|
||||
int number = symbol->user_token_number;
|
||||
|
||||
if (number == SALIAS)
|
||||
continue;
|
||||
/* At this stage, if there are literal aliases, they are part of
|
||||
SYMBOLS, so we should not find symbols which are the aliases
|
||||
here. */
|
||||
assert (number != USER_NUMBER_ALIAS);
|
||||
|
||||
/* Skip error token. */
|
||||
if (symbol == errtoken)
|
||||
continue;
|
||||
if (symbol->tag[0] == '\'')
|
||||
continue; /* skip literal character */
|
||||
if (symbol->tag[0] == '\"')
|
||||
{
|
||||
/* use literal string only if given a symbol with an alias */
|
||||
if (symbol->alias)
|
||||
symbol = symbol->alias;
|
||||
else
|
||||
continue;
|
||||
}
|
||||
|
||||
/* If this string has an alias, then it is necessarily the alias
|
||||
which is to be output. */
|
||||
if (symbol->alias)
|
||||
symbol = symbol->alias;
|
||||
|
||||
/* Don't output literal chars or strings (when defined only as a
|
||||
string). Note that must be done after the alias resolution:
|
||||
think about `%token 'f' "f"'. */
|
||||
if (symbol->tag[0] == '\'' || symbol->tag[0] == '\"')
|
||||
continue;
|
||||
|
||||
/* Don't #define nonliteral tokens whose names contain periods
|
||||
or '$' (as does the default value of the EOF token). */
|
||||
@@ -605,6 +609,7 @@ token_definitions_output (FILE *out)
|
||||
|
||||
fprintf (out, "%s[[[%s]], [%d]]",
|
||||
first ? "" : ",\n", symbol->tag, number);
|
||||
|
||||
first = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user