print_shifts (FILE *out, state_t *state)
{
int i;
- shifts *shiftp = state->shifts;
+ shifts_t *shiftp = state->shifts;
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
if (!SHIFT_IS_DISABLED (shiftp, i))
{
- int state1 = shiftp->shifts[i];
+ state_number_t state1 = shiftp->shifts[i];
symbol_number_t symbol = states[state1]->accessing_symbol;
fprintf (out,
_(" %-4s\tshift, and go to state %d\n"),
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)
print_gotos (FILE *out, state_t *state)
{
int i;
- shifts *shiftp = state->shifts;
+ shifts_t *shiftp = state->shifts;
for (i = 0; i < shiftp->nshifts && SHIFT_IS_SHIFT (shiftp, i); i++)
/* Skip token shifts. */;
for (; i < shiftp->nshifts; i++)
if (!SHIFT_IS_DISABLED (shiftp, i))
{
- int state1 = shiftp->shifts[i];
+ state_number_t state1 = shiftp->shifts[i];
symbol_number_t symbol = states[state1]->accessing_symbol;
fprintf (out, _(" %-4s\tgo to state %d\n"),
symbol_tag_get (symbols[symbol]), state1);
print_reductions (FILE *out, state_t *state)
{
int i;
- shifts *shiftp = state->shifts;
- reductions *redp = state->reductions;
- errs *errp = state->errs;
+ shifts_t *shiftp = state->shifts;
+ reductions_t *redp = state->reductions;
+ errs_t *errp = state->errs;
int nodefault = 0;
if (redp->nreds == 0)
bitset_and (lookaheadset, state->lookaheads[0], shiftset);
- for (i = 0; i < ntokens; i++)
- if (bitset_test (lookaheadset, i))
- fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
- symbol_tag_get (symbols[i]),
- default_rule->number - 1,
- symbol_tag_get_n (default_rule->lhs, 1));
-
+ BITSET_EXECUTE (lookaheadset, 0, i,
+ {
+ fprintf (out, _(" %-4s\t[reduce using rule %d (%s)]\n"),
+ symbol_tag_get (symbols[i]),
+ default_rule->number - 1,
+ symbol_tag_get_n (default_rule->lhs, 1));
+ });
fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"),
default_rule->number - 1,
symbol_tag_get (default_rule->lhs));
for (i = 0; i < state->nlookaheads; ++i)
{
int count = 0;
- int j;
bitset_andn (lookaheadset, state->lookaheads[i], shiftset);
-
- for (j = 0; j < ntokens; j++)
- if (bitset_test (lookaheadset, j))
- count++;
+ count = bitset_count (lookaheadset);
if (count > cmax)
{
static void
print_actions (FILE *out, state_t *state)
{
- reductions *redp = state->reductions;
- shifts *shiftp = state->shifts;
+ reductions_t *redp = state->reductions;
+ shifts_t *shiftp = state->shifts;
if (shiftp->nshifts == 0 && redp->nreds == 0)
{
- if (final_state == state->number)
+ if (state->number == final_state->number)
fprintf (out, _(" $default\taccept\n"));
else
fprintf (out, _(" NO ACTIONS\n"));
print_grammar (FILE *out)
{
symbol_number_t i;
- item_number_t *rule;
char buffer[90];
int column = 0;
if (token_translations[i] != undeftoken->number)
{
const char *tag = symbol_tag_get (symbols[token_translations[i]]);
- int r;
+ rule_number_t r;
+ item_number_t *rhsp;
+
buffer[0] = 0;
column = strlen (tag);
fputs (tag, out);
sprintf (buffer, " (%d)", i);
for (r = 1; r < nrules + 1; r++)
- for (rule = rules[r].rhs; *rule >= 0; rule++)
- if (item_number_as_symbol_number (*rule) == token_translations[i])
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (item_number_as_symbol_number (*rhsp) == token_translations[i])
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r - 1);
for (i = ntokens; i < nsyms; i++)
{
int left_count = 0, right_count = 0;
- int r;
+ rule_number_t r;
const char *tag = symbol_tag_get (symbols[i]);
for (r = 1; r < nrules + 1; r++)
{
+ item_number_t *rhsp;
if (rules[r].lhs->number == i)
left_count++;
- for (rule = rules[r].rhs; *rule >= 0; rule++)
- if (item_number_as_symbol_number (*rule) == i)
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (item_number_as_symbol_number (*rhsp) == i)
{
right_count++;
break;
sprintf (buffer + strlen (buffer), _(" on right:"));
for (r = 1; r < nrules + 1; r++)
{
- for (rule = rules[r].rhs; *rule >= 0; rule++)
- if (item_number_as_symbol_number (*rule) == i)
+ item_number_t *rhsp;
+ for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
+ if (item_number_as_symbol_number (*rhsp) == i)
{
END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", r - 1);
void
print_results (void)
{
- size_t i;
+ state_number_t i;
/* We used to use just .out if SPEC_NAME_PREFIX (-p) was used, but
that conflicts with Posix. */