* src/output.c, src/reader.c, src/symtab.c, src/symtab.h: Rename

bucket.value as bucket.number.
This commit is contained in:
Akim Demaille
2002-04-07 15:29:56 +00:00
parent 9901390012
commit d9b739c32f
5 changed files with 31 additions and 25 deletions

View File

@@ -1,3 +1,9 @@
2002-04-07 Akim Demaille <akim@epita.fr>
* src/output.c, src/reader.c, src/symtab.c, src/symtab.h: Rename
bucket.value as bucket.number.
2002-04-07 Akim Demaille <akim@epita.fr> 2002-04-07 Akim Demaille <akim@epita.fr>
* src/closure.c, src/derives.c, src/gram.h, src/lalr.c, * src/closure.c, src/derives.c, src/gram.h, src/lalr.c,

View File

@@ -577,7 +577,7 @@ token_definitions_output (FILE *out)
if (number == SALIAS) if (number == SALIAS)
continue; continue;
/* Skip error token. */ /* Skip error token. */
if (symbol->value == error_token_number) if (symbol->number == error_token_number)
continue; continue;
if (symbol->tag[0] == '\'') if (symbol->tag[0] == '\'')
continue; /* skip literal character */ continue; /* skip literal character */
@@ -600,7 +600,7 @@ token_definitions_output (FILE *out)
if (semantic_parser) if (semantic_parser)
/* FIXME: This is probably wrong, and should be just as /* FIXME: This is probably wrong, and should be just as
above. --akim. */ above. --akim. */
fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->value); fprintf (out, "# define T%s\t%d\n", symbol->tag, symbol->number);
first = 0; first = 0;
} }
} }

View File

@@ -559,7 +559,7 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
complain (_("symbol %s redefined"), symbol->tag); complain (_("symbol %s redefined"), symbol->tag);
symbol->class = what_is; symbol->class = what_is;
if (what_is == nterm_sym && oldclass != nterm_sym) if (what_is == nterm_sym && oldclass != nterm_sym)
symbol->value = nvars++; symbol->number = nvars++;
if (typename) if (typename)
{ {
@@ -1202,7 +1202,7 @@ gensym (void)
token_buffer = buf; token_buffer = buf;
sym = getsym (token_buffer); sym = getsym (token_buffer);
sym->class = nterm_sym; sym->class = nterm_sym;
sym->value = nvars++; sym->number = nvars++;
return sym; return sym;
} }
@@ -1294,7 +1294,7 @@ readgram (void)
if (lhs->class == unknown_sym) if (lhs->class == unknown_sym)
{ {
lhs->class = nterm_sym; lhs->class = nterm_sym;
lhs->value = nvars; lhs->number = nvars;
nvars++; nvars++;
} }
else if (lhs->class == token_sym) else if (lhs->class == token_sym)
@@ -1471,7 +1471,7 @@ readgram (void)
("symbol %s is used, but is not defined as a token and has no rules"), ("symbol %s is used, but is not defined as a token and has no rules"),
bp->tag); bp->tag);
bp->class = nterm_sym; bp->class = nterm_sym;
bp->value = nvars++; bp->number = nvars++;
} }
/* Insert the initial rule, which line is that of the first rule /* Insert the initial rule, which line is that of the first rule
@@ -1544,7 +1544,7 @@ token_translations_init (void)
for (bp = firstsymbol; bp; bp = bp->next) for (bp = firstsymbol; bp; bp = bp->next)
{ {
/* Non-terminal? */ /* Non-terminal? */
if (bp->value >= ntokens) if (bp->number >= ntokens)
continue; continue;
/* A token string alias? */ /* A token string alias? */
if (bp->user_token_number == SALIAS) if (bp->user_token_number == SALIAS)
@@ -1557,7 +1557,7 @@ token_translations_init (void)
complain (_("tokens %s and %s both assigned number %d"), complain (_("tokens %s and %s both assigned number %d"),
symbols[token_translations[bp->user_token_number]]->tag, symbols[token_translations[bp->user_token_number]]->tag,
bp->tag, bp->user_token_number); bp->tag, bp->user_token_number);
token_translations[bp->user_token_number] = bp->value; token_translations[bp->user_token_number] = bp->number;
} }
} }
@@ -1583,20 +1583,20 @@ packsymbols (void)
{ {
if (bp->class == nterm_sym) if (bp->class == nterm_sym)
{ {
bp->value += ntokens; bp->number += ntokens;
} }
else if (bp->alias) else if (bp->alias)
{ {
/* This symbol and its alias are a single token defn. /* This symbol and its alias are a single token defn.
Allocate a tokno, and assign to both check agreement of Allocate a tokno, and assign to both check agreement of
prec and assoc fields and make both the same */ prec and assoc fields and make both the same */
if (bp->value == -1) if (bp->number == -1)
{ {
if (bp == eoftoken || bp->alias == eoftoken) if (bp == eoftoken || bp->alias == eoftoken)
bp->value = bp->alias->value = 0; bp->number = bp->alias->number = 0;
else else
{ {
bp->value = bp->alias->value = tokno++; bp->number = bp->alias->number = tokno++;
} }
} }
@@ -1632,9 +1632,9 @@ packsymbols (void)
else /* bp->class == token_sym */ else /* bp->class == token_sym */
{ {
if (bp == eoftoken) if (bp == eoftoken)
bp->value = 0; bp->number = 0;
else else
bp->value = tokno++; bp->number = tokno++;
} }
if (bp->class == token_sym) if (bp->class == token_sym)
@@ -1645,25 +1645,25 @@ packsymbols (void)
max_user_token_number = bp->user_token_number; max_user_token_number = bp->user_token_number;
} }
symbols[bp->value] = bp; symbols[bp->number] = bp;
} }
token_translations_init (); token_translations_init ();
error_token_number = errtoken->value; error_token_number = errtoken->number;
if (startval->class == unknown_sym) if (startval->class == unknown_sym)
fatal (_("the start symbol %s is undefined"), startval->tag); fatal (_("the start symbol %s is undefined"), startval->tag);
else if (startval->class == token_sym) else if (startval->class == token_sym)
fatal (_("the start symbol %s is a token"), startval->tag); fatal (_("the start symbol %s is a token"), startval->tag);
start_symbol = startval->value; start_symbol = startval->number;
} }
/*---------------------------------------------------------------. /*---------------------------------------------------------------.
| Convert the rules into the representation using RRHS, RLHS and | | Convert the rules into the representation using RRHS, RLHS and |
| RITEMS. | | RITEM. |
`---------------------------------------------------------------*/ `---------------------------------------------------------------*/
static void static void
@@ -1687,7 +1687,7 @@ packgram (void)
while (p) while (p)
{ {
bucket *ruleprec = p->ruleprec; bucket *ruleprec = p->ruleprec;
rules[ruleno].lhs = p->sym->value; rules[ruleno].lhs = p->sym->number;
rules[ruleno].rhs = ritem + itemno; rules[ruleno].rhs = ritem + itemno;
rules[ruleno].line = p->line; rules[ruleno].line = p->line;
rules[ruleno].useful = TRUE; rules[ruleno].useful = TRUE;
@@ -1699,7 +1699,7 @@ packgram (void)
p = p->next; p = p->next;
while (p && p->sym) while (p && p->sym)
{ {
ritem[itemno++] = p->sym->value; ritem[itemno++] = p->sym->number;
/* A rule gets by default the precedence and associativity /* A rule gets by default the precedence and associativity
of the last token in it. */ of the last token in it. */
if (p->sym->class == token_sym) if (p->sym->class == token_sym)
@@ -1717,7 +1717,7 @@ packgram (void)
{ {
rules[ruleno].prec = ruleprec->prec; rules[ruleno].prec = ruleprec->prec;
rules[ruleno].assoc = ruleprec->assoc; rules[ruleno].assoc = ruleprec->assoc;
rules[ruleno].precsym = ruleprec->value; rules[ruleno].precsym = ruleprec->number;
} }
ritem[itemno++] = -ruleno; ritem[itemno++] = -ruleno;
@@ -1774,7 +1774,7 @@ reader (void)
/* Construct the axiom symbol. */ /* Construct the axiom symbol. */
axiom = getsym ("$axiom"); axiom = getsym ("$axiom");
axiom->class = nterm_sym; axiom->class = nterm_sym;
axiom->value = nvars++; axiom->number = nvars++;
/* Construct the error token */ /* Construct the error token */
errtoken = getsym ("error"); errtoken = getsym ("error");

View File

@@ -1,5 +1,5 @@
/* Symbol table manager for Bison, /* Symbol table manager for Bison,
Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc. Copyright 1984, 1989, 2000, 2001, 2002 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -55,7 +55,7 @@ bucket_new (const char *tag, int hashval)
res->next = NULL; res->next = NULL;
res->tag = xstrdup (tag); res->tag = xstrdup (tag);
res->type_name = NULL; res->type_name = NULL;
res->value = -1; res->number = -1;
res->prec = 0; res->prec = 0;
res->assoc = right_assoc; res->assoc = right_assoc;
res->user_token_number = SUNDEF; res->user_token_number = SUNDEF;

View File

@@ -46,7 +46,7 @@ typedef struct bucket
char *tag; char *tag;
/* Its type. */ /* Its type. */
char *type_name; char *type_name;
short value; short number;
short prec; short prec;
associativity assoc; associativity assoc;
short user_token_number; short user_token_number;