Use "look-ahead" instead of "lookahead", consistently.

This commit is contained in:
Paul Eggert
2004-06-21 20:20:31 +00:00
parent 57a90331bd
commit 8dd162d3ff
23 changed files with 253 additions and 218 deletions

View File

@@ -41,8 +41,8 @@ int expected_rr_conflicts = -1;
static char *conflicts = NULL;
struct obstack solved_conflicts_obstack;
static bitset shiftset;
static bitset lookaheadset;
static bitset shift_set;
static bitset look_ahead_set;
@@ -146,7 +146,7 @@ flush_shift (state *s, int token)
transitions *trans = s->transitions;
int i;
bitset_reset (lookaheadset, token);
bitset_reset (look_ahead_set, token);
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_SYMBOL (trans, i) == token)
@@ -154,16 +154,16 @@ flush_shift (state *s, int token)
}
/*-------------------------------------------------------------------.
| Turn off the reduce recorded for the specified token for the |
| specified lookahead. Used when we resolve a shift-reduce conflict |
| in favor of the shift. |
`-------------------------------------------------------------------*/
/*--------------------------------------------------------------------.
| Turn off the reduce recorded for the specified token for the |
| specified look-ahead. Used when we resolve a shift-reduce conflict |
| in favor of the shift. |
`--------------------------------------------------------------------*/
static void
flush_reduce (bitset lookaheads, int token)
flush_reduce (bitset look_ahead_tokens, int token)
{
bitset_reset (lookaheads, token);
bitset_reset (look_ahead_tokens, token);
}
@@ -173,7 +173,7 @@ flush_reduce (bitset lookaheads, int token)
| rule has a precedence. A conflict is resolved by modifying the |
| shift or reduce tables so that there is no longer a conflict. |
| |
| LOOKAHEAD is the number of the lookahead bitset to consider. |
| RULENO is the number of the look-ahead bitset to consider. |
| |
| ERRORS can be used to store discovered explicit errors. |
`------------------------------------------------------------------*/
@@ -186,12 +186,12 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors)
/* Find the rule to reduce by to get precedence of reduction. */
rule *redrule = reds->rules[ruleno];
int redprec = redrule->prec->prec;
bitset lookaheads = reds->lookaheads[ruleno];
bitset look_ahead_tokens = reds->look_ahead_tokens[ruleno];
int nerrs = 0;
for (i = 0; i < ntokens; i++)
if (bitset_test (lookaheads, i)
&& bitset_test (lookaheadset, i)
if (bitset_test (look_ahead_tokens, i)
&& bitset_test (look_ahead_set, i)
&& symbols[i]->prec)
{
/* Shift-reduce conflict occurs for token number i
@@ -205,7 +205,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors)
else if (symbols[i]->prec > redprec)
{
log_resolution (redrule, i, shift_resolution);
flush_reduce (lookaheads, i);
flush_reduce (look_ahead_tokens, i);
}
else
/* Matching precedence levels.
@@ -217,7 +217,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors)
{
case right_assoc:
log_resolution (redrule, i, right_resolution);
flush_reduce (lookaheads, i);
flush_reduce (look_ahead_tokens, i);
break;
case left_assoc:
@@ -228,7 +228,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors)
case non_assoc:
log_resolution (redrule, i, nonassoc_resolution);
flush_shift (s, i);
flush_reduce (lookaheads, i);
flush_reduce (look_ahead_tokens, i);
/* Record an explicit error for this token. */
errors[nerrs++] = symbols[i];
break;
@@ -257,7 +257,7 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors)
| Solve the S/R conflicts of state S using the |
| precedence/associativity, and flag it inconsistent if it still has |
| conflicts. ERRORS can be used as storage to compute the list of |
| lookaheads on which S raises a syntax error (%nonassoc). |
| look-ahead tokens on which S raises a syntax error (%nonassoc). |
`-------------------------------------------------------------------*/
static void
@@ -270,27 +270,27 @@ set_conflicts (state *s, symbol **errors)
if (s->consistent)
return;
bitset_zero (lookaheadset);
bitset_zero (look_ahead_set);
FOR_EACH_SHIFT (trans, i)
bitset_set (lookaheadset, TRANSITION_SYMBOL (trans, i));
bitset_set (look_ahead_set, TRANSITION_SYMBOL (trans, i));
/* Loop over all rules which require lookahead in this state. First
/* Loop over all rules which require look-ahead in this state. First
check for shift-reduce conflict, and try to resolve using
precedence. */
for (i = 0; i < reds->num; ++i)
if (reds->rules[i]->prec && reds->rules[i]->prec->prec
&& !bitset_disjoint_p (reds->lookaheads[i], lookaheadset))
&& !bitset_disjoint_p (reds->look_ahead_tokens[i], look_ahead_set))
resolve_sr_conflict (s, i, errors);
/* Loop over all rules which require lookahead in this state. Check
/* Loop over all rules which require look-ahead in this state. Check
for conflicts not resolved above. */
for (i = 0; i < reds->num; ++i)
{
if (!bitset_disjoint_p (reds->lookaheads[i], lookaheadset))
if (!bitset_disjoint_p (reds->look_ahead_tokens[i], look_ahead_set))
conflicts[s->number] = 1;
bitset_or (lookaheadset, lookaheadset, reds->lookaheads[i]);
bitset_or (look_ahead_set, look_ahead_set, reds->look_ahead_tokens[i]);
}
}
@@ -304,12 +304,12 @@ void
conflicts_solve (void)
{
state_number i;
/* List of lookaheads on which we explicitly raise a syntax error. */
/* List of look-ahead tokens on which we explicitly raise a syntax error. */
symbol **errors = MALLOC (errors, ntokens + 1);
CALLOC (conflicts, nstates);
shiftset = bitset_create (ntokens, BITSET_FIXED);
lookaheadset = bitset_create (ntokens, BITSET_FIXED);
shift_set = bitset_create (ntokens, BITSET_FIXED);
look_ahead_set = bitset_create (ntokens, BITSET_FIXED);
obstack_init (&solved_conflicts_obstack);
for (i = 0; i < nstates; i++)
@@ -341,18 +341,18 @@ count_sr_conflicts (state *s)
if (!trans)
return 0;
bitset_zero (lookaheadset);
bitset_zero (shiftset);
bitset_zero (look_ahead_set);
bitset_zero (shift_set);
FOR_EACH_SHIFT (trans, i)
bitset_set (shiftset, TRANSITION_SYMBOL (trans, i));
bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
for (i = 0; i < reds->num; ++i)
bitset_or (lookaheadset, lookaheadset, reds->lookaheads[i]);
bitset_or (look_ahead_set, look_ahead_set, reds->look_ahead_tokens[i]);
bitset_and (lookaheadset, lookaheadset, shiftset);
bitset_and (look_ahead_set, look_ahead_set, shift_set);
src_count = bitset_count (lookaheadset);
src_count = bitset_count (look_ahead_set);
return src_count;
}
@@ -377,7 +377,7 @@ count_rr_conflicts (state *s, bool one_per_token)
int count = 0;
int j;
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i))
if (bitset_test (reds->look_ahead_tokens[j], i))
count++;
if (count >= 2)
@@ -432,7 +432,7 @@ conflicts_output (FILE *out)
/*--------------------------------------------------------.
| Total the number of S/R and R/R conflicts. Unlike the |
| code in conflicts_output, however, count EACH pair of |
| reductions for the same state and lookahead as one |
| reductions for the same state and look-ahead as one |
| conflict. |
`--------------------------------------------------------*/
@@ -523,7 +523,7 @@ void
conflicts_free (void)
{
XFREE (conflicts);
bitset_free (shiftset);
bitset_free (lookaheadset);
bitset_free (shift_set);
bitset_free (look_ahead_set);
obstack_free (&solved_conflicts_obstack, NULL);
}

View File

@@ -138,7 +138,7 @@ static const char * const report_args[] =
"none",
"state", "states",
"itemset", "itemsets",
"lookahead", "lookaheads",
"look-ahead", "lookahead", "lookaheads",
"solved",
"all",
0
@@ -149,7 +149,9 @@ static const int report_types[] =
report_none,
report_states, report_states,
report_states | report_itemsets, report_states | report_itemsets,
report_states | report_lookaheads, report_states | report_lookaheads,
report_states | report_look_ahead_tokens,
report_states | report_look_ahead_tokens,
report_states | report_look_ahead_tokens,
report_states | report_solved_conflicts,
report_all
};
@@ -237,7 +239,7 @@ Output:\n\
THINGS is a list of comma separated words that can include:\n\
`state' describe the states\n\
`itemset' complete the core item sets with their closure\n\
`lookahead' explicitly associate lookaheads to items\n\
`look-ahead' explicitly associate look-ahead tokens to items\n\
`solved' describe shift/reduce conflicts solving\n\
`all' include all the above information\n\
`none' disable the report\n\

View File

@@ -1,5 +1,5 @@
/* Parse command line arguments for bison.
Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003
Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -76,7 +76,7 @@ enum report
report_none = 0,
report_states = 1 << 0,
report_itemsets = 1 << 1,
report_lookaheads = 1 << 2,
report_look_ahead_tokens= 1 << 2,
report_solved_conflicts = 1 << 3,
report_all = ~0
};

View File

@@ -1,6 +1,6 @@
/* Compute look-ahead criteria for Bison.
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -22,7 +22,7 @@
/* Compute how to make the finite state machine deterministic; find
which rules need lookahead in each state, and which lookahead
which rules need look-ahead in each state, and which look-ahead
tokens they accept. */
#include "system.h"
@@ -215,9 +215,9 @@ add_lookback_edge (state *s, rule *r, int gotono)
{
int ri = state_reduction_find (s, r);
goto_list *sp = MALLOC (sp, 1);
sp->next = lookback[(s->reductions->lookaheads - LA) + ri];
sp->next = lookback[(s->reductions->look_ahead_tokens - LA) + ri];
sp->value = gotono;
lookback[(s->reductions->lookaheads - LA) + ri] = sp;
lookback[(s->reductions->look_ahead_tokens - LA) + ri] = sp;
}
@@ -306,7 +306,7 @@ compute_FOLLOWS (void)
static void
compute_lookaheads (void)
compute_look_ahead_tokens (void)
{
size_t i;
goto_list *sp;
@@ -324,27 +324,27 @@ compute_lookaheads (void)
}
/*-----------------------------------------------------------.
| Count the number of lookaheads required for S (NLOOKAHEADS |
| member). |
`-----------------------------------------------------------*/
/*-----------------------------------------------------.
| Count the number of look-ahead tokens required for S |
| (N_LOOK_AHEAD_TOKENS member). |
`-----------------------------------------------------*/
static int
state_lookaheads_count (state *s)
state_look_ahead_tokens_count (state *s)
{
int k;
int nlookaheads = 0;
int n_look_ahead_tokens = 0;
reductions *rp = s->reductions;
transitions *sp = s->transitions;
/* We need a lookahead either to distinguish different
/* We need a look-ahead either to distinguish different
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->num > 1
|| (rp->num == 1 && sp->num &&
!TRANSITION_IS_DISABLED (sp, 0) && TRANSITION_IS_SHIFT (sp, 0)))
nlookaheads += rp->num;
n_look_ahead_tokens += rp->num;
else
s->consistent = 1;
@@ -355,13 +355,13 @@ state_lookaheads_count (state *s)
break;
}
return nlookaheads;
return n_look_ahead_tokens;
}
/*----------------------------------------------.
| Compute LA, NLA, and the lookaheads members. |
`----------------------------------------------*/
/*-----------------------------------------------------.
| Compute LA, NLA, and the look_ahead_tokens members. |
`-----------------------------------------------------*/
static void
initialize_LA (void)
@@ -369,10 +369,10 @@ initialize_LA (void)
state_number i;
bitsetv pLA;
/* Compute the total number of reductions requiring a lookahead. */
/* Compute the total number of reductions requiring a look-ahead. */
nLA = 0;
for (i = 0; i < nstates; i++)
nLA += state_lookaheads_count (states[i]);
nLA += state_look_ahead_tokens_count (states[i]);
/* Avoid having to special case 0. */
if (!nLA)
nLA = 1;
@@ -380,54 +380,54 @@ initialize_LA (void)
pLA = LA = bitsetv_create (nLA, ntokens, BITSET_FIXED);
CALLOC (lookback, nLA);
/* Initialize the members LOOKAHEADS for each state which reductions
require lookaheads. */
/* Initialize the members LOOK_AHEAD_TOKENS for each state whose reductions
require look-ahead tokens. */
for (i = 0; i < nstates; i++)
{
int count = state_lookaheads_count (states[i]);
int count = state_look_ahead_tokens_count (states[i]);
if (count)
{
states[i]->reductions->lookaheads = pLA;
states[i]->reductions->look_ahead_tokens = pLA;
pLA += count;
}
}
}
/*---------------------------------------.
| Output the lookaheads for each state. |
`---------------------------------------*/
/*----------------------------------------------.
| Output the look-ahead tokens for each state. |
`----------------------------------------------*/
static void
lookaheads_print (FILE *out)
look_ahead_tokens_print (FILE *out)
{
state_number i;
int j, k;
fprintf (out, "Lookaheads: BEGIN\n");
fprintf (out, "Look-ahead tokens: BEGIN\n");
for (i = 0; i < nstates; ++i)
{
reductions *reds = states[i]->reductions;
bitset_iterator iter;
int nlookaheads = 0;
int n_look_ahead_tokens = 0;
if (reds->lookaheads)
if (reds->look_ahead_tokens)
for (k = 0; k < reds->num; ++k)
if (reds->lookaheads[k])
++nlookaheads;
if (reds->look_ahead_tokens[k])
++n_look_ahead_tokens;
fprintf (out, "State %d: %d lookaheads\n",
i, nlookaheads);
fprintf (out, "State %d: %d look-ahead tokens\n",
i, n_look_ahead_tokens);
if (reds->lookaheads)
if (reds->look_ahead_tokens)
for (j = 0; j < reds->num; ++j)
BITSET_FOR_EACH (iter, reds->lookaheads[j], k, 0)
BITSET_FOR_EACH (iter, reds->look_ahead_tokens[j], k, 0)
{
fprintf (out, " on %d (%s) -> rule %d\n",
k, symbols[k]->tag,
reds->rules[j]->number);
};
}
fprintf (out, "Lookaheads: END\n");
fprintf (out, "Look-ahead tokens: END\n");
}
void
@@ -438,10 +438,10 @@ lalr (void)
initialize_F ();
build_relations ();
compute_FOLLOWS ();
compute_lookaheads ();
compute_look_ahead_tokens ();
if (trace_flag & trace_sets)
lookaheads_print (stderr);
look_ahead_tokens_print (stderr);
}
@@ -450,6 +450,6 @@ lalr_free (void)
{
state_number s;
for (s = 0; s < nstates; ++s)
states[s]->reductions->lookaheads = NULL;
states[s]->reductions->look_ahead_tokens = NULL;
bitsetv_free (LA);
}

View File

@@ -33,12 +33,12 @@
# include "state.h"
/* Compute how to make the finite state machine deterministic; find
which rules need lookahead in each state, and which lookahead
which rules need look-ahead in each state, and which look-ahead
tokens they accept. */
void lalr (void);
/* Release the information related to lookaheads. Can be performed
/* Release the information related to look-ahead tokens. Can be performed
once the action tables are computed. */
void lalr_free (void);

View File

@@ -1,6 +1,6 @@
/* Top level entry point of Bison.
Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000, 2001, 2002
Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000, 2001, 2002, 2004
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -107,7 +107,7 @@ main (int argc, char *argv[])
timevar_pop (TV_LALR);
/* Find and record any conflicts: places where one token of
lookahead is not enough to disambiguate the parsing. In file
look-ahead is not enough to disambiguate the parsing. In file
conflicts. Also resolve s/r conflicts based on precedence
declarations. */
timevar_push (TV_CONFLICTS);
@@ -147,7 +147,7 @@ main (int argc, char *argv[])
if (complaint_issued)
goto finish;
/* Lookaheads are no longer needed. */
/* Look-ahead tokens are no longer needed. */
timevar_push (TV_FREE);
lalr_free ();
timevar_pop (TV_FREE);

View File

@@ -454,7 +454,7 @@ static void
prepare_actions (void)
{
/* Figure out the actions for the specified state, indexed by
lookahead token type. */
look-ahead token type. */
muscle_insert_rule_number_table ("defact", yydefact,
yydefact[0], 1, nstates);

View File

@@ -1,6 +1,6 @@
/* Print information on generated parser, for bison,
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003
Copyright (C) 1984, 1986, 1989, 2000, 2001, 2002, 2003, 2004
Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -39,8 +39,8 @@
#include "state.h"
#include "symtab.h"
static bitset shiftset;
static bitset lookaheadset;
static bitset shift_set;
static bitset look_ahead_set;
#if 0
static void
@@ -111,9 +111,9 @@ print_core (FILE *out, state *s)
for (/* Nothing */; *sp >= 0; ++sp)
fprintf (out, " %s", symbols[*sp]->tag);
/* Display the lookaheads? */
if (report_flag & report_lookaheads)
state_rule_lookaheads_print (s, &rules[r], out);
/* Display the look-ahead tokens? */
if (report_flag & report_look_ahead_tokens)
state_rule_look_ahead_tokens_print (s, &rules[r], out);
fputc ('\n', out);
}
@@ -132,7 +132,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
size_t width = 0;
int i;
/* Compute the width of the lookaheads column. */
/* Compute the width of the look-ahead token column. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
@@ -148,7 +148,7 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
fputc ('\n', out);
width += 2;
/* Report lookaheads and shifts. */
/* Report look-ahead tokens and shifts. */
for (i = 0; i < trans->num; i++)
if (!TRANSITION_IS_DISABLED (trans, i)
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
@@ -180,7 +180,7 @@ print_errs (FILE *out, state *s)
size_t width = 0;
int i;
/* Compute the width of the lookaheads column. */
/* Compute the width of the look-ahead token column. */
for (i = 0; i < errp->num; ++i)
if (errp->symbols[i])
max_length (&width, errp->symbols[i]->tag);
@@ -192,7 +192,7 @@ print_errs (FILE *out, state *s)
fputc ('\n', out);
width += 2;
/* Report lookaheads and errors. */
/* Report look-ahead tokens and errors. */
for (i = 0; i < errp->num; ++i)
if (errp->symbols[i])
{
@@ -218,13 +218,13 @@ state_default_rule (state *s)
int cmax = 0;
int i;
/* No need for a lookahead. */
/* No need for a look-ahead. */
if (s->consistent)
return reds->rules[0];
/* 1. Each reduction is possibly masked by the lookaheads on which
/* 1. Each reduction is possibly masked by the look-ahead tokens on which
we shift (S/R conflicts)... */
bitset_zero (shiftset);
bitset_zero (shift_set);
{
transitions *trans = s->transitions;
FOR_EACH_SHIFT (trans, i)
@@ -233,27 +233,27 @@ state_default_rule (state *s)
default rule. */
if (TRANSITION_IS_ERROR (trans, i))
return NULL;
bitset_set (shiftset, TRANSITION_SYMBOL (trans, i));
bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
}
}
/* 2. Each reduction is possibly masked by the lookaheads on which
/* 2. Each reduction is possibly masked by the look-ahead tokens on which
we raise an error (due to %nonassoc). */
{
errs *errp = s->errs;
for (i = 0; i < errp->num; i++)
if (errp->symbols[i])
bitset_set (shiftset, errp->symbols[i]->number);
bitset_set (shift_set, errp->symbols[i]->number);
}
for (i = 0; i < reds->num; ++i)
{
int count = 0;
/* How many non-masked lookaheads are there for this reduction?
*/
bitset_andn (lookaheadset, reds->lookaheads[i], shiftset);
count = bitset_count (lookaheadset);
/* How many non-masked look-ahead tokens are there for this
reduction? */
bitset_andn (look_ahead_set, reds->look_ahead_tokens[i], shift_set);
count = bitset_count (look_ahead_set);
if (count > cmax)
{
@@ -264,27 +264,27 @@ state_default_rule (state *s)
/* 3. And finally, each reduction is possibly masked by previous
reductions (in R/R conflicts, we keep the first reductions).
*/
bitset_or (shiftset, shiftset, reds->lookaheads[i]);
bitset_or (shift_set, shift_set, reds->look_ahead_tokens[i]);
}
return default_rule;
}
/*--------------------------------------------------------------------.
| Report a reduction of RULE on LOOKAHEADS (which can be `default'). |
| If not ENABLED, the rule is masked by a shift or a reduce (S/R and |
| R/R conflicts). |
`--------------------------------------------------------------------*/
/*--------------------------------------------------------------------------.
| Report a reduction of RULE on LOOK_AHEAD_TOKEN (which can be `default'). |
| If not ENABLED, the rule is masked by a shift or a reduce (S/R and |
| R/R conflicts). |
`--------------------------------------------------------------------------*/
static void
print_reduction (FILE *out, size_t width,
const char *lookahead,
const char *look_ahead_token,
rule *r, bool enabled)
{
int j;
fprintf (out, " %s", lookahead);
for (j = width - strlen (lookahead); j > 0; --j)
fprintf (out, " %s", look_ahead_token);
for (j = width - strlen (look_ahead_token); j > 0; --j)
fputc (' ', out);
if (!enabled)
fputc ('[', out);
@@ -316,21 +316,21 @@ print_reductions (FILE *out, state *s)
default_rule = state_default_rule (s);
bitset_zero (shiftset);
bitset_zero (shift_set);
FOR_EACH_SHIFT (trans, i)
bitset_set (shiftset, TRANSITION_SYMBOL (trans, i));
bitset_set (shift_set, TRANSITION_SYMBOL (trans, i));
/* Compute the width of the lookaheads column. */
/* Compute the width of the look-ahead token column. */
if (default_rule)
width = strlen (_("$default"));
if (reds->lookaheads)
if (reds->look_ahead_tokens)
for (i = 0; i < ntokens; i++)
{
bool count = bitset_test (shiftset, i);
bool count = bitset_test (shift_set, i);
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i))
if (bitset_test (reds->look_ahead_tokens[j], i))
{
if (! count)
{
@@ -352,15 +352,15 @@ print_reductions (FILE *out, state *s)
fputc ('\n', out);
width += 2;
/* Report lookaheads (or $default) and reductions. */
if (reds->lookaheads)
/* Report look-ahead tokens (or $default) and reductions. */
if (reds->look_ahead_tokens)
for (i = 0; i < ntokens; i++)
{
bool defaulted = false;
bool count = bitset_test (shiftset, i);
bool count = bitset_test (shift_set, i);
for (j = 0; j < reds->num; ++j)
if (bitset_test (reds->lookaheads[j], i))
if (bitset_test (reds->look_ahead_tokens[j], i))
{
if (! count)
{
@@ -562,12 +562,12 @@ print_results (void)
if (report_flag & report_itemsets)
new_closure (nritems);
/* Storage for print_reductions. */
shiftset = bitset_create (ntokens, BITSET_FIXED);
lookaheadset = bitset_create (ntokens, BITSET_FIXED);
shift_set = bitset_create (ntokens, BITSET_FIXED);
look_ahead_set = bitset_create (ntokens, BITSET_FIXED);
for (i = 0; i < nstates; i++)
print_state (out, states[i]);
bitset_free (shiftset);
bitset_free (lookaheadset);
bitset_free (shift_set);
bitset_free (look_ahead_set);
if (report_flag & report_itemsets)
free_closure ();

View File

@@ -1,6 +1,6 @@
/* Output a VCG description on generated parser, for Bison,
Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -88,21 +88,21 @@ print_core (struct obstack *oout, state *s)
for (/* Nothing */; *sp >= 0; ++sp)
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
/* Experimental feature: display the lookaheads. */
if (report_flag & report_lookaheads)
/* Experimental feature: display the look-ahead tokens. */
if (report_flag & report_look_ahead_tokens)
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int redno = state_reduction_find (s, &rules[r]);
/* Print them if there are. */
if (reds->lookaheads && redno != -1)
if (reds->look_ahead_tokens && redno != -1)
{
bitset_iterator biter;
int k;
char const *sep = "";
obstack_sgrow (oout, "[");
BITSET_FOR_EACH (biter, reds->lookaheads[redno], k, 0)
BITSET_FOR_EACH (biter, reds->look_ahead_tokens[redno], k, 0)
{
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
sep = ", ";

View File

@@ -102,7 +102,7 @@ reductions_new (int num, rule **reds)
size_t rules_size = num * sizeof *reds;
reductions *res = xmalloc (offsetof (reductions, rules) + rules_size);
res->num = num;
res->lookaheads = NULL;
res->look_ahead_tokens = NULL;
memcpy (res->rules, reds, rules_size);
return res;
}
@@ -219,26 +219,26 @@ state_errs_set (state *s, int num, symbol **tokens)
/*-----------------------------------------------------.
| Print on OUT all the lookaheads such that S wants to |
| reduce R. |
`-----------------------------------------------------*/
/*---------------------------------------------------.
| Print on OUT all the look-ahead tokens such that S |
| wants to reduce R. |
`---------------------------------------------------*/
void
state_rule_lookaheads_print (state *s, rule *r, FILE *out)
state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out)
{
/* Find the reduction we are handling. */
reductions *reds = s->reductions;
int red = state_reduction_find (s, r);
/* Print them if there are. */
if (reds->lookaheads && red != -1)
if (reds->look_ahead_tokens && red != -1)
{
bitset_iterator biter;
int k;
char const *sep = "";
fprintf (out, " [");
BITSET_FOR_EACH (biter, reds->lookaheads[red], k, 0)
BITSET_FOR_EACH (biter, reds->look_ahead_tokens[red], k, 0)
{
fprintf (out, "%s%s", sep, symbols[k]->tag);
sep = ", ";

View File

@@ -46,11 +46,11 @@
Each core contains a vector of NITEMS items which are the indices
in the RITEMS vector of the items that are selected in this state.
The two types of actions are shifts/gotos (push the lookahead token
The two types of actions are shifts/gotos (push the look-ahead token
and read another/goto to the state designated by a nterm) and
reductions (combine the last n things on the stack via a rule,
replace them with the symbol that the rule derives, and leave the
lookahead token alone). When the states are generated, these
look-ahead token alone). When the states are generated, these
actions are represented in two other lists.
Each transition structure describes the possible transitions out
@@ -185,7 +185,7 @@ errs *errs_new (int num, symbol **tokens);
typedef struct
{
short int num;
bitset *lookaheads;
bitset *look_ahead_tokens;
rule *rules[1];
} reductions;
@@ -203,7 +203,7 @@ struct state
reductions *reductions;
errs *errs;
/* Nonzero if no lookahead is needed to decide what to do in state S. */
/* Nonzero if no look-ahead is needed to decide what to do in state S. */
char consistent;
/* If some conflicts were solved thanks to precedence/associativity,
@@ -234,9 +234,9 @@ int state_reduction_find (state *s, rule *r);
/* Set the errs of STATE. */
void state_errs_set (state *s, int num, symbol **errors);
/* Print on OUT all the lookaheads such that this STATE wants to
/* Print on OUT all the look-ahead tokens such that this STATE wants to
reduce R. */
void state_rule_lookaheads_print (state *s, rule *r, FILE *out);
void state_rule_look_ahead_tokens_print (state *s, rule *r, FILE *out);
/* Create/destroy the states hash table. */
void state_hash_new (void);

View File

@@ -194,7 +194,7 @@ conflict_row (state *s)
/* Find all reductions for token J, and record all that do not
match ACTROW[J]. */
for (i = 0; i < reds->num; i += 1)
if (bitset_test (reds->lookaheads[i], j)
if (bitset_test (reds->look_ahead_tokens[i], j)
&& (actrow[j]
!= rule_number_as_item_number (reds->rules[i]->number)))
{
@@ -215,8 +215,8 @@ conflict_row (state *s)
/*------------------------------------------------------------------.
| Decide what to do for each type of token if seen as the lookahead |
| token in specified state. The value returned is used as the |
| Decide what to do for each type of token if seen as the |
| look-ahead in specified state. The value returned is used as the |
| default action (yydefact) for the state. In addition, ACTROW is |
| filled with what to do for each kind of token, index by symbol |
| number, with zero meaning do the default action. The value |
@@ -224,7 +224,7 @@ conflict_row (state *s)
| situation is an error. The parser recognizes this value |
| specially. |
| |
| This is where conflicts are resolved. The loop over lookahead |
| This is where conflicts are resolved. The loop over look-ahead |
| rules considered lower-numbered rules last, and the last rule |
| considered that likes a token gets to handle it. |
| |
@@ -249,17 +249,17 @@ action_row (state *s)
for (i = 0; i < ntokens; i++)
actrow[i] = conflrow[i] = 0;
if (reds->lookaheads)
if (reds->look_ahead_tokens)
{
int j;
bitset_iterator biter;
/* loop over all the rules available here which require
lookahead (in reverse order to give precedence to the first
look-ahead (in reverse order to give precedence to the first
rule) */
for (i = reds->num - 1; i >= 0; --i)
/* and find each token which the rule finds acceptable
to come next */
BITSET_FOR_EACH (biter, reds->lookaheads[i], j, 0)
BITSET_FOR_EACH (biter, reds->look_ahead_tokens[i], j, 0)
{
/* and record this rule as the rule to use if that
token follows. */
@@ -406,7 +406,7 @@ save_row (state_number s)
/*------------------------------------------------------------------.
| Figure out the actions for the specified state, indexed by |
| lookahead token type. |
| look-ahead token type. |
| |
| The YYDEFACT table is output now. The detailed info is saved for |
| putting into YYTABLE later. |

View File

@@ -1,5 +1,5 @@
/* Prepare the LALR and GLR parser tables.
Copyright (C) 2002 Free Software Foundation, Inc.
Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler.
@@ -56,7 +56,7 @@
something else to do.
YYPACT[S] = index in YYTABLE of the portion describing state S.
The lookahead token's type is used to index that portion to find
The look-ahead token's type is used to index that portion to find
out what to do.
If the value in YYTABLE is positive, we shift the token and go to