[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07-fyi-reduction-list.patch
From: |
Akim Demaille |
Subject: |
07-fyi-reduction-list.patch |
Date: |
Mon, 10 Dec 2001 09:35:49 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
Now that states have a complete set of members, the linked list of
reductions is useless: just fill directly the state's reductions
member.
* src/state.h (struct reductions): Remove member `number' and
`next'.
* src/LR0.c (first_reduction, last_reduction): Remove.
(save_reductions): Don't link the new reductions, store them in
this_state.
* src/lalr.c (set_state_table): No need to attach reductions to
states, it's already done.
* src/output.c (output_actions): No longer free the shifts, then
the reductions, then the states: free all the states and their
members.
Index: src/LR0.c
--- src/LR0.c Sat, 08 Dec 2001 13:33:23 +0100 akim
+++ src/LR0.c Sat, 08 Dec 2001 15:45:09 +0100 akim
@@ -30,18 +30,17 @@
#include "complain.h"
#include "closure.h"
#include "LR0.h"
+#include "lalr.h"
#include "reduce.h"
int nstates;
int final_state;
state_t *first_state = NULL;
shifts *first_shift = NULL;
-reductions *first_reduction = NULL;
static state_t *this_state = NULL;
static state_t *last_state = NULL;
static shifts *last_shift = NULL;
-static reductions *last_reduction = NULL;
static int nshifts;
static short *shift_symbol = NULL;
@@ -551,17 +550,10 @@
if (count)
{
reductions *p = REDUCTIONS_ALLOC (count);
-
- p->number = this_state->number;
p->nreds = count;
-
shortcpy (p->rules, redset, count);
- if (last_reduction)
- last_reduction->next = p;
- else
- first_reduction = p;
- last_reduction = p;
+ this_state->reductions = p;
}
}
Index: src/lalr.c
--- src/lalr.c Sat, 08 Dec 2001 13:33:23 +0100 akim
+++ src/lalr.c Sat, 08 Dec 2001 15:39:10 +0100 akim
@@ -156,12 +156,6 @@
state_table[sp->number]->shifts = sp;
}
- {
- reductions *rp;
- for (rp = first_reduction; rp; rp = rp->next)
- state_table[rp->number]->reductions = rp;
- }
-
/* Pessimization, but simplification of the code: make sure all the
states have a shifts, even if reduced to 0 shifts. */
{
Index: src/output.c
--- src/output.c Sat, 08 Dec 2001 14:32:42 +0100 akim
+++ src/output.c Sat, 08 Dec 2001 15:46:12 +0100 akim
@@ -885,6 +885,7 @@
static void
output_actions (void)
{
+ int i;
nvectors = nstates + nvars;
froms = XCALLOC (short *, nvectors);
@@ -893,8 +894,6 @@
width = XCALLOC (short, nvectors);
token_actions ();
- LIST_FREE (shifts, first_shift);
- LIST_FREE (reductions, first_reduction);
XFREE (LA);
XFREE (LAruleno);
@@ -910,7 +909,14 @@
output_table ();
output_check ();
- LIST_FREE (state_t, first_state);
+
+ for (i = 0; i < nstates; ++i)
+ {
+ XFREE (state_table[i]->shifts);
+ XFREE (state_table[i]->reductions);
+ XFREE (state_table[i]->errs);
+ free (state_table[i]);
+ }
XFREE (state_table);
}
Index: src/state.h
--- src/state.h Sat, 08 Dec 2001 13:33:23 +0100 akim
+++ src/state.h Sat, 08 Dec 2001 15:41:03 +0100 akim
@@ -162,8 +162,6 @@
typedef struct reductions
{
- struct reductions *next;
- short number;
short nreds;
short rules[1];
} reductions;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 07-fyi-reduction-list.patch,
Akim Demaille <=