bison-patches
[Top][All Lists]
Advanced

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

08-state-reduction-set.patch


From: Akim Demaille
Subject: 08-state-reduction-set.patch
Date: Sun, 30 Jun 2002 19:27:03 +0200

Index: ChangeLog
from  Akim Demaille  <address@hidden>
        * src/LR0.c (save_reductions): Remove, replaced by...
        * src/state.h, src/state.c (state_reductions_set): New.
        (reductions, errs): Rename as...
        (reductions_t, errs_t): these.
        Adjust all dependencies.
        
        
Index: src/LR0.c
--- src/LR0.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/LR0.c Sat, 29 Jun 2002 13:59:38 +0200 akim
@@ -94,7 +94,7 @@
   /* See comments before new_itemsets.  All the vectors of items
      live inside KERNEL_ITEMS.  The number of active items after
      some symbol cannot be more than the number of times that symbol
-     appears as an item, which is symbol_count[symbol].
+     appears as an item, which is SYMBOL_COUNT[SYMBOL].
      We allocate that much space for each symbol.  */
 
   kernel_base = XCALLOC (item_number_t *, nsyms);
@@ -313,8 +313,7 @@
     }
 
   /* Make a reductions structure and copy the data into it.  */
-  state->reductions = reductions_new (count);
-  memcpy (state->reductions->rules, redset, count * sizeof (redset[0]));
+  state_reductions_set (state, count, redset);
 }
 
 
@@ -340,7 +339,7 @@
       if (!state->errs)
        state->errs = errs_new (0);
       if (!state->reductions)
-       state->reductions = reductions_new (0);
+       state_reductions_set (state, 0, 0);
 
       states[state->number] = state;
 
Index: src/conflicts.c
--- src/conflicts.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/conflicts.c Sat, 29 Jun 2002 13:50:21 +0200 akim
@@ -179,7 +179,7 @@
   rule_t *redrule = state->lookaheads_rule[lookahead];
   int redprec = redrule->prec->prec;
   bitset lookaheads = state->lookaheads[lookahead];
-  errs *errp = errs_new (ntokens + 1);
+  errs_t *errp = errs_new (ntokens + 1);
   errp->nerrs = 0;
 
   for (i = 0; i < ntokens; i++)
Index: src/lalr.c
--- src/lalr.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/lalr.c Sat, 29 Jun 2002 13:50:54 +0200 akim
@@ -521,7 +521,7 @@
     {
       int k;
       int nlookaheads = 0;
-      reductions *rp = states[i]->reductions;
+      reductions_t *rp = states[i]->reductions;
       shifts_t *sp = states[i]->shifts;
 
       /* We need a lookahead either to distinguish different
Index: src/output.c
--- src/output.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/output.c Sat, 29 Jun 2002 13:50:54 +0200 akim
@@ -429,9 +429,9 @@
 {
   int i;
   int default_rule = 0;
-  reductions *redp = state->reductions;
+  reductions_t *redp = state->reductions;
   shifts_t *shiftp = state->shifts;
-  errs *errp = state->errs;
+  errs_t *errp = state->errs;
   /* set nonzero to inhibit having any default reduction */
   int nodefault = 0;
   int conflicted = 0;
Index: src/print.c
--- src/print.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/print.c Sat, 29 Jun 2002 13:51:29 +0200 akim
@@ -128,7 +128,7 @@
 static void
 print_errs (FILE *out, state_t *state)
 {
-  errs *errp = state->errs;
+  errs_t *errp = state->errs;
   int i;
 
   for (i = 0; i < errp->nerrs; ++i)
@@ -170,8 +170,8 @@
 {
   int i;
   shifts_t *shiftp = state->shifts;
-  reductions *redp = state->reductions;
-  errs *errp = state->errs;
+  reductions_t *redp = state->reductions;
+  errs_t *errp = state->errs;
   int nodefault = 0;
 
   if (redp->nreds == 0)
@@ -304,7 +304,7 @@
 static void
 print_actions (FILE *out, state_t *state)
 {
-  reductions *redp = state->reductions;
+  reductions_t *redp = state->reductions;
   shifts_t *shiftp = state->shifts;
 
   if (shiftp->nshifts == 0 && redp->nreds == 0)
Index: src/print_graph.c
--- src/print_graph.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/print_graph.c Sat, 29 Jun 2002 13:51:29 +0200 akim
@@ -123,8 +123,8 @@
 {
   int i;
 
-  shifts_t   *shiftp = state->shifts;
-  reductions *redp = state->reductions;
+  shifts_t     *shiftp = state->shifts;
+  reductions_t *redp = state->reductions;
 
   static char buff[10];
   edge_t edge;
Index: src/state.c
--- src/state.c Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/state.c Sat, 29 Jun 2002 13:58:15 +0200 akim
@@ -61,23 +61,23 @@
 `-------------------------------*/
 
 #define ERRS_ALLOC(Nerrs)                                              \
-  (errs *) xcalloc ((unsigned) (sizeof (errs)                          \
+  (errs_t *) xcalloc ((unsigned) (sizeof (errs_t)                      \
                                   + (Nerrs - 1) * sizeof (short)), 1)
 
 
-errs *
+errs_t *
 errs_new (int n)
 {
-  errs *res = ERRS_ALLOC (n);
+  errs_t *res = ERRS_ALLOC (n);
   res->nerrs = n;
   return res;
 }
 
 
-errs *
-errs_dup (errs *src)
+errs_t *
+errs_dup (errs_t *src)
 {
-  errs *res = errs_new (src->nerrs);
+  errs_t *res = errs_new (src->nerrs);
   memcpy (res->errs, src->errs, src->nerrs * sizeof (src->errs[0]));
   return res;
 }
@@ -95,14 +95,15 @@
 `-------------------------------------*/
 
 #define REDUCTIONS_ALLOC(Nreductions)                                  \
-  (reductions *) xcalloc ((unsigned) (sizeof (reductions)              \
+  (reductions_t *) xcalloc ((unsigned) (sizeof (reductions_t)          \
                                   + (Nreductions - 1) * sizeof (short)), 1)
 
-reductions *
-reductions_new (int n)
+static reductions_t *
+reductions_new (int nreductions, short *reductions)
 {
-  reductions *res = REDUCTIONS_ALLOC (n);
-  res->nreds = n;
+  reductions_t *res = REDUCTIONS_ALLOC (nreductions);
+  res->nreds = nreductions;
+  memcpy (res->rules, reductions, nreductions * sizeof (reductions[0]));
   return res;
 }
 
@@ -156,6 +157,17 @@
 state_shifts_set (state_t *state, int nshifts, state_number_t *shifts)
 {
   state->shifts = shifts_new (nshifts, shifts);
+}
+
+
+/*------------------------------.
+| Set the reductions of STATE.  |
+`------------------------------*/
+
+void
+state_reductions_set (state_t *state, int nreductions, short *reductions)
+{
+  state->reductions = reductions_new (nreductions, reductions);
 }
 
 
Index: src/state.h
--- src/state.h Sat, 29 Jun 2002 13:48:33 +0200 akim
+++ src/state.h Sat, 29 Jun 2002 13:57:32 +0200 akim
@@ -144,27 +144,26 @@
 | Errs.  |
 `-------*/
 
-typedef struct errs
+typedef struct errs_s
 {
   short nerrs;
   short errs[1];
-} errs;
+} errs_t;
 
-errs *errs_new PARAMS ((int n));
-errs *errs_dup PARAMS ((errs *src));
+errs_t *errs_new PARAMS ((int n));
+errs_t *errs_dup PARAMS ((errs_t *src));
 
 
 /*-------------.
 | Reductions.  |
 `-------------*/
 
-typedef struct reductions
+typedef struct reductions_s
 {
   short nreds;
   short rules[1];
-} reductions;
+} reductions_t;
 
-reductions *reductions_new PARAMS ((int n));
 
 
 /*----------.
@@ -176,8 +175,8 @@
   state_number_t number;
   symbol_number_t accessing_symbol;
   shifts_t     *shifts;
-  reductions *reductions;
-  errs       *errs;
+  reductions_t *reductions;
+  errs_t       *errs;
 
   /* Nonzero if no lookahead is needed to decide what to do in state S.  */
   char consistent;
@@ -207,6 +206,10 @@
 /* Set the shifts of STATE.  */
 void state_shifts_set PARAMS ((state_t *state,
                               int nshifts, state_number_t *shifts));
+
+/* Set the reductions of STATE.  */
+void state_reductions_set PARAMS ((state_t *state,
+                                  int nreductions, short *reductions));
 
 /* Print on OUT all the lookaheads such that this STATE wants to
    reduce this RULE.  */



reply via email to

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