[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
19-fyi-state-table-to-states.patch
From: |
Akim Demaille |
Subject: |
19-fyi-state-table-to-states.patch |
Date: |
Sat, 29 Dec 2001 15:14:48 +0100 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* src/LR0.c, src/conflicts.c, src/lalr.c, src/lalr.h, src/output.c
* src/print.c, src/print_graph.c, src/state.h: Rename state_table
as states.
Index: src/LR0.c
--- src/LR0.c Fri, 28 Dec 2001 16:30:23 +0100 akim
+++ src/LR0.c Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -365,14 +365,14 @@
/*--------------------.
-| Build STATE_TABLE. |
+| Build STATES. |
`--------------------*/
static void
-set_state_table (void)
+set_states (void)
{
state_t *sp;
- state_table = XCALLOC (state_t *, nstates);
+ states = XCALLOC (state_t *, nstates);
for (sp = first_state; sp; sp = sp->next)
{
@@ -386,7 +386,7 @@
if (!sp->reductions)
sp->reductions = reductions_new (0);
- state_table[sp->number] = sp;
+ states[sp->number] = sp;
}
}
@@ -432,6 +432,6 @@
free_closure ();
free_storage ();
- /* Set up STATE_TABLE. */
- set_state_table ();
+ /* Set up STATES. */
+ set_states ();
}
Index: src/conflicts.c
--- src/conflicts.c Fri, 28 Dec 2001 16:41:48 +0100 akim
+++ src/conflicts.c Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -204,7 +204,7 @@
lookaheadset = XCALLOC (unsigned, tokensetsize);
for (i = 0; i < nstates; i++)
- set_conflicts (state_table[i]);
+ set_conflicts (states[i]);
}
@@ -327,8 +327,8 @@
if (conflicts[i])
{
fprintf (out, _("State %d contains "), i);
- fputs (conflict_report (count_sr_conflicts (state_table[i]),
- count_rr_conflicts (state_table[i])), out);
+ fputs (conflict_report (count_sr_conflicts (states[i]),
+ count_rr_conflicts (states[i])), out);
printed_sth = TRUE;
}
if (printed_sth)
@@ -357,8 +357,8 @@
for (i = 0; i < nstates; i++)
if (conflicts[i])
{
- src_total += count_sr_conflicts (state_table[i]);
- rrc_total += count_rr_conflicts (state_table[i]);
+ src_total += count_sr_conflicts (states[i]);
+ rrc_total += count_rr_conflicts (states[i]);
}
src_ok = src_total == (expected_conflicts == -1 ? 0 : expected_conflicts);
Index: src/lalr.c
--- src/lalr.c Fri, 28 Dec 2001 16:44:34 +0100 akim
+++ src/lalr.c Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -36,7 +36,7 @@
#include "getargs.h"
/* All the decorated states, indexed by the state number. */
-state_t **state_table = NULL;
+state_t **states = NULL;
int tokensetsize;
short *LAruleno;
@@ -150,9 +150,9 @@
np = LAruleno;
for (i = 0; i < nstates; i++)
- if (!state_table[i]->consistent)
- for (j = 0; j < state_table[i]->reductions->nreds; j++)
- *np++ = state_table[i]->reductions->rules[j];
+ if (!states[i]->consistent)
+ for (j = 0; j < states[i]->reductions->nreds; j++)
+ *np++ = states[i]->reductions->rules[j];
}
@@ -168,7 +168,7 @@
ngotos = 0;
for (state = 0; state < nstates; ++state)
{
- shifts *sp = state_table[state]->shifts;
+ shifts *sp = states[state]->shifts;
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
{
if (ngotos == MAXSHORT)
@@ -199,7 +199,7 @@
for (state = 0; state < nstates; ++state)
{
- shifts *sp = state_table[state]->shifts;
+ shifts *sp = states[state]->shifts;
for (i = sp->nshifts - 1; i >= 0 && SHIFT_IS_GOTO (sp, i); --i)
{
int k = temp_map[SHIFT_SYMBOL (sp, i)]++;
@@ -260,7 +260,7 @@
for (i = 0; i < ngotos; i++)
{
int stateno = to_state[i];
- shifts *sp = state_table[stateno]->shifts;
+ shifts *sp = states[stateno]->shifts;
int j;
for (j = 0; j < sp->nshifts && SHIFT_IS_SHIFT (sp, j); j++)
@@ -409,7 +409,7 @@
for (i = 0; i < ngotos; i++)
{
int nedges = 0;
- int symbol1 = state_table[to_state[i]]->accessing_symbol;
+ int symbol1 = states[to_state[i]]->accessing_symbol;
short *rulep;
for (rulep = derives[symbol1]; *rulep > 0; rulep++)
@@ -417,7 +417,7 @@
int done;
int length = 1;
short *rp;
- state_t *state = state_table[from_state[i]];
+ state_t *state = states[from_state[i]];
states1[0] = state->number;
for (rp = &ritem[rules[*rulep].rhs]; *rp >= 0; rp++)
@@ -426,7 +426,7 @@
int j;
for (j = 0; j < sp->nshifts; j++)
{
- state = state_table[sp->shifts[j]];
+ state = states[sp->shifts[j]];
if (state->accessing_symbol == *rp)
break;
}
@@ -522,8 +522,8 @@
{
int k;
int nlookaheads = 0;
- reductions *rp = state_table[i]->reductions;
- shifts *sp = state_table[i]->shifts;
+ reductions *rp = states[i]->reductions;
+ shifts *sp = states[i]->shifts;
/* We need a lookahead either to distinguish different
reductions (i.e., there are two or more), or to distinguish a
@@ -533,17 +533,17 @@
|| (rp->nreds == 1 && sp->nshifts && SHIFT_IS_SHIFT (sp, 0)))
nlookaheads += rp->nreds;
else
- state_table[i]->consistent = 1;
+ states[i]->consistent = 1;
for (k = 0; k < sp->nshifts; k++)
if (SHIFT_IS_ERROR (sp, k))
{
- state_table[i]->consistent = 0;
+ states[i]->consistent = 0;
break;
}
- state_table[i]->nlookaheads = nlookaheads;
- state_table[i]->lookaheadsp = nLA;
+ states[i]->nlookaheads = nlookaheads;
+ states[i]->lookaheadsp = nLA;
nLA += nlookaheads;
}
}
@@ -561,14 +561,14 @@
for (i = 0; i < nstates; ++i)
{
fprintf (out, "State %d: %d lookaheads\n",
- i, state_table[i]->nlookaheads);
+ i, states[i]->nlookaheads);
- for (j = 0; j < state_table[i]->nlookaheads; ++j)
+ for (j = 0; j < states[i]->nlookaheads; ++j)
for (k = 0; k < ntokens; ++k)
- if (BITISSET (LA (state_table[i]->lookaheadsp + j), j))
+ if (BITISSET (LA (states[i]->lookaheadsp + j), j))
fprintf (out, " on %d (%s) -> rule %d\n",
k, symbols[k]->tag,
- -LAruleno[state_table[i]->lookaheadsp + j] - 1);
+ -LAruleno[states[i]->lookaheadsp + j] - 1);
}
fprintf (out, "Lookaheads: END\n");
}
Index: src/lalr.h
--- src/lalr.h Sun, 16 Dec 2001 18:26:08 +0100 akim
+++ src/lalr.h Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -70,7 +70,7 @@
/* All the states, indexed by the state number. */
-extern state_t **state_table;
+extern state_t **states;
extern int tokensetsize;
Index: src/output.c
--- src/output.c Fri, 28 Dec 2001 16:41:48 +0100 akim
+++ src/output.c Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -222,7 +222,7 @@
int i;
short *values = (short *) alloca (sizeof (short) * nstates);
for (i = 0; i < nstates; ++i)
- values[i] = state_table[i]->accessing_symbol;
+ values[i] = states[i]->accessing_symbol;
output_table_data (&format_obstack, values,
0, 1, nstates);
muscle_insert ("stos", obstack_finish (&format_obstack));
@@ -362,7 +362,7 @@
if (!shift_state)
continue;
- symbol = state_table[shift_state]->accessing_symbol;
+ symbol = states[shift_state]->accessing_symbol;
if (ISVAR (symbol))
break;
@@ -486,7 +486,7 @@
actrow = XCALLOC (short, ntokens);
for (i = 0; i < nstates; ++i)
{
- yydefact[i] = action_row (state_table[i]);
+ yydefact[i] = action_row (states[i]);
save_row (i);
}
@@ -904,12 +904,12 @@
for (i = 0; i < nstates; ++i)
{
- free (state_table[i]->shifts);
- XFREE (state_table[i]->reductions);
- free (state_table[i]->errs);
- free (state_table[i]);
+ free (states[i]->shifts);
+ XFREE (states[i]->reductions);
+ free (states[i]->errs);
+ free (states[i]);
}
- XFREE (state_table);
+ XFREE (states);
}
Index: src/print.c
--- src/print.c Fri, 28 Dec 2001 16:41:48 +0100 akim
+++ src/print.c Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -122,7 +122,7 @@
if (!SHIFT_IS_DISABLED (shiftp, i))
{
int state1 = shiftp->shifts[i];
- int symbol = state_table[state1]->accessing_symbol;
+ int symbol = states[state1]->accessing_symbol;
fprintf (out,
_(" %-4s\tshift, and go to state %d\n"),
escape (symbols[symbol]->tag), state1);
@@ -164,7 +164,7 @@
if (!SHIFT_IS_DISABLED (shiftp, i))
{
int state1 = shiftp->shifts[i];
- int symbol = state_table[state1]->accessing_symbol;
+ int symbol = states[state1]->accessing_symbol;
fprintf (out, _(" %-4s\tgo to state %d\n"),
escape (symbols[symbol]->tag), state1);
}
@@ -501,7 +501,7 @@
shiftset = XCALLOC (unsigned, tokensetsize);
lookaheadset = XCALLOC (unsigned, tokensetsize);
for (i = 0; i < nstates; i++)
- print_state (out, state_table[i]);
+ print_state (out, states[i]);
free (shiftset);
free (lookaheadset);
if (trace_flag)
Index: src/print_graph.c
--- src/print_graph.c Fri, 28 Dec 2001 16:41:48 +0100 akim
+++ src/print_graph.c Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -114,7 +114,7 @@
if (!SHIFT_IS_DISABLED (shiftp, i))
{
int state1 = shiftp->shifts[i];
- int symbol = state_table[state1]->accessing_symbol;
+ int symbol = states[state1]->accessing_symbol;
new_edge (&edge);
@@ -202,7 +202,7 @@
/* Output nodes and edges. */
new_closure (nritems);
for (i = 0; i < nstates; i++)
- print_state (state_table[i]);
+ print_state (states[i]);
free_closure ();
/* Close graph. */
Index: src/state.h
--- src/state.h Thu, 27 Dec 2001 11:15:14 +0100 akim
+++ src/state.h Fri, 28 Dec 2001 16:45:07 +0100 akim
@@ -107,7 +107,7 @@
case of gotos. */
#define SHIFT_SYMBOL(Shifts, Shift) \
- (state_table[Shifts->shifts[Shift]]->accessing_symbol)
+ (states[Shifts->shifts[Shift]]->accessing_symbol)
/* Is the SHIFTS->shifts[Shift] a real shift? (as opposed to gotos.) */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 19-fyi-state-table-to-states.patch,
Akim Demaille <=