X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f3849179e5cd37eeae22a2f149275322b44efe59..20c37f213a14c112251907734402cbf80f44d780:/src/reader.c diff --git a/src/reader.c b/src/reader.c index c8d90ec4..f76f5c84 100644 --- a/src/reader.c +++ b/src/reader.c @@ -237,7 +237,7 @@ symbol_translation (symbol_t *this) && this->user_token_number != SALIAS) { /* A token which translation has already been set? */ - if (token_translations[this->user_token_number] != 2) + if (token_translations[this->user_token_number] != undeftoken->number) complain (_("tokens %s and %s both assigned number %d"), symbols[token_translations[this->user_token_number]]->tag, this->tag, this->user_token_number); @@ -1433,7 +1433,7 @@ readgram (void) /* start a new rule and record its lhs. */ ++nrules; - ++nitems; + ++nritems; p = symbol_list_new (lhs); @@ -1511,7 +1511,7 @@ readgram (void) current one, so that the action just read can belong to it. */ ++nrules; - ++nitems; + ++nritems; p = symbol_list_new (sdummy); /* Attach its lineno to that of the host rule. */ p->line = crule->line; @@ -1532,7 +1532,7 @@ readgram (void) /* Insert the dummy generated by that rule into this rule. */ - ++nitems; + ++nritems; p = symbol_list_new (sdummy); p1->next = p; p1 = p; @@ -1542,7 +1542,7 @@ readgram (void) if (t == tok_identifier) { - ++nitems; + ++nritems; p = symbol_list_new (symval); p1->next = p; p1 = p; @@ -1633,13 +1633,13 @@ readgram (void) p->next->next->next = symbol_list_new (NULL); p->next->next->next->next = grammar; nrules += 1; - nitems += 3; + nritems += 3; grammar = p; startval = axiom; - if (nsyms > MAXSHORT) + if (nsyms > SHRT_MAX) fatal (_("too many symbols (tokens plus nonterminals); maximum %d"), - MAXSHORT); + SHRT_MAX); assert (nsyms == ntokens + nvars); } @@ -1691,13 +1691,13 @@ token_translations_init (void) max_user_token_number = this->user_token_number; } - token_translations = XCALLOC (short, max_user_token_number + 1); + token_translations = XCALLOC (token_number_t, 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 (i = 0; i < max_user_token_number + 1; i++) - token_translations[i] = 2; + token_translations[i] = undeftoken->number; symbols_do (symbol_translation, NULL); } @@ -1718,8 +1718,6 @@ packsymbols (void) token_translations_init (); - error_token_number = errtoken->number; - if (startval->class == unknown_sym) fatal (_("the start symbol %s is undefined"), startval->tag); else if (startval->class == token_sym) @@ -1741,11 +1739,7 @@ packgram (void) int ruleno; symbol_list *p; - /* We use short to index items. */ - if (nitems >= MAXSHORT) - fatal (_("too many items (max %d)"), MAXSHORT); - - ritem = XCALLOC (short, nitems + 1); + ritem = XCALLOC (item_number_t, nritems + 1); rules = XCALLOC (rule_t, nrules) - 1; itemno = 0; @@ -1793,8 +1787,7 @@ packgram (void) } ritem[itemno] = 0; - nritems = itemno; - assert (nritems == nitems); + assert (itemno == nritems); if (trace_flag) ritem_print (stderr); @@ -1836,7 +1829,6 @@ reader (void) undeftoken = getsym ("$undefined."); undeftoken->class = token_sym; undeftoken->number = ntokens++; - undeftoken->user_token_number = 2; /* Initialize the obstacks. */ obstack_init (&action_obstack);