From fb9087861fd4b7de68fb8e86d08d4f07fd77238d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 19 Nov 2001 10:39:07 +0000 Subject: [PATCH] * src/closure.c (itemsetend): Remove, replaced with... (itemsetsize): new. --- ChangeLog | 6 ++++++ src/LR0.c | 14 +++++--------- src/closure.c | 23 ++++++++++++----------- src/closure.h | 4 ++-- 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2e58baa..fd85c1fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-19 Akim Demaille + + * src/closure.c (itemsetend): Remove, replaced with... + (itemsetsize): new. + + 2001-11-19 Akim Demaille * src/LR0.c (kernel_end): Remove, replaced with... diff --git a/src/LR0.c b/src/LR0.c index cecc0eae..8d424eab 100644 --- a/src/LR0.c +++ b/src/LR0.c @@ -150,7 +150,7 @@ new_itemsets (void) shiftcount = 0; - for (i = 0; i < itemsetend - itemset; ++i) + for (i = 0; i < itemsetsize; ++i) { int symbol = ritem[itemset[i]]; if (symbol > 0) @@ -544,19 +544,15 @@ augment_automaton (void) static void save_reductions (void) { - short *isp; - int item; int count; - reductions *p; - - short *rend; + int i; /* Find and count the active items that represent ends of rules. */ count = 0; - for (isp = itemset; isp < itemsetend; isp++) + for (i = 0; i < itemsetsize; ++i) { - item = ritem[*isp]; + int item = ritem[itemset[i]]; if (item < 0) redset[count++] = -item; } @@ -565,7 +561,7 @@ save_reductions (void) if (count) { - p = REDUCTIONS_ALLOC (count); + reductions *p = REDUCTIONS_ALLOC (count); p->number = this_state->number; p->nreds = count; diff --git a/src/closure.c b/src/closure.c index 09d83500..ac37b2c0 100644 --- a/src/closure.c +++ b/src/closure.c @@ -26,8 +26,10 @@ #include "derives.h" #include "warshall.h" +/* ITEMSETSIZE is the size of the array ITEMSET. */ short *itemset; -short *itemsetend; +size_t itemsetsize; + static unsigned *ruleset; /* internal data. See comments before set_fderives and set_firsts. */ @@ -51,11 +53,10 @@ static int varsetsize; static void print_closure (int n) { - short *isp; - + int i; fprintf (stderr, "n = %d\n", n); - for (isp = itemset; isp < itemsetend; isp++) - fprintf (stderr, " %d\n", *isp); + for (i = 0; i < itemsetsize; ++i) + fprintf (stderr, " %d\n", itemset[i]); fprintf (stderr, "\n\n"); } @@ -265,9 +266,9 @@ closure (short *core, int n) } ruleno = 0; - itemsetend = itemset; + itemsetsize = 0; csp = core; - for (i= 0; i < rulesetsize; ++i) + for (i = 0; i < rulesetsize; ++i) { int word = ruleset[i]; if (word == 0) @@ -283,9 +284,9 @@ closure (short *core, int n) if (word & (1 << b)) { itemno = rule_table[ruleno].rhs; - while (csp < (core + n ) && *csp < itemno) - *itemsetend++ = *csp++; - *itemsetend++ = itemno; + while (csp < (core + n) && *csp < itemno) + itemset[itemsetsize++] = *csp++; + itemset[itemsetsize++] = itemno; } ruleno++; @@ -294,7 +295,7 @@ closure (short *core, int n) } while (csp < (core + n)) - *itemsetend++ = *csp++; + itemset[itemsetsize++] = *csp++; if (trace_flag) print_closure (n); diff --git a/src/closure.h b/src/closure.h index 91d9d09d..67759a48 100644 --- a/src/closure.h +++ b/src/closure.h @@ -1,5 +1,5 @@ /* Subroutines for bison - Copyright 1984, 1989, 2000 Free Software Foundation, Inc. + Copyright 1984, 1989, 2000, 2001 Free Software Foundation, Inc. This file is part of Bison, the GNU Compiler Compiler. @@ -51,6 +51,6 @@ void closure PARAMS ((short *items, int n)); void free_closure PARAMS ((void)); extern short *itemset; -extern short *itemsetend; +extern size_t itemsetsize; #endif /* !CLOSURE_H_ */ -- 2.45.2