]> git.saurik.com Git - bison.git/commitdiff
Minor code cleanup in parser table construction.
authorJoel E. Denny <jdenny@ces.clemson.edu>
Mon, 7 May 2007 02:28:42 +0000 (02:28 +0000)
committerJoel E. Denny <jdenny@ces.clemson.edu>
Mon, 7 May 2007 02:28:42 +0000 (02:28 +0000)
* src/LR0.c (new_itemsets): Use item_number_is_symbol_number.
(new_itemsets, save_reductions): Update for rename to nitemset.
* src/closure.c (nritemset): Rename to...
(nitemset): ... this since the "r" appears to meaningless and isn't
used in the comments.
(closure): Update for rename.
* src/closure.h (nritemset): Update extern to...
(nitemset): ... this.
* src/lalr.c (LA): Fix a typo in comments.
* src/print.c (print_core): Update for rename to nitemset.
* src/print_graph.c (print_graph): Likewise.
* src/state.h: Fix some typos in header comments.

ChangeLog
src/LR0.c
src/closure.c
src/closure.h
src/lalr.c
src/print.c
src/print_graph.c
src/state.h

index 3b0b8647e57d61e26fa814d4b8626a3090d12ade..53361e3d2554d987365addc20afa6434b7e08f40 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2007-05-06  Joel E. Denny  <jdenny@ces.clemson.edu>
+
+       Minor code cleanup in parser table construction.
+       * src/LR0.c (new_itemsets): Use item_number_is_symbol_number.
+       (new_itemsets, save_reductions): Update for rename to nitemset.
+       * src/closure.c (nritemset): Rename to...
+       (nitemset): ... this since the "r" appears to meaningless and isn't
+       used in the comments.
+       (closure): Update for rename.
+       * src/closure.h (nritemset): Update extern to...
+       (nitemset): ... this.
+       * src/lalr.c (LA): Fix a typo in comments.
+       * src/print.c (print_core): Update for rename to nitemset.
+       * src/print_graph.c (print_graph): Likewise.
+       * src/state.h: Fix some typos in header comments.
+
 2007-04-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        * THANKS: Use ASCII for Sebastien Fricker's name.  Bison source
 2007-04-04  Paul Eggert  <eggert@cs.ucla.edu>
 
        * THANKS: Use ASCII for Sebastien Fricker's name.  Bison source
index 945d41f8e0e8fc8ac35a1deeb2ad7e769f779bbf..f94f5ec900a6758194f005ad56c0623c4e656854 100644 (file)
--- a/src/LR0.c
+++ b/src/LR0.c
@@ -183,8 +183,8 @@ new_itemsets (state *s)
 
   nshifts = 0;
 
 
   nshifts = 0;
 
-  for (i = 0; i < nritemset; ++i)
-    if (ritem[itemset[i]] >= 0)
+  for (i = 0; i < nitemset; ++i)
+    if (item_number_is_symbol_number (ritem[itemset[i]]))
       {
        symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
        if (!kernel_size[sym])
       {
        symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
        if (!kernel_size[sym])
@@ -272,7 +272,7 @@ save_reductions (state *s)
   size_t i;
 
   /* Find and count the active items that represent ends of rules. */
   size_t i;
 
   /* Find and count the active items that represent ends of rules. */
-  for (i = 0; i < nritemset; ++i)
+  for (i = 0; i < nitemset; ++i)
     {
       item_number item = ritem[itemset[i]];
       if (item_number_is_rule_number (item))
     {
       item_number item = ritem[itemset[i]];
       if (item_number_is_rule_number (item))
index 001b8316a735f32cec1fc698ecfbd9906908f441..a12e9622e51b83190947333924ebd4744913644b 100644 (file)
@@ -37,7 +37,7 @@
 
 /* NITEMSET is the size of the array ITEMSET.  */
 item_number *itemset;
 
 /* NITEMSET is the size of the array ITEMSET.  */
 item_number *itemset;
-size_t nritemset;
+size_t nitemset;
 
 static bitset ruleset;
 
 
 static bitset ruleset;
 
@@ -213,30 +213,30 @@ closure (item_number *core, size_t n)
     if (ISVAR (ritem[core[c]]))
       bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
 
     if (ISVAR (ritem[core[c]]))
       bitset_or (ruleset, ruleset, FDERIVES (ritem[core[c]]));
 
-  nritemset = 0;
+  nitemset = 0;
   c = 0;
   BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
     {
       item_number itemno = rules[ruleno].rhs - ritem;
       while (c < n && core[c] < itemno)
        {
   c = 0;
   BITSET_FOR_EACH (iter, ruleset, ruleno, 0)
     {
       item_number itemno = rules[ruleno].rhs - ritem;
       while (c < n && core[c] < itemno)
        {
-         itemset[nritemset] = core[c];
-         nritemset++;
+         itemset[nitemset] = core[c];
+         nitemset++;
          c++;
        }
          c++;
        }
-      itemset[nritemset] = itemno;
-      nritemset++;
+      itemset[nitemset] = itemno;
+      nitemset++;
     };
 
   while (c < n)
     {
     };
 
   while (c < n)
     {
-      itemset[nritemset] = core[c];
-      nritemset++;
+      itemset[nitemset] = core[c];
+      nitemset++;
       c++;
     }
 
   if (trace_flag & trace_sets)
       c++;
     }
 
   if (trace_flag & trace_sets)
-    print_closure ("output", itemset, nritemset);
+    print_closure ("output", itemset, nitemset);
 }
 
 
 }
 
 
index a2582e89467cccfcf21b2ff49befbcb9710e52fe..c170e645a82f573635c0024f2e1914952fe0dcf5 100644 (file)
@@ -54,6 +54,6 @@ void closure (item_number *items, size_t n);
 void free_closure (void);
 
 extern item_number *itemset;
 void free_closure (void);
 
 extern item_number *itemset;
-extern size_t nritemset;
+extern size_t nitemset;
 
 #endif /* !CLOSURE_H_ */
 
 #endif /* !CLOSURE_H_ */
index f2bfa96738f2b4e5b1dcce61486bc4381c779064..805797cf334b7299ab65e7c7c4d84e053f2e9bfc 100644 (file)
@@ -56,7 +56,7 @@ typedef struct goto_list
 } goto_list;
 
 
 } goto_list;
 
 
-/* LA is a LR by NTOKENS matrix of bits.  LA[l, i] is 1 if the rule
+/* LA is an NLA by NTOKENS matrix of bits.  LA[l, i] is 1 if the rule
    LArule[l] is applicable in the appropriate state when the next
    token is symbol i.  If LA[l, i] and LA[l, j] are both 1 for i != j,
    it is a conflict.  */
    LArule[l] is applicable in the appropriate state when the next
    token is symbol i.  If LA[l, i] and LA[l, j] are both 1 for i != j,
    it is a conflict.  */
index 08feaafbcc543b2b2a42e9193a012ea7fad7249e..3fecc2a71ea1592253e4d3271a4d8241ce202a5e 100644 (file)
@@ -81,7 +81,7 @@ print_core (FILE *out, state *s)
     {
       closure (sitems, snritems);
       sitems = itemset;
     {
       closure (sitems, snritems);
       sitems = itemset;
-      snritems = nritemset;
+      snritems = nitemset;
     }
 
   if (!snritems)
     }
 
   if (!snritems)
index aba6902831e155eae002a17143ba3cfedbd6035d..8898c9aaa56ba06a798b9b7930e9a71a019a3f7d 100644 (file)
@@ -56,7 +56,7 @@ print_core (struct obstack *oout, state *s)
     {
       closure (sitems, snritems);
       sitems = itemset;
     {
       closure (sitems, snritems);
       sitems = itemset;
-      snritems = nritemset;
+      snritems = nitemset;
     }
 
   obstack_fgrow1 (oout, "%d", s->number);
     }
 
   obstack_fgrow1 (oout, "%d", s->number);
index a2ae217fa460d0a731f80d7fbcbd9d2525a8127d..28933e132395c70b0ee9a8dedcc46c81a21c815b 100644 (file)
@@ -44,7 +44,7 @@
    ACCESSING_SYMBOL of the core.
 
    Each core contains a vector of NITEMS items which are the indices
    ACCESSING_SYMBOL of the core.
 
    Each core contains a vector of NITEMS items which are the indices
-   in the RITEMS vector of the items that are selected in this state.
+   in the RITEM vector of the items that are selected in this state.
 
    The two types of actions are shifts/gotos (push the lookahead token
    and read another/goto to the state designated by a nterm) and
 
    The two types of actions are shifts/gotos (push the lookahead token
    and read another/goto to the state designated by a nterm) and
@@ -63,9 +63,8 @@
    deletes transitions by having them point to zero.
 
    Each reductions structure describes the possible reductions at the
    deletes transitions by having them point to zero.
 
    Each reductions structure describes the possible reductions at the
-   state whose number is in the number field.  The data is a list of
-   nreds rules, represented by their rule numbers.  first_reduction
-   points to the list of these structures.
+   state whose number is in the number field.  rules is an array of
+   num rules.  lookahead_tokens is an array of bitsets, one per rule.
 
    Conflict resolution can decide that certain tokens in certain
    states should explicitly be errors (for implementing %nonassoc).
 
    Conflict resolution can decide that certain tokens in certain
    states should explicitly be errors (for implementing %nonassoc).