mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* 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.
This commit is contained in:
@@ -1,3 +1,12 @@
|
||||
2002-06-30 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* 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.
|
||||
|
||||
|
||||
2002-06-30 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/LR0.c (state_list_t, state_list_append): New.
|
||||
|
||||
@@ -94,7 +94,7 @@ allocate_itemsets (void)
|
||||
/* 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 @@ save_reductions (state_t *state)
|
||||
}
|
||||
|
||||
/* 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 @@ set_states (void)
|
||||
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;
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ resolve_sr_conflict (state_t *state, int lookahead)
|
||||
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++)
|
||||
|
||||
@@ -521,7 +521,7 @@ states_lookaheads_count (void)
|
||||
{
|
||||
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
|
||||
|
||||
@@ -429,9 +429,9 @@ action_row (state_t *state)
|
||||
{
|
||||
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;
|
||||
|
||||
@@ -128,7 +128,7 @@ print_shifts (FILE *out, state_t *state)
|
||||
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 @@ print_reductions (FILE *out, state_t *state)
|
||||
{
|
||||
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 @@ print_reductions (FILE *out, state_t *state)
|
||||
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)
|
||||
|
||||
@@ -123,8 +123,8 @@ print_actions (state_t *state, const char *node_name)
|
||||
{
|
||||
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;
|
||||
|
||||
34
src/state.c
34
src/state.c
@@ -61,23 +61,23 @@ shifts_new (int nshifts, state_number_t *shifts)
|
||||
`-------------------------------*/
|
||||
|
||||
#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 @@ errs_dup (errs *src)
|
||||
`-------------------------------------*/
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
@@ -159,6 +160,17 @@ state_shifts_set (state_t *state, int nshifts, state_number_t *shifts)
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------.
|
||||
| Set the reductions of STATE. |
|
||||
`------------------------------*/
|
||||
|
||||
void
|
||||
state_reductions_set (state_t *state, int nreductions, short *reductions)
|
||||
{
|
||||
state->reductions = reductions_new (nreductions, reductions);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*--------------------------------------------------------------.
|
||||
| Print on OUT all the lookaheads such that this STATE wants to |
|
||||
|
||||
21
src/state.h
21
src/state.h
@@ -144,27 +144,26 @@ typedef struct shifts_s
|
||||
| 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 @@ typedef struct state_s
|
||||
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;
|
||||
@@ -208,6 +207,10 @@ state_t *state_new PARAMS ((symbol_number_t accessing_symbol,
|
||||
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. */
|
||||
void state_rule_lookaheads_print PARAMS ((state_t *state, rule_t *rule,
|
||||
|
||||
Reference in New Issue
Block a user