mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
* src/state.h (reductions_t): Rename member `nreds' as num.
(errs_t): Rename members `nerrs' and `errs' as `num' and `symbols'. * src/state.c (ERRS_ALLOC, REDUCTIONS_ALLOC): Use the correct types.
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2002-06-30 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/state.h (reductions_t): Rename member `nreds' as num.
|
||||
(errs_t): Rename members `nerrs' and `errs' as `num' and `symbols'.
|
||||
* src/state.c (ERRS_ALLOC, REDUCTIONS_ALLOC): Use the correct types.
|
||||
|
||||
|
||||
2002-06-30 Akim Demaille <akim@epita.fr>
|
||||
|
||||
* src/state.h, src/state.c (shift_t, SHIFT_SYMBOL, SHIFT_IS_SHIFT)
|
||||
|
||||
@@ -58,7 +58,7 @@ enum conflict_resolution_e
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
log_resolution (rule_t *rule, int token,
|
||||
log_resolution (rule_t *rule, symbol_number_t token,
|
||||
enum conflict_resolution_e resolution)
|
||||
{
|
||||
if (report_flag & report_solved_conflicts)
|
||||
@@ -144,7 +144,8 @@ flush_shift (state_t *state, int token)
|
||||
|
||||
bitset_reset (lookaheadset, token);
|
||||
for (i = 0; i < transitions->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (transitions, i) && TRANSITION_SYMBOL (transitions, i) == token)
|
||||
if (!TRANSITION_IS_DISABLED (transitions, i)
|
||||
&& TRANSITION_SYMBOL (transitions, i) == token)
|
||||
TRANSITION_DISABLE (transitions, i);
|
||||
}
|
||||
|
||||
@@ -174,13 +175,13 @@ flush_reduce (bitset lookaheads, int token)
|
||||
static void
|
||||
resolve_sr_conflict (state_t *state, int lookahead)
|
||||
{
|
||||
int i;
|
||||
symbol_number_t i;
|
||||
/* Find the rule to reduce by to get precedence of reduction. */
|
||||
rule_t *redrule = state->lookaheads_rule[lookahead];
|
||||
int redprec = redrule->prec->prec;
|
||||
bitset lookaheads = state->lookaheads[lookahead];
|
||||
errs_t *errp = errs_new (ntokens + 1);
|
||||
errp->nerrs = 0;
|
||||
errp->num = 0;
|
||||
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (bitset_test (lookaheads, i)
|
||||
@@ -223,7 +224,7 @@ resolve_sr_conflict (state_t *state, int lookahead)
|
||||
flush_shift (state, i);
|
||||
flush_reduce (lookaheads, i);
|
||||
/* Record an explicit error for this token. */
|
||||
errp->errs[errp->nerrs++] = i;
|
||||
errp->symbols[errp->num++] = i;
|
||||
break;
|
||||
|
||||
case undef_assoc:
|
||||
|
||||
@@ -77,7 +77,7 @@ initialize_LA (void)
|
||||
np = LArule;
|
||||
for (i = 0; i < nstates; i++)
|
||||
if (!states[i]->consistent)
|
||||
for (j = 0; j < states[i]->reductions->nreds; j++)
|
||||
for (j = 0; j < states[i]->reductions->num; j++)
|
||||
*np++ = &rules[states[i]->reductions->rules[j]];
|
||||
}
|
||||
|
||||
@@ -366,9 +366,9 @@ states_lookaheads_count (void)
|
||||
reductions (i.e., there are two or more), or to distinguish a
|
||||
reduction from a shift. Otherwise, it is straightforward,
|
||||
and the state is `consistent'. */
|
||||
if (rp->nreds > 1
|
||||
|| (rp->nreds == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0)))
|
||||
nlookaheads += rp->nreds;
|
||||
if (rp->num > 1
|
||||
|| (rp->num == 1 && sp->num && TRANSITION_IS_SHIFT (sp, 0)))
|
||||
nlookaheads += rp->num;
|
||||
else
|
||||
states[i]->consistent = 1;
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ action_row (state_t *state)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
actrow[i] = conflrow[i] = 0;
|
||||
|
||||
if (redp->nreds >= 1)
|
||||
if (redp->num >= 1)
|
||||
{
|
||||
int j;
|
||||
/* loop over all the rules available here which require
|
||||
@@ -478,16 +478,16 @@ action_row (state_t *state)
|
||||
|
||||
/* See which tokens are an explicit error in this state (due to
|
||||
%nonassoc). For them, record SHRT_MIN as the action. */
|
||||
for (i = 0; i < errp->nerrs; i++)
|
||||
for (i = 0; i < errp->num; i++)
|
||||
{
|
||||
int symbol = errp->errs[i];
|
||||
symbol_number_t symbol = errp->symbols[i];
|
||||
actrow[symbol] = SHRT_MIN;
|
||||
}
|
||||
|
||||
/* Now find the most common reduction and make it the default action
|
||||
for this state. */
|
||||
|
||||
if (redp->nreds >= 1 && !nodefault)
|
||||
if (redp->num >= 1 && !nodefault)
|
||||
{
|
||||
if (state->consistent)
|
||||
default_rule = redp->rules[0];
|
||||
|
||||
22
src/print.c
22
src/print.c
@@ -178,9 +178,9 @@ print_errs (FILE *out, state_t *state)
|
||||
int i;
|
||||
|
||||
/* Compute the width of the lookaheads column. */
|
||||
for (i = 0; i < errp->nerrs; ++i)
|
||||
if (errp->errs[i])
|
||||
max_length (&width, symbol_tag_get (symbols[errp->errs[i]]));
|
||||
for (i = 0; i < errp->num; ++i)
|
||||
if (errp->symbols[i])
|
||||
max_length (&width, symbol_tag_get (symbols[errp->symbols[i]]));
|
||||
|
||||
/* Nothing to report. */
|
||||
if (!width)
|
||||
@@ -190,10 +190,10 @@ print_errs (FILE *out, state_t *state)
|
||||
width += 2;
|
||||
|
||||
/* Report lookaheads and errors. */
|
||||
for (i = 0; i < errp->nerrs; ++i)
|
||||
if (errp->errs[i])
|
||||
for (i = 0; i < errp->num; ++i)
|
||||
if (errp->symbols[i])
|
||||
{
|
||||
const char *tag = symbol_tag_get (symbols[errp->errs[i]]);
|
||||
const char *tag = symbol_tag_get (symbols[errp->symbols[i]]);
|
||||
int j;
|
||||
fprintf (out, " %s", tag);
|
||||
for (j = width - strlen (tag); j > 0; --j)
|
||||
@@ -240,9 +240,9 @@ state_default_rule (state_t *state)
|
||||
we raise an error (due to %nonassoc). */
|
||||
{
|
||||
errs_t *errp = state->errs;
|
||||
for (i = 0; i < errp->nerrs; i++)
|
||||
if (errp->errs[i])
|
||||
bitset_set (shiftset, errp->errs[i]);
|
||||
for (i = 0; i < errp->num; i++)
|
||||
if (errp->symbols[i])
|
||||
bitset_set (shiftset, errp->symbols[i]);
|
||||
}
|
||||
|
||||
for (i = 0; i < state->nlookaheads; ++i)
|
||||
@@ -308,7 +308,7 @@ print_reductions (FILE *out, state_t *state)
|
||||
size_t width = 0;
|
||||
int i, j;
|
||||
|
||||
if (redp->nreds == 0)
|
||||
if (redp->num == 0)
|
||||
return;
|
||||
|
||||
default_rule = state_default_rule (state);
|
||||
@@ -398,7 +398,7 @@ print_actions (FILE *out, state_t *state)
|
||||
reductions_t *redp = state->reductions;
|
||||
transitions_t *transitions = state->shifts;
|
||||
|
||||
if (transitions->num == 0 && redp->nreds == 0)
|
||||
if (transitions->num == 0 && redp->num == 0)
|
||||
{
|
||||
fputc ('\n', out);
|
||||
if (state->number == final_state->number)
|
||||
|
||||
12
src/state.c
12
src/state.c
@@ -76,14 +76,14 @@ transitions_to (transitions_t *shifts, symbol_number_t s)
|
||||
|
||||
#define ERRS_ALLOC(Nerrs) \
|
||||
(errs_t *) xcalloc ((unsigned) (sizeof (errs_t) \
|
||||
+ (Nerrs - 1) * sizeof (short)), 1)
|
||||
+ (Nerrs - 1) * sizeof (symbol_number_t)), 1)
|
||||
|
||||
|
||||
errs_t *
|
||||
errs_new (int n)
|
||||
{
|
||||
errs_t *res = ERRS_ALLOC (n);
|
||||
res->nerrs = n;
|
||||
res->num = n;
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -91,8 +91,8 @@ errs_new (int n)
|
||||
errs_t *
|
||||
errs_dup (errs_t *src)
|
||||
{
|
||||
errs_t *res = errs_new (src->nerrs);
|
||||
memcpy (res->errs, src->errs, src->nerrs * sizeof (src->errs[0]));
|
||||
errs_t *res = errs_new (src->num);
|
||||
memcpy (res->symbols, src->symbols, src->num * sizeof (src->symbols[0]));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -110,13 +110,13 @@ errs_dup (errs_t *src)
|
||||
|
||||
#define REDUCTIONS_ALLOC(Nreductions) \
|
||||
(reductions_t *) xcalloc ((unsigned) (sizeof (reductions_t) \
|
||||
+ (Nreductions - 1) * sizeof (short)), 1)
|
||||
+ (Nreductions - 1) * sizeof (rule_number_t)), 1)
|
||||
|
||||
static reductions_t *
|
||||
reductions_new (int nreductions, short *reductions)
|
||||
{
|
||||
reductions_t *res = REDUCTIONS_ALLOC (nreductions);
|
||||
res->nreds = nreductions;
|
||||
res->num = nreductions;
|
||||
memcpy (res->rules, reductions, nreductions * sizeof (reductions[0]));
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -152,8 +152,8 @@ struct state_s *transitions_to PARAMS ((transitions_t *state,
|
||||
|
||||
typedef struct errs_s
|
||||
{
|
||||
short nerrs;
|
||||
short errs[1];
|
||||
short num;
|
||||
symbol_number_t symbols[1];
|
||||
} errs_t;
|
||||
|
||||
errs_t *errs_new PARAMS ((int n));
|
||||
@@ -166,8 +166,8 @@ errs_t *errs_dup PARAMS ((errs_t *src));
|
||||
|
||||
typedef struct reductions_s
|
||||
{
|
||||
short nreds;
|
||||
short rules[1];
|
||||
short num;
|
||||
rule_number_t rules[1];
|
||||
} reductions_t;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user