From 0fb1ffb1bfede38666fbc3a4b1e253b473bd6d7d Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 4 Mar 2002 12:04:47 +0000 Subject: [PATCH] * src/lalr.c (F): Now a bitset*. Adjust all dependencies. --- ChangeLog | 6 ++++++ src/lalr.c | 29 +++++++++++++---------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 759f82a2..6170b5ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2002-03-04 Akim Demaille + + * src/lalr.c (F): Now a bitset*. + Adjust all dependencies. + + 2002-03-04 Akim Demaille * src/conflicts.c (shiftset, lookaheadset): Now bitset. diff --git a/src/lalr.c b/src/lalr.c index 30e9f318..87e91cd5 100644 --- a/src/lalr.c +++ b/src/lalr.c @@ -51,8 +51,7 @@ short *to_state = NULL; /* And for the famous F variable, which name is so descriptive that a comment is hardly needed. . */ -static unsigned *F = NULL; -#define F(Rule) (F + (Rule) * tokensetsize) +static bitset *F = NULL; static short **includes; static shorts **lookback; @@ -75,9 +74,7 @@ static void traverse (int i) { int j; - size_t k; int height; - size_t size = F (i + 1) - F(i); VERTICES[++top] = i; INDEX[i] = height = top; @@ -91,8 +88,7 @@ traverse (int i) if (INDEX[i] > INDEX[R[i][j]]) INDEX[i] = INDEX[R[i][j]]; - for (k = 0; k < size; ++k) - F (i)[k] |= F (R[i][j])[k]; + bitset_or (F[i], F[i], F[R[i][j]]); } if (INDEX[i] == height) @@ -104,8 +100,7 @@ traverse (int i) if (i == j) break; - for (k = 0; k < size; ++k) - F (j)[k] = F (i)[k]; + bitset_copy (F[j], F[i]); } } @@ -262,7 +257,12 @@ initialize_F (void) int i; - F = XCALLOC (unsigned, ngotos * tokensetsize); + F = XCALLOC (bitset, ngotos); + for (i = 0; i < ngotos; ++i) + { + F[i] = bitset_create (ntokens, BITSET_FIXED); + bitset_zero (F[i]); + } for (i = 0; i < ngotos; i++) { @@ -271,7 +271,7 @@ initialize_F (void) int j; for (j = 0; j < sp->nshifts && SHIFT_IS_SHIFT (sp, j); j++) - SETBIT (F (i), SHIFT_SYMBOL (sp, j)); + bitset_set (F[i], SHIFT_SYMBOL (sp, j)); for (; j < sp->nshifts; j++) { @@ -500,18 +500,15 @@ compute_lookaheads (void) for (i = 0; i < nLA; i++) for (sp = lookback[i]; sp; sp = sp->next) - { - int j; - for (j = 0; j < ntokens; ++j) - if (BITISSET (F (sp->value), j)) - bitset_set (LA[i], j); - } + bitset_or (LA[i], LA[i], F[sp->value]); /* Free LOOKBACK. */ for (i = 0; i < nLA; i++) LIST_FREE (shorts, lookback[i]); XFREE (lookback); + for (i = 0; i < (unsigned) ngotos; ++i) + bitset_free (F[i]); XFREE (F); } -- 2.45.2