(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 (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)
`----------------------------------------------------------------*/
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)
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);
}
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)
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:
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]];
}
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;
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
/* 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];
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)
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)
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)
size_t width = 0;
int i, j;
- if (redp->nreds == 0)
+ if (redp->num == 0)
return;
default_rule = state_default_rule (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)
#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;
}
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;
}
#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;
}
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));
typedef struct reductions_s
{
- short nreds;
- short rules[1];
+ short num;
+ rule_number_t rules[1];
} reductions_t;