]> git.saurik.com Git - bison.git/blobdiff - src/reader.c
More.
[bison.git] / src / reader.c
index c8d90ec40d52ee5f9d82bafd4515f003098e5344..f76f5c8487a0fbe25636831d0689bf9f3305aed9 100644 (file)
@@ -237,7 +237,7 @@ symbol_translation (symbol_t *this)
       && this->user_token_number != SALIAS)
     {
       /* A token which translation has already been set? */
       && 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);
        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;
        /* start a new rule and record its lhs.  */
 
        ++nrules;
-       ++nitems;
+       ++nritems;
 
        p = symbol_list_new (lhs);
 
 
        p = symbol_list_new (lhs);
 
@@ -1511,7 +1511,7 @@ readgram (void)
                   current one, so that the action just read can
                   belong to it.  */
                ++nrules;
                   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;
                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.  */
 
                /* Insert the dummy generated by that rule into this
                   rule.  */
-               ++nitems;
+               ++nritems;
                p = symbol_list_new (sdummy);
                p1->next = p;
                p1 = p;
                p = symbol_list_new (sdummy);
                p1->next = p;
                p1 = p;
@@ -1542,7 +1542,7 @@ readgram (void)
 
            if (t == tok_identifier)
              {
 
            if (t == tok_identifier)
              {
-               ++nitems;
+               ++nritems;
                p = symbol_list_new (symval);
                p1->next = p;
                p1 = p;
                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;
   p->next->next->next = symbol_list_new (NULL);
   p->next->next->next->next = grammar;
   nrules += 1;
-  nitems += 3;
+  nritems += 3;
   grammar = p;
   startval = axiom;
 
   grammar = p;
   startval = axiom;
 
-  if (nsyms > MAXSHORT)
+  if (nsyms > SHRT_MAX)
     fatal (_("too many symbols (tokens plus nonterminals); maximum %d"),
     fatal (_("too many symbols (tokens plus nonterminals); maximum %d"),
-          MAXSHORT);
+          SHRT_MAX);
 
   assert (nsyms == ntokens + nvars);
 }
 
   assert (nsyms == ntokens + nvars);
 }
@@ -1691,13 +1691,13 @@ token_translations_init (void)
        max_user_token_number = this->user_token_number;
     }
 
        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++)
 
   /* 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);
 }
 
   symbols_do (symbol_translation, NULL);
 }
@@ -1718,8 +1718,6 @@ packsymbols (void)
 
   token_translations_init ();
 
 
   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)
   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;
 
   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;
   rules = XCALLOC (rule_t, nrules) - 1;
 
   itemno = 0;
@@ -1793,8 +1787,7 @@ packgram (void)
     }
 
   ritem[itemno] = 0;
     }
 
   ritem[itemno] = 0;
-  nritems = itemno;
-  assert (nritems == nitems);
+  assert (itemno == nritems);
 
   if (trace_flag)
     ritem_print (stderr);
 
   if (trace_flag)
     ritem_print (stderr);
@@ -1836,7 +1829,6 @@ reader (void)
   undeftoken = getsym ("$undefined.");
   undeftoken->class = token_sym;
   undeftoken->number = ntokens++;
   undeftoken = getsym ("$undefined.");
   undeftoken->class = token_sym;
   undeftoken->number = ntokens++;
-  undeftoken->user_token_number = 2;
 
   /* Initialize the obstacks. */
   obstack_init (&action_obstack);
 
   /* Initialize the obstacks. */
   obstack_init (&action_obstack);