mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 21:03:04 +00:00
Remove `translations' as it is always set to true.
* src/gram.h: Adjust. * src/reader.c (packsymbols, parse_token_decl): Adjust * src/print.c (print_grammar): Adjust. * src/output.c (output_token_translations): Adjust. * src/lex.c (lex): Adjust. * src/gram.c: Be sure the set pointers to NULL. (dummy): Rename as... (gram_free): this.
This commit is contained in:
28
src/gram.c
28
src/gram.c
@@ -31,21 +31,19 @@ int nsyms;
|
||||
int ntokens;
|
||||
int nvars;
|
||||
|
||||
short *ritem;
|
||||
short *rlhs;
|
||||
short *rrhs;
|
||||
short *rprec;
|
||||
short *rprecsym;
|
||||
short *sprec;
|
||||
short *rassoc;
|
||||
short *sassoc;
|
||||
short *token_translations;
|
||||
short *rline;
|
||||
short *ritem = NULL;
|
||||
short *rlhs = NULL;
|
||||
short *rrhs = NULL;
|
||||
short *rprec = NULL;
|
||||
short *rprecsym = NULL;
|
||||
short *sprec = NULL;
|
||||
short *rassoc = NULL;
|
||||
short *sassoc = NULL;
|
||||
short *token_translations = NULL;
|
||||
short *rline = NULL;
|
||||
|
||||
int start_symbol;
|
||||
|
||||
int translations;
|
||||
|
||||
int max_user_token_number;
|
||||
|
||||
int semantic_parser;
|
||||
@@ -54,10 +52,10 @@ int pure_parser;
|
||||
|
||||
int error_token_number;
|
||||
|
||||
/* This is to avoid linker problems which occur on VMS when using GCC,
|
||||
when the file in question contains data definitions only. */
|
||||
/* Free all the memory associated to these pointers. */
|
||||
|
||||
void
|
||||
dummy (void)
|
||||
gram_free (void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -107,13 +107,9 @@ typedef enum
|
||||
|
||||
/* token translation table: indexed by a token number as returned by
|
||||
the user's yylex routine, it yields the internal token number used
|
||||
by the parser and throughout bison. If translations is zero, the
|
||||
translation table is not used because the two kinds of token
|
||||
numbers are the same. (It is noted in reader.c that "Nowadays
|
||||
translations is always set to 1...") */
|
||||
by the parser and throughout bison. */
|
||||
|
||||
extern short *token_translations;
|
||||
extern int translations;
|
||||
extern int max_user_token_number;
|
||||
|
||||
/* SEMANTIC_PARSER is nonzero if the input file says to use the hairy
|
||||
|
||||
@@ -419,7 +419,6 @@ lex (void)
|
||||
case '\'':
|
||||
/* parse the literal token and compute character code in code */
|
||||
|
||||
translations = -1;
|
||||
{
|
||||
int code, discode;
|
||||
|
||||
@@ -447,7 +446,6 @@ lex (void)
|
||||
case '\"':
|
||||
/* parse the literal string token and treat as an identifier */
|
||||
|
||||
translations = -1;
|
||||
{
|
||||
int code; /* ignored here */
|
||||
|
||||
|
||||
20
src/output.c
20
src/output.c
@@ -295,25 +295,17 @@ output_token_translations (void)
|
||||
\n\
|
||||
/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */\n");
|
||||
|
||||
if (translations)
|
||||
{
|
||||
obstack_fgrow2 (&table_obstack,
|
||||
obstack_fgrow2 (&table_obstack,
|
||||
"#define YYTRANSLATE(x) ((unsigned)(x) <= %d ? yytranslate[x] : %d)\
|
||||
\n\
|
||||
\n",
|
||||
max_user_token_number, nsyms);
|
||||
max_user_token_number, nsyms);
|
||||
|
||||
output_short_or_char_table (&table_obstack,
|
||||
output_short_or_char_table (&table_obstack,
|
||||
"YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX",
|
||||
ntokens < 127 ? "char" : "short",
|
||||
"yytranslate", token_translations,
|
||||
0, 1, max_user_token_number + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
obstack_sgrow (&table_obstack,
|
||||
"\n#define YYTRANSLATE(x) (x)\n");
|
||||
}
|
||||
ntokens < 127 ? "char" : "short",
|
||||
"yytranslate", token_translations,
|
||||
0, 1, max_user_token_number + 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
59
src/print.c
59
src/print.c
@@ -253,49 +253,26 @@ print_grammar (void)
|
||||
_("Terminals, with rules where they appear"));
|
||||
obstack_sgrow (&output_obstack, "\n\n");
|
||||
obstack_fgrow1 (&output_obstack, "%s (-1)\n", tags[0]);
|
||||
if (translations)
|
||||
{
|
||||
for (i = 0; i <= max_user_token_number; i++)
|
||||
if (token_translations[i] != 2)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
column = strlen (tags[token_translations[i]]);
|
||||
obstack_sgrow (&output_obstack, tags[token_translations[i]]);
|
||||
END_TEST (50);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
|
||||
if (*rule == token_translations[i])
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), " %d", j);
|
||||
break;
|
||||
}
|
||||
obstack_fgrow1 (&output_obstack, "%s\n", buffer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 1; i < ntokens; i++)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
column = strlen (tags[i]);
|
||||
obstack_sgrow (&output_obstack, tags[i]);
|
||||
END_TEST (50);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
for (i = 0; i <= max_user_token_number; i++)
|
||||
if (token_translations[i] != 2)
|
||||
{
|
||||
buffer[0] = 0;
|
||||
column = strlen (tags[token_translations[i]]);
|
||||
obstack_sgrow (&output_obstack, tags[token_translations[i]]);
|
||||
END_TEST (50);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
|
||||
if (*rule == i)
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), " %d", j);
|
||||
break;
|
||||
}
|
||||
obstack_fgrow1 (&output_obstack, "%s\n", buffer);
|
||||
}
|
||||
}
|
||||
for (j = 1; j <= nrules; j++)
|
||||
for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
|
||||
if (*rule == token_translations[i])
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), " %d", j);
|
||||
break;
|
||||
}
|
||||
obstack_fgrow1 (&output_obstack, "%s\n", buffer);
|
||||
}
|
||||
|
||||
obstack_sgrow (&output_obstack, "\n");
|
||||
obstack_sgrow (&output_obstack,
|
||||
|
||||
69
src/reader.c
69
src/reader.c
@@ -512,7 +512,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
|
||||
/* symbol and symval combined are only one symbol */
|
||||
nsyms--;
|
||||
}
|
||||
translations = 1;
|
||||
symbol = NULL;
|
||||
}
|
||||
else if (token == tok_identifier)
|
||||
@@ -537,7 +536,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
|
||||
else if (symbol && token == tok_number)
|
||||
{
|
||||
symbol->user_token_number = numval;
|
||||
translations = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -679,7 +677,6 @@ parse_assoc_decl (associativity assoc)
|
||||
if (prev == tok_identifier)
|
||||
{
|
||||
symval->user_token_number = numval;
|
||||
translations = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -736,7 +733,7 @@ parse_union_decl (void)
|
||||
|
||||
while (c != EOF)
|
||||
{
|
||||
|
||||
|
||||
/* If C contains '/', it is output by copy_comment (). */
|
||||
if (c != '/')
|
||||
{
|
||||
@@ -744,7 +741,7 @@ parse_union_decl (void)
|
||||
if (defines_flag)
|
||||
obstack_1grow (&defines_obstack, c);
|
||||
}
|
||||
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case '\n':
|
||||
@@ -827,7 +824,6 @@ parse_thong_decl (void)
|
||||
char *typename = 0;
|
||||
int usrtoknum;
|
||||
|
||||
translations = 1;
|
||||
token = lex (); /* fetch typename or first token */
|
||||
if (token == tok_typename)
|
||||
{
|
||||
@@ -1657,9 +1653,10 @@ output_token_defines (struct obstack *oout)
|
||||
continue;
|
||||
|
||||
obstack_fgrow2 (oout, "# define\t%s\t%d\n",
|
||||
symbol,
|
||||
(translations ? bp->user_token_number : bp->value));
|
||||
symbol, bp->user_token_number);
|
||||
if (semantic_parser)
|
||||
/* FIXME: This is certainly dead wrong, and should be just as
|
||||
above. --akim. */
|
||||
obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);
|
||||
}
|
||||
|
||||
@@ -1676,9 +1673,9 @@ output_token_defines (struct obstack *oout)
|
||||
static void
|
||||
packsymbols (void)
|
||||
{
|
||||
bucket *bp;
|
||||
bucket *bp = NULL;
|
||||
int tokno = 1;
|
||||
int i;
|
||||
int i, j;
|
||||
int last_user_token_number;
|
||||
static char DOLLAR[] = "$";
|
||||
|
||||
@@ -1744,7 +1741,7 @@ packsymbols (void)
|
||||
|
||||
if (bp->class == token_sym)
|
||||
{
|
||||
if (translations && !(bp->user_token_number))
|
||||
if (!bp->user_token_number)
|
||||
bp->user_token_number = ++last_user_token_number;
|
||||
if (bp->user_token_number > max_user_token_number)
|
||||
max_user_token_number = bp->user_token_number;
|
||||
@@ -1757,30 +1754,25 @@ packsymbols (void)
|
||||
|
||||
}
|
||||
|
||||
if (translations)
|
||||
token_translations = XCALLOC (short, max_user_token_number + 1);
|
||||
|
||||
/* initialize all entries for literal tokens to 2, the internal
|
||||
token number for $undefined., which represents all invalid
|
||||
inputs. */
|
||||
for (j = 0; j <= max_user_token_number; j++)
|
||||
token_translations[j] = 2;
|
||||
|
||||
for (bp = firstsymbol; bp; bp = bp->next)
|
||||
{
|
||||
int j;
|
||||
|
||||
token_translations = XCALLOC (short, max_user_token_number + 1);
|
||||
|
||||
/* initialize all entries for literal tokens to 2, the internal
|
||||
token number for $undefined., which represents all invalid
|
||||
inputs. */
|
||||
for (j = 0; j <= max_user_token_number; j++)
|
||||
token_translations[j] = 2;
|
||||
|
||||
for (bp = firstsymbol; bp; bp = bp->next)
|
||||
{
|
||||
if (bp->value >= ntokens)
|
||||
continue; /* non-terminal */
|
||||
if (bp->user_token_number == SALIAS)
|
||||
continue;
|
||||
if (token_translations[bp->user_token_number] != 2)
|
||||
complain (_("tokens %s and %s both assigned number %d"),
|
||||
tags[token_translations[bp->user_token_number]],
|
||||
bp->tag, bp->user_token_number);
|
||||
token_translations[bp->user_token_number] = bp->value;
|
||||
}
|
||||
if (bp->value >= ntokens)
|
||||
continue; /* non-terminal */
|
||||
if (bp->user_token_number == SALIAS)
|
||||
continue;
|
||||
if (token_translations[bp->user_token_number] != 2)
|
||||
complain (_("tokens %s and %s both assigned number %d"),
|
||||
tags[token_translations[bp->user_token_number]],
|
||||
bp->tag, bp->user_token_number);
|
||||
token_translations[bp->user_token_number] = bp->value;
|
||||
}
|
||||
|
||||
error_token_number = errtoken->value;
|
||||
@@ -1906,15 +1898,6 @@ reader (void)
|
||||
start_flag = 0;
|
||||
startval = NULL; /* start symbol not specified yet. */
|
||||
|
||||
#if 0
|
||||
/* initially assume token number translation not needed. */
|
||||
translations = 0;
|
||||
#endif
|
||||
/* Nowadays translations is always set to 1, since we give `error' a
|
||||
user-token-number to satisfy the Posix demand for YYERRCODE==256.
|
||||
*/
|
||||
translations = 1;
|
||||
|
||||
nsyms = 1;
|
||||
nvars = 0;
|
||||
nrules = 0;
|
||||
|
||||
Reference in New Issue
Block a user