bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

code cleanup in parser table construction


From: Joel E. Denny
Subject: code cleanup in parser table construction
Date: Sun, 6 May 2007 22:28:46 -0400 (EDT)

I committed this.

Index: ChangeLog
===================================================================
RCS file: /sources/bison/bison/ChangeLog,v
retrieving revision 1.1695
diff -p -u -r1.1695 ChangeLog
--- ChangeLog   4 Apr 2007 22:41:58 -0000       1.1695
+++ ChangeLog   7 May 2007 02:23:45 -0000
@@ -1,3 +1,19 @@
+2007-05-06  Joel E. Denny  <address@hidden>
+
+       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  <address@hidden>
 
        * THANKS: Use ASCII for Sebastien Fricker's name.  Bison source
Index: src/LR0.c
===================================================================
RCS file: /sources/bison/bison/src/LR0.c,v
retrieving revision 1.96
diff -p -u -r1.96 LR0.c
--- src/LR0.c   15 Sep 2006 16:34:47 -0000      1.96
+++ src/LR0.c   7 May 2007 02:23:45 -0000
@@ -183,8 +183,8 @@ new_itemsets (state *s)
 
   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])
@@ -272,7 +272,7 @@ save_reductions (state *s)
   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))
Index: src/closure.c
===================================================================
RCS file: /sources/bison/bison/src/closure.c,v
retrieving revision 1.74
diff -p -u -r1.74 closure.c
--- src/closure.c       9 Dec 2005 23:51:25 -0000       1.74
+++ src/closure.c       7 May 2007 02:23:45 -0000
@@ -37,7 +37,7 @@
 
 /* NITEMSET is the size of the array ITEMSET.  */
 item_number *itemset;
-size_t nritemset;
+size_t nitemset;
 
 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]]));
 
-  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)
        {
-         itemset[nritemset] = core[c];
-         nritemset++;
+         itemset[nitemset] = core[c];
+         nitemset++;
          c++;
        }
-      itemset[nritemset] = itemno;
-      nritemset++;
+      itemset[nitemset] = itemno;
+      nitemset++;
     };
 
   while (c < n)
     {
-      itemset[nritemset] = core[c];
-      nritemset++;
+      itemset[nitemset] = core[c];
+      nitemset++;
       c++;
     }
 
   if (trace_flag & trace_sets)
-    print_closure ("output", itemset, nritemset);
+    print_closure ("output", itemset, nitemset);
 }
 
 
Index: src/closure.h
===================================================================
RCS file: /sources/bison/bison/src/closure.h,v
retrieving revision 1.14
diff -p -u -r1.14 closure.h
--- src/closure.h       14 May 2005 06:49:47 -0000      1.14
+++ src/closure.h       7 May 2007 02:23:45 -0000
@@ -54,6 +54,6 @@ void closure (item_number *items, size_t
 void free_closure (void);
 
 extern item_number *itemset;
-extern size_t nritemset;
+extern size_t nitemset;
 
 #endif /* !CLOSURE_H_ */
Index: src/lalr.c
===================================================================
RCS file: /sources/bison/bison/src/lalr.c,v
retrieving revision 1.110
diff -p -u -r1.110 lalr.c
--- src/lalr.c  15 Sep 2006 16:34:48 -0000      1.110
+++ src/lalr.c  7 May 2007 02:23:45 -0000
@@ -56,7 +56,7 @@ typedef struct 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.  */
Index: src/print.c
===================================================================
RCS file: /sources/bison/bison/src/print.c,v
retrieving revision 1.100
diff -p -u -r1.100 print.c
--- src/print.c 1 Mar 2007 03:40:18 -0000       1.100
+++ src/print.c 7 May 2007 02:23:45 -0000
@@ -81,7 +81,7 @@ print_core (FILE *out, state *s)
     {
       closure (sitems, snritems);
       sitems = itemset;
-      snritems = nritemset;
+      snritems = nitemset;
     }
 
   if (!snritems)
Index: src/print_graph.c
===================================================================
RCS file: /sources/bison/bison/src/print_graph.c,v
retrieving revision 1.62
diff -p -u -r1.62 print_graph.c
--- src/print_graph.c   12 Oct 2006 23:29:52 -0000      1.62
+++ src/print_graph.c   7 May 2007 02:23:45 -0000
@@ -56,7 +56,7 @@ print_core (struct obstack *oout, state 
     {
       closure (sitems, snritems);
       sitems = itemset;
-      snritems = nritemset;
+      snritems = nitemset;
     }
 
   obstack_fgrow1 (oout, "%d", s->number);
Index: src/state.h
===================================================================
RCS file: /sources/bison/bison/src/state.h,v
retrieving revision 1.50
diff -p -u -r1.50 state.h
--- src/state.h 10 Jun 2006 03:02:23 -0000      1.50
+++ src/state.h 7 May 2007 02:23:45 -0000
@@ -44,7 +44,7 @@
    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
@@ -63,9 +63,8 @@
    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).




reply via email to

[Prev in Thread] Current Thread [Next in Thread]