mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-10 04:43:03 +00:00
global: remove unnecessary horizontal tabs.
This change was made by applying emacs' untabify function to nearly all files in Bison's repository. Required tabs in make files, ChangeLog, regexps, and test code were manually skipped. Other notable exceptions and changes are listed below. * bootstrap: Skip because we sync this with gnulib. * data/m4sugar/foreach.m4 * data/m4sugar/m4sugar.m4: Skip because we sync these with Autoconf. * djgpp: Skip because I don't know how to test djgpp properly, and this code appears to be unmaintained anyway. * README-hacking (Hacking): Specify that tabs should be avoided where not required.
This commit is contained in:
68
src/LR0.c
68
src/LR0.c
@@ -62,7 +62,7 @@ state_list_append (symbol_number sym, size_t core_size, item_number *core)
|
||||
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "state_list_append (state = %d, symbol = %d (%s))\n",
|
||||
nstates, sym, symbols[sym]->tag);
|
||||
nstates, sym, symbols[sym]->tag);
|
||||
|
||||
node->next = NULL;
|
||||
node->state = s;
|
||||
@@ -100,13 +100,13 @@ allocate_itemsets (void)
|
||||
symbols. */
|
||||
size_t count = 0;
|
||||
size_t *symbol_count = xcalloc (nsyms + nuseless_nonterminals,
|
||||
sizeof *symbol_count);
|
||||
sizeof *symbol_count);
|
||||
|
||||
for (r = 0; r < nrules; ++r)
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||
{
|
||||
count++;
|
||||
symbol_count[*rhsp]++;
|
||||
count++;
|
||||
symbol_count[*rhsp]++;
|
||||
}
|
||||
|
||||
/* See comments before new_itemsets. All the vectors of items
|
||||
@@ -187,15 +187,15 @@ new_itemsets (state *s)
|
||||
for (i = 0; i < nitemset; ++i)
|
||||
if (item_number_is_symbol_number (ritem[itemset[i]]))
|
||||
{
|
||||
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
||||
if (!kernel_size[sym])
|
||||
{
|
||||
shift_symbol[nshifts] = sym;
|
||||
nshifts++;
|
||||
}
|
||||
symbol_number sym = item_number_as_symbol_number (ritem[itemset[i]]);
|
||||
if (!kernel_size[sym])
|
||||
{
|
||||
shift_symbol[nshifts] = sym;
|
||||
nshifts++;
|
||||
}
|
||||
|
||||
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
|
||||
kernel_size[sym]++;
|
||||
kernel_base[sym][kernel_size[sym]] = itemset[i] + 1;
|
||||
kernel_size[sym]++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
|
||||
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Entering get_state, symbol = %d (%s)\n",
|
||||
sym, symbols[sym]->tag);
|
||||
sym, symbols[sym]->tag);
|
||||
|
||||
s = state_hash_lookup (core_size, core);
|
||||
if (!s)
|
||||
@@ -228,7 +228,7 @@ get_state (symbol_number sym, size_t core_size, item_number *core)
|
||||
|
||||
/*---------------------------------------------------------------.
|
||||
| Use the information computed by new_itemsets to find the state |
|
||||
| numbers reached by each shift transition from S. |
|
||||
| numbers reached by each shift transition from S. |
|
||||
| |
|
||||
| SHIFTSET is set up as a vector of those states. |
|
||||
`---------------------------------------------------------------*/
|
||||
@@ -248,7 +248,7 @@ append_states (state *s)
|
||||
symbol_number sym = shift_symbol[i];
|
||||
int j;
|
||||
for (j = i; 0 < j && sym < shift_symbol[j - 1]; j--)
|
||||
shift_symbol[j] = shift_symbol[j - 1];
|
||||
shift_symbol[j] = shift_symbol[j - 1];
|
||||
shift_symbol[j] = sym;
|
||||
}
|
||||
|
||||
@@ -277,16 +277,16 @@ save_reductions (state *s)
|
||||
{
|
||||
item_number item = ritem[itemset[i]];
|
||||
if (item_number_is_rule_number (item))
|
||||
{
|
||||
rule_number r = item_number_as_rule_number (item);
|
||||
redset[count++] = &rules[r];
|
||||
if (r == 0)
|
||||
{
|
||||
/* This is "reduce 0", i.e., accept. */
|
||||
aver (!final_state);
|
||||
final_state = s;
|
||||
}
|
||||
}
|
||||
{
|
||||
rule_number r = item_number_as_rule_number (item);
|
||||
redset[count++] = &rules[r];
|
||||
if (r == 0)
|
||||
{
|
||||
/* This is "reduce 0", i.e., accept. */
|
||||
aver (!final_state);
|
||||
final_state = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make a reductions structure and copy the data into it. */
|
||||
@@ -308,14 +308,14 @@ set_states (void)
|
||||
state_list *this = first_state;
|
||||
|
||||
/* Pessimization, but simplification of the code: make sure all
|
||||
the states have valid transitions and reductions members,
|
||||
even if reduced to 0. It is too soon for errs, which are
|
||||
computed later, but set_conflicts. */
|
||||
the states have valid transitions and reductions members,
|
||||
even if reduced to 0. It is too soon for errs, which are
|
||||
computed later, but set_conflicts. */
|
||||
state *s = this->state;
|
||||
if (!s->transitions)
|
||||
state_transitions_set (s, 0, 0);
|
||||
state_transitions_set (s, 0, 0);
|
||||
if (!s->reductions)
|
||||
state_reductions_set (s, 0, 0);
|
||||
state_reductions_set (s, 0, 0);
|
||||
|
||||
states[s->number] = s;
|
||||
|
||||
@@ -349,9 +349,9 @@ generate_states (void)
|
||||
{
|
||||
state *s = list->state;
|
||||
if (trace_flag & trace_automaton)
|
||||
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
||||
s->number,
|
||||
symbols[s->accessing_symbol]->tag);
|
||||
fprintf (stderr, "Processing state %d (reached by %s)\n",
|
||||
s->number,
|
||||
symbols[s->accessing_symbol]->tag);
|
||||
/* Set up itemset for the transitions out of this state. itemset gets a
|
||||
vector of all the items that could be accepted next. */
|
||||
closure (s->items, s->nitems);
|
||||
@@ -363,7 +363,7 @@ generate_states (void)
|
||||
append_states (s);
|
||||
|
||||
/* Create the shifts structures for the shifts to those states,
|
||||
now that the state numbers transitioning to are known. */
|
||||
now that the state numbers transitioning to are known. */
|
||||
state_transitions_set (s, nshifts, shiftset);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ print_closure (char const *title, item_number *array, size_t size)
|
||||
item_number *rp;
|
||||
fprintf (stderr, " %2d: .", array[i]);
|
||||
for (rp = &ritem[array[i]]; *rp >= 0; ++rp)
|
||||
fprintf (stderr, " %s", symbols[*rp]->tag);
|
||||
fprintf (stderr, " %s", symbols[*rp]->tag);
|
||||
fprintf (stderr, " (rule %d)\n", -*rp - 1);
|
||||
}
|
||||
fputs ("\n\n", stderr);
|
||||
@@ -80,10 +80,10 @@ print_firsts (void)
|
||||
bitset_iterator iter;
|
||||
fprintf (stderr, "\t%s firsts\n", symbols[i]->tag);
|
||||
BITSET_FOR_EACH (iter, FIRSTS (i), j, 0)
|
||||
{
|
||||
fprintf (stderr, "\t\t%s\n",
|
||||
symbols[j + ntokens]->tag);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "\t\t%s\n",
|
||||
symbols[j + ntokens]->tag);
|
||||
}
|
||||
}
|
||||
fprintf (stderr, "\n\n");
|
||||
}
|
||||
@@ -101,10 +101,10 @@ print_fderives (void)
|
||||
bitset_iterator iter;
|
||||
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||
BITSET_FOR_EACH (iter, FDERIVES (i), r, 0)
|
||||
{
|
||||
fprintf (stderr, "\t\t%3d ", r);
|
||||
rule_rhs_print (&rules[r], stderr);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "\t\t%3d ", r);
|
||||
rule_rhs_print (&rules[r], stderr);
|
||||
}
|
||||
}
|
||||
fprintf (stderr, "\n\n");
|
||||
}
|
||||
@@ -130,9 +130,9 @@ set_firsts (void)
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
for (j = 0; derives[i - ntokens][j]; ++j)
|
||||
{
|
||||
item_number sym = derives[i - ntokens][j]->rhs[0];
|
||||
if (ISVAR (sym))
|
||||
bitset_set (FIRSTS (i), sym - ntokens);
|
||||
item_number sym = derives[i - ntokens][j]->rhs[0];
|
||||
if (ISVAR (sym))
|
||||
bitset_set (FIRSTS (i), sym - ntokens);
|
||||
}
|
||||
|
||||
if (trace_flag & trace_sets)
|
||||
@@ -168,8 +168,8 @@ set_fderives (void)
|
||||
for (i = ntokens; i < nsyms; ++i)
|
||||
for (j = ntokens; j < nsyms; ++j)
|
||||
if (bitset_test (FIRSTS (i), j - ntokens))
|
||||
for (k = 0; derives[j - ntokens][k]; ++k)
|
||||
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
|
||||
for (k = 0; derives[j - ntokens][k]; ++k)
|
||||
bitset_set (FDERIVES (i), derives[j - ntokens][k]->number);
|
||||
|
||||
if (trace_flag & trace_sets)
|
||||
print_fderives ();
|
||||
@@ -219,11 +219,11 @@ closure (item_number *core, size_t n)
|
||||
{
|
||||
item_number itemno = rules[ruleno].rhs - ritem;
|
||||
while (c < n && core[c] < itemno)
|
||||
{
|
||||
itemset[nitemset] = core[c];
|
||||
nitemset++;
|
||||
c++;
|
||||
}
|
||||
{
|
||||
itemset[nitemset] = core[c];
|
||||
nitemset++;
|
||||
c++;
|
||||
}
|
||||
itemset[nitemset] = itemno;
|
||||
nitemset++;
|
||||
};
|
||||
|
||||
@@ -47,8 +47,8 @@ static unsigned *indent_ptr = 0;
|
||||
static
|
||||
void
|
||||
error_message (location *loc,
|
||||
const char *prefix,
|
||||
const char *message, va_list args)
|
||||
const char *prefix,
|
||||
const char *message, va_list args)
|
||||
{
|
||||
unsigned pos = 0;
|
||||
|
||||
@@ -81,12 +81,12 @@ error_message (location *loc,
|
||||
}
|
||||
|
||||
/** Wrap error_message() with varargs handling. */
|
||||
#define ERROR_MESSAGE(Loc, Prefix, Message) \
|
||||
{ \
|
||||
va_list args; \
|
||||
va_start (args, Message); \
|
||||
error_message (Loc, Prefix, Message, args); \
|
||||
va_end (args); \
|
||||
#define ERROR_MESSAGE(Loc, Prefix, Message) \
|
||||
{ \
|
||||
va_list args; \
|
||||
va_start (args, Message); \
|
||||
error_message (Loc, Prefix, Message, args); \
|
||||
va_end (args); \
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
# include "location.h"
|
||||
|
||||
# ifdef __cplusplus
|
||||
# ifdef __cplusplus
|
||||
extern "C" {
|
||||
# endif
|
||||
|
||||
@@ -86,7 +86,7 @@ void fatal_at (location loc, char const *format, ...)
|
||||
/** Whether an error was reported. */
|
||||
extern bool complaint_issued;
|
||||
|
||||
# ifdef __cplusplus
|
||||
# ifdef __cplusplus
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
242
src/conflicts.c
242
src/conflicts.c
@@ -64,75 +64,75 @@ enum conflict_resolution
|
||||
|
||||
static inline void
|
||||
log_resolution (rule *r, symbol_number token,
|
||||
enum conflict_resolution resolution)
|
||||
enum conflict_resolution resolution)
|
||||
{
|
||||
if (report_flag & report_solved_conflicts)
|
||||
{
|
||||
/* The description of the resolution. */
|
||||
switch (resolution)
|
||||
{
|
||||
case shift_resolution:
|
||||
case right_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as shift"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
{
|
||||
case shift_resolution:
|
||||
case right_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as shift"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case reduce_resolution:
|
||||
case left_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as reduce"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
case reduce_resolution:
|
||||
case left_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as reduce"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as an error"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
}
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
_(" Conflict between rule %d and token %s"
|
||||
" resolved as an error"),
|
||||
r->number,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
}
|
||||
|
||||
/* The reason. */
|
||||
switch (resolution)
|
||||
{
|
||||
case shift_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
" (%s < %s)",
|
||||
r->prec->tag,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
{
|
||||
case shift_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
" (%s < %s)",
|
||||
r->prec->tag,
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case reduce_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
" (%s < %s)",
|
||||
symbols[token]->tag,
|
||||
r->prec->tag);
|
||||
break;
|
||||
case reduce_resolution:
|
||||
obstack_fgrow2 (&solved_conflicts_obstack,
|
||||
" (%s < %s)",
|
||||
symbols[token]->tag,
|
||||
r->prec->tag);
|
||||
break;
|
||||
|
||||
case left_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
" (%%left %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
case left_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
" (%%left %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case right_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
" (%%right %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
case right_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
" (%%right %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
" (%%nonassoc %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
}
|
||||
case nonassoc_resolution:
|
||||
obstack_fgrow1 (&solved_conflicts_obstack,
|
||||
" (%%nonassoc %s)",
|
||||
symbols[token]->tag);
|
||||
break;
|
||||
}
|
||||
|
||||
obstack_sgrow (&solved_conflicts_obstack, ".\n");
|
||||
}
|
||||
@@ -226,7 +226,7 @@ flush_shift (state *s, int token)
|
||||
bitset_reset (lookahead_set, token);
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||
&& TRANSITION_SYMBOL (trans, i) == token)
|
||||
&& TRANSITION_SYMBOL (trans, i) == token)
|
||||
TRANSITION_DISABLE (trans, i);
|
||||
}
|
||||
|
||||
@@ -268,23 +268,23 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
|
||||
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (bitset_test (lookahead_tokens, i)
|
||||
&& bitset_test (lookahead_set, i)
|
||||
&& symbols[i]->prec)
|
||||
&& bitset_test (lookahead_set, i)
|
||||
&& symbols[i]->prec)
|
||||
{
|
||||
/* Shift-reduce conflict occurs for token number i
|
||||
and it has a precedence.
|
||||
The precedence of shifting is that of token i. */
|
||||
if (symbols[i]->prec < redprec)
|
||||
{
|
||||
log_resolution (redrule, i, reduce_resolution);
|
||||
flush_shift (s, i);
|
||||
}
|
||||
else if (symbols[i]->prec > redprec)
|
||||
{
|
||||
log_resolution (redrule, i, shift_resolution);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
}
|
||||
else
|
||||
/* Shift-reduce conflict occurs for token number i
|
||||
and it has a precedence.
|
||||
The precedence of shifting is that of token i. */
|
||||
if (symbols[i]->prec < redprec)
|
||||
{
|
||||
log_resolution (redrule, i, reduce_resolution);
|
||||
flush_shift (s, i);
|
||||
}
|
||||
else if (symbols[i]->prec > redprec)
|
||||
{
|
||||
log_resolution (redrule, i, shift_resolution);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
}
|
||||
else
|
||||
/* Matching precedence levels.
|
||||
For non-defined associativity, keep both: unexpected
|
||||
associativity conflict.
|
||||
@@ -292,32 +292,32 @@ resolve_sr_conflict (state *s, int ruleno, symbol **errors, int *nerrs)
|
||||
For right associativity, keep only the shift.
|
||||
For nonassociativity, keep neither. */
|
||||
|
||||
switch (symbols[i]->assoc)
|
||||
{
|
||||
switch (symbols[i]->assoc)
|
||||
{
|
||||
case undef_assoc:
|
||||
abort ();
|
||||
abort ();
|
||||
|
||||
case precedence_assoc:
|
||||
break;
|
||||
|
||||
case right_assoc:
|
||||
log_resolution (redrule, i, right_resolution);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
break;
|
||||
case right_assoc:
|
||||
log_resolution (redrule, i, right_resolution);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
break;
|
||||
|
||||
case left_assoc:
|
||||
log_resolution (redrule, i, left_resolution);
|
||||
flush_shift (s, i);
|
||||
break;
|
||||
case left_assoc:
|
||||
log_resolution (redrule, i, left_resolution);
|
||||
flush_shift (s, i);
|
||||
break;
|
||||
|
||||
case non_assoc:
|
||||
log_resolution (redrule, i, nonassoc_resolution);
|
||||
flush_shift (s, i);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
/* Record an explicit error for this token. */
|
||||
errors[(*nerrs)++] = symbols[i];
|
||||
break;
|
||||
}
|
||||
case non_assoc:
|
||||
log_resolution (redrule, i, nonassoc_resolution);
|
||||
flush_shift (s, i);
|
||||
flush_reduce (lookahead_tokens, i);
|
||||
/* Record an explicit error for this token. */
|
||||
errors[(*nerrs)++] = symbols[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,7 +350,7 @@ set_conflicts (state *s, symbol **errors)
|
||||
precedence. */
|
||||
for (i = 0; i < reds->num; ++i)
|
||||
if (reds->rules[i]->prec && reds->rules[i]->prec->prec
|
||||
&& !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
|
||||
&& !bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
|
||||
resolve_sr_conflict (s, i, errors, &nerrs);
|
||||
|
||||
if (nerrs)
|
||||
@@ -375,7 +375,7 @@ set_conflicts (state *s, symbol **errors)
|
||||
for (i = 0; i < reds->num; ++i)
|
||||
{
|
||||
if (!bitset_disjoint_p (reds->lookahead_tokens[i], lookahead_set))
|
||||
conflicts[s->number] = 1;
|
||||
conflicts[s->number] = 1;
|
||||
bitset_or (lookahead_set, lookahead_set, reds->lookahead_tokens[i]);
|
||||
}
|
||||
}
|
||||
@@ -404,9 +404,9 @@ conflicts_solve (void)
|
||||
set_conflicts (states[i], errors);
|
||||
|
||||
/* For uniformity of the code, make sure all the states have a valid
|
||||
`errs' member. */
|
||||
`errs' member. */
|
||||
if (!states[i]->errs)
|
||||
states[i]->errs = errs_new (0, 0);
|
||||
states[i]->errs = errs_new (0, 0);
|
||||
}
|
||||
|
||||
free (errors);
|
||||
@@ -475,11 +475,11 @@ 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->lookahead_tokens[j], i))
|
||||
count++;
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
count++;
|
||||
|
||||
if (count >= 2)
|
||||
rrc_count += one_per_token ? 1 : count-1;
|
||||
rrc_count += one_per_token ? 1 : count-1;
|
||||
}
|
||||
|
||||
return rrc_count;
|
||||
@@ -495,7 +495,7 @@ conflict_report (FILE *out, int src_num, int rrc_num)
|
||||
{
|
||||
if (src_num && rrc_num)
|
||||
fprintf (out, _("conflicts: %d shift/reduce, %d reduce/reduce\n"),
|
||||
src_num, rrc_num);
|
||||
src_num, rrc_num);
|
||||
else if (src_num)
|
||||
fprintf (out, _("conflicts: %d shift/reduce\n"), src_num);
|
||||
else if (rrc_num)
|
||||
@@ -516,12 +516,12 @@ conflicts_output (FILE *out)
|
||||
{
|
||||
state *s = states[i];
|
||||
if (conflicts[i])
|
||||
{
|
||||
fprintf (out, _("State %d "), i);
|
||||
conflict_report (out, count_sr_conflicts (s),
|
||||
count_rr_conflicts (s, true));
|
||||
printed_sth = true;
|
||||
}
|
||||
{
|
||||
fprintf (out, _("State %d "), i);
|
||||
conflict_report (out, count_sr_conflicts (s),
|
||||
count_rr_conflicts (s, true));
|
||||
printed_sth = true;
|
||||
}
|
||||
}
|
||||
if (printed_sth)
|
||||
fputs ("\n\n", out);
|
||||
@@ -531,7 +531,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 |
|
||||
| conflict. |
|
||||
| conflict. |
|
||||
`--------------------------------------------------------*/
|
||||
|
||||
int
|
||||
@@ -545,8 +545,8 @@ conflicts_total_count (void)
|
||||
for (i = 0; i < nstates; i++)
|
||||
if (conflicts[i])
|
||||
{
|
||||
count += count_sr_conflicts (states[i]);
|
||||
count += count_rr_conflicts (states[i], false);
|
||||
count += count_sr_conflicts (states[i]);
|
||||
count += count_rr_conflicts (states[i], false);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@@ -576,10 +576,10 @@ conflicts_print (void)
|
||||
|
||||
for (i = 0; i < nstates; i++)
|
||||
if (conflicts[i])
|
||||
{
|
||||
src_total += count_sr_conflicts (states[i]);
|
||||
rrc_total += count_rr_conflicts (states[i], true);
|
||||
}
|
||||
{
|
||||
src_total += count_sr_conflicts (states[i]);
|
||||
rrc_total += count_rr_conflicts (states[i], true);
|
||||
}
|
||||
}
|
||||
|
||||
if (! glr_parser && rrc_total > 0 && expected_rr_conflicts != -1)
|
||||
@@ -611,22 +611,22 @@ conflicts_print (void)
|
||||
if (expected_sr_conflicts == -1 && expected_rr_conflicts == -1)
|
||||
set_warning_issued ();
|
||||
if (! yacc_flag)
|
||||
fprintf (stderr, "%s: ", current_file);
|
||||
fprintf (stderr, "%s: ", current_file);
|
||||
conflict_report (stderr, src_total, rrc_total);
|
||||
}
|
||||
|
||||
if (expected_sr_conflicts != -1 || expected_rr_conflicts != -1)
|
||||
{
|
||||
if (! src_ok)
|
||||
complain (ngettext ("expected %d shift/reduce conflict",
|
||||
"expected %d shift/reduce conflicts",
|
||||
src_expected),
|
||||
src_expected);
|
||||
complain (ngettext ("expected %d shift/reduce conflict",
|
||||
"expected %d shift/reduce conflicts",
|
||||
src_expected),
|
||||
src_expected);
|
||||
if (! rrc_ok)
|
||||
complain (ngettext ("expected %d reduce/reduce conflict",
|
||||
"expected %d reduce/reduce conflicts",
|
||||
rrc_expected),
|
||||
rrc_expected);
|
||||
complain (ngettext ("expected %d reduce/reduce conflict",
|
||||
"expected %d reduce/reduce conflicts",
|
||||
rrc_expected),
|
||||
rrc_expected);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,10 +49,10 @@ print_derives (void)
|
||||
rule **rp;
|
||||
fprintf (stderr, "\t%s derives\n", symbols[i]->tag);
|
||||
for (rp = derives[i - ntokens]; *rp; ++rp)
|
||||
{
|
||||
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
||||
rule_rhs_print (*rp, stderr);
|
||||
}
|
||||
{
|
||||
fprintf (stderr, "\t\t%3d ", (*rp)->user_number);
|
||||
rule_rhs_print (*rp, stderr);
|
||||
}
|
||||
}
|
||||
|
||||
fputs ("\n\n", stderr);
|
||||
@@ -96,10 +96,10 @@ derives_compute (void)
|
||||
rule_list *p = dset[i - ntokens];
|
||||
derives[i - ntokens] = q;
|
||||
while (p)
|
||||
{
|
||||
*q++ = p->value;
|
||||
p = p->next;
|
||||
}
|
||||
{
|
||||
*q++ = p->value;
|
||||
p = p->next;
|
||||
}
|
||||
*q++ = NULL;
|
||||
}
|
||||
|
||||
|
||||
62
src/files.c
62
src/files.c
@@ -200,7 +200,7 @@ compute_exts_from_src (const char *ext)
|
||||
|
||||
static void
|
||||
file_name_split (const char *file_name,
|
||||
const char **base, const char **tab, const char **ext)
|
||||
const char **base, const char **tab, const char **ext)
|
||||
{
|
||||
*base = last_component (file_name);
|
||||
|
||||
@@ -215,9 +215,9 @@ file_name_split (const char *file_name,
|
||||
size_t baselen = *ext - *base;
|
||||
size_t dottablen = 4;
|
||||
if (dottablen < baselen
|
||||
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
||||
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
||||
*tab = *ext - dottablen;
|
||||
&& (strncmp (*ext - dottablen, ".tab", dottablen) == 0
|
||||
|| strncmp (*ext - dottablen, "_tab", dottablen) == 0))
|
||||
*tab = *ext - dottablen;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,44 +239,44 @@ compute_file_name_parts (void)
|
||||
|
||||
/* ALL_BUT_EXT goes up the EXT, excluding it. */
|
||||
all_but_ext =
|
||||
xstrndup (spec_outfile,
|
||||
(strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
|
||||
xstrndup (spec_outfile,
|
||||
(strlen (spec_outfile) - (ext ? strlen (ext) : 0)));
|
||||
|
||||
/* ALL_BUT_TAB_EXT goes up to TAB, excluding it. */
|
||||
all_but_tab_ext =
|
||||
xstrndup (spec_outfile,
|
||||
(strlen (spec_outfile)
|
||||
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
|
||||
xstrndup (spec_outfile,
|
||||
(strlen (spec_outfile)
|
||||
- (tab ? strlen (tab) : (ext ? strlen (ext) : 0))));
|
||||
|
||||
if (ext)
|
||||
compute_exts_from_src (ext);
|
||||
compute_exts_from_src (ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
file_name_split (grammar_file, &base, &tab, &ext);
|
||||
|
||||
if (spec_file_prefix)
|
||||
{
|
||||
/* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
|
||||
dir_prefix =
|
||||
{
|
||||
/* If --file-prefix=foo was specified, ALL_BUT_TAB_EXT = `foo'. */
|
||||
dir_prefix =
|
||||
xstrndup (spec_file_prefix,
|
||||
last_component (spec_file_prefix) - spec_file_prefix);
|
||||
all_but_tab_ext = xstrdup (spec_file_prefix);
|
||||
}
|
||||
all_but_tab_ext = xstrdup (spec_file_prefix);
|
||||
}
|
||||
else if (yacc_flag)
|
||||
{
|
||||
/* If --yacc, then the output is `y.tab.c'. */
|
||||
dir_prefix = xstrdup ("");
|
||||
all_but_tab_ext = xstrdup ("y");
|
||||
}
|
||||
{
|
||||
/* If --yacc, then the output is `y.tab.c'. */
|
||||
dir_prefix = xstrdup ("");
|
||||
all_but_tab_ext = xstrdup ("y");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Otherwise, ALL_BUT_TAB_EXT is computed from the input
|
||||
grammar: `foo/bar.yy' => `bar'. */
|
||||
dir_prefix = xstrdup ("");
|
||||
all_but_tab_ext =
|
||||
xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
|
||||
}
|
||||
{
|
||||
/* Otherwise, ALL_BUT_TAB_EXT is computed from the input
|
||||
grammar: `foo/bar.yy' => `bar'. */
|
||||
dir_prefix = xstrdup ("");
|
||||
all_but_tab_ext =
|
||||
xstrndup (base, (strlen (base) - (ext ? strlen (ext) : 0)));
|
||||
}
|
||||
|
||||
if (language->add_tab)
|
||||
all_but_ext = concat2 (all_but_tab_ext, TAB_EXT);
|
||||
@@ -285,7 +285,7 @@ compute_file_name_parts (void)
|
||||
|
||||
/* Compute the extensions from the grammar file name. */
|
||||
if (ext && !yacc_flag)
|
||||
compute_exts_from_gf (ext);
|
||||
compute_exts_from_gf (ext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -312,20 +312,20 @@ compute_output_file_names (void)
|
||||
if (defines_flag)
|
||||
{
|
||||
if (! spec_defines_file)
|
||||
spec_defines_file = concat2 (all_but_ext, header_extension);
|
||||
spec_defines_file = concat2 (all_but_ext, header_extension);
|
||||
}
|
||||
|
||||
if (graph_flag)
|
||||
{
|
||||
if (! spec_graph_file)
|
||||
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
||||
spec_graph_file = concat2 (all_but_tab_ext, ".dot");
|
||||
output_file_name_check (&spec_graph_file);
|
||||
}
|
||||
|
||||
if (xml_flag)
|
||||
{
|
||||
if (! spec_xml_file)
|
||||
spec_xml_file = concat2 (all_but_tab_ext, ".xml");
|
||||
spec_xml_file = concat2 (all_but_tab_ext, ".xml");
|
||||
output_file_name_check (&spec_xml_file);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,10 +76,10 @@ static struct obstack obstack_for_string;
|
||||
#define STRING_GROW \
|
||||
obstack_grow (&obstack_for_string, yytext, yyleng)
|
||||
|
||||
#define STRING_FINISH \
|
||||
do { \
|
||||
obstack_1grow (&obstack_for_string, '\0'); \
|
||||
last_string = obstack_finish (&obstack_for_string); \
|
||||
#define STRING_FINISH \
|
||||
do { \
|
||||
obstack_1grow (&obstack_for_string, '\0'); \
|
||||
last_string = obstack_finish (&obstack_for_string); \
|
||||
} while (0)
|
||||
|
||||
#define STRING_FREE \
|
||||
|
||||
212
src/getargs.c
212
src/getargs.c
@@ -52,7 +52,7 @@ bool graph_flag;
|
||||
bool xml_flag;
|
||||
bool no_lines_flag;
|
||||
bool token_table_flag;
|
||||
bool yacc_flag; /* for -y */
|
||||
bool yacc_flag; /* for -y */
|
||||
|
||||
bool nondeterministic_parser = false;
|
||||
bool glr_parser = false;
|
||||
@@ -94,32 +94,32 @@ char *program_name;
|
||||
*/
|
||||
static void
|
||||
flags_argmatch (const char *option,
|
||||
const char * const keys[], const int values[],
|
||||
int all, int *flags, char *args)
|
||||
const char * const keys[], const int values[],
|
||||
int all, int *flags, char *args)
|
||||
{
|
||||
if (args)
|
||||
{
|
||||
args = strtok (args, ",");
|
||||
while (args)
|
||||
{
|
||||
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
|
||||
int value = XARGMATCH (option, args + no, keys, values);
|
||||
if (value == 0)
|
||||
{
|
||||
if (no)
|
||||
*flags |= all;
|
||||
else
|
||||
*flags &= ~all;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (no)
|
||||
*flags &= ~value;
|
||||
else
|
||||
*flags |= value;
|
||||
}
|
||||
args = strtok (NULL, ",");
|
||||
}
|
||||
{
|
||||
int no = strncmp (args, "no-", 3) == 0 ? 3 : 0;
|
||||
int value = XARGMATCH (option, args + no, keys, values);
|
||||
if (value == 0)
|
||||
{
|
||||
if (no)
|
||||
*flags |= all;
|
||||
else
|
||||
*flags &= ~all;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (no)
|
||||
*flags &= ~value;
|
||||
else
|
||||
*flags |= value;
|
||||
}
|
||||
args = strtok (NULL, ",");
|
||||
}
|
||||
}
|
||||
else
|
||||
*flags |= all;
|
||||
@@ -135,9 +135,9 @@ flags_argmatch (const char *option,
|
||||
* \arg FlagName_all the all value.
|
||||
* \arg FlagName_flag the flag to update.
|
||||
*/
|
||||
#define FLAGS_ARGMATCH(FlagName, Args) \
|
||||
#define FLAGS_ARGMATCH(FlagName, Args) \
|
||||
flags_argmatch ("--" #FlagName, FlagName ## _args, FlagName ## _types, \
|
||||
FlagName ## _all, &FlagName ## _flag, Args)
|
||||
FlagName ## _all, &FlagName ## _flag, Args)
|
||||
|
||||
|
||||
/*----------------------.
|
||||
@@ -265,13 +265,13 @@ usage (int status)
|
||||
{
|
||||
if (status != 0)
|
||||
fprintf (stderr, _("Try `%s --help' for more information.\n"),
|
||||
program_name);
|
||||
program_name);
|
||||
else
|
||||
{
|
||||
/* For ../build-aux/cross-options.pl to work, use the format:
|
||||
^ -S, --long[=ARGS] (whitespace)
|
||||
A --long option is required.
|
||||
Otherwise, add exceptions to ../build-aux/cross-options.pl. */
|
||||
^ -S, --long[=ARGS] (whitespace)
|
||||
A --long option is required.
|
||||
Otherwise, add exceptions to ../build-aux/cross-options.pl. */
|
||||
|
||||
printf (_("Usage: %s [OPTION]... FILE\n"), program_name);
|
||||
fputs (_("\
|
||||
@@ -379,14 +379,14 @@ version (void)
|
||||
putc ('\n', stdout);
|
||||
|
||||
fprintf (stdout,
|
||||
_("Copyright (C) %d Free Software Foundation, Inc.\n"),
|
||||
PACKAGE_COPYRIGHT_YEAR);
|
||||
_("Copyright (C) %d Free Software Foundation, Inc.\n"),
|
||||
PACKAGE_COPYRIGHT_YEAR);
|
||||
|
||||
fputs (_("\
|
||||
This is free software; see the source for copying conditions. There is NO\n\
|
||||
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
|
||||
"),
|
||||
stdout);
|
||||
stdout);
|
||||
}
|
||||
|
||||
|
||||
@@ -415,12 +415,12 @@ language_argmatch (char const *arg, int prio, location loc)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; valid_languages[i].language[0]; i++)
|
||||
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
||||
{
|
||||
language_prio = prio;
|
||||
language = &valid_languages[i];
|
||||
return;
|
||||
}
|
||||
if (c_strcasecmp (arg, valid_languages[i].language) == 0)
|
||||
{
|
||||
language_prio = prio;
|
||||
language = &valid_languages[i];
|
||||
return;
|
||||
}
|
||||
msg = _("invalid language `%s'");
|
||||
}
|
||||
else if (language_prio == prio)
|
||||
@@ -474,25 +474,25 @@ enum
|
||||
static struct option const long_options[] =
|
||||
{
|
||||
/* Operation modes. */
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "version", no_argument, 0, 'V' },
|
||||
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
|
||||
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
|
||||
{ "help", no_argument, 0, 'h' },
|
||||
{ "version", no_argument, 0, 'V' },
|
||||
{ "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION },
|
||||
{ "print-datadir", no_argument, 0, PRINT_DATADIR_OPTION },
|
||||
{ "warnings", optional_argument, 0, 'W' },
|
||||
|
||||
/* Parser. */
|
||||
{ "name-prefix", required_argument, 0, 'p' },
|
||||
{ "name-prefix", required_argument, 0, 'p' },
|
||||
{ "include", required_argument, 0, 'I' },
|
||||
|
||||
/* Output. */
|
||||
{ "file-prefix", required_argument, 0, 'b' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "output-file", required_argument, 0, 'o' },
|
||||
{ "graph", optional_argument, 0, 'g' },
|
||||
{ "file-prefix", required_argument, 0, 'b' },
|
||||
{ "output", required_argument, 0, 'o' },
|
||||
{ "output-file", required_argument, 0, 'o' },
|
||||
{ "graph", optional_argument, 0, 'g' },
|
||||
{ "xml", optional_argument, 0, 'x' },
|
||||
{ "report", required_argument, 0, 'r' },
|
||||
{ "report", required_argument, 0, 'r' },
|
||||
{ "report-file", required_argument, 0, REPORT_FILE_OPTION },
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
{ "verbose", no_argument, 0, 'v' },
|
||||
|
||||
/* Hidden. */
|
||||
{ "trace", optional_argument, 0, 'T' },
|
||||
@@ -502,13 +502,13 @@ static struct option const long_options[] =
|
||||
|
||||
/* Operation modes. */
|
||||
{ "fixed-output-files", no_argument, 0, 'y' },
|
||||
{ "yacc", no_argument, 0, 'y' },
|
||||
{ "yacc", no_argument, 0, 'y' },
|
||||
|
||||
/* Parser. */
|
||||
{ "debug", no_argument, 0, 't' },
|
||||
{ "define", required_argument, 0, 'D' },
|
||||
{ "debug", no_argument, 0, 't' },
|
||||
{ "define", required_argument, 0, 'D' },
|
||||
{ "force-define", required_argument, 0, 'F' },
|
||||
{ "locations", no_argument, 0, LOCATIONS_OPTION },
|
||||
{ "locations", no_argument, 0, LOCATIONS_OPTION },
|
||||
{ "no-lines", no_argument, 0, 'l' },
|
||||
{ "raw", no_argument, 0, 0 },
|
||||
{ "skeleton", required_argument, 0, 'S' },
|
||||
@@ -545,15 +545,15 @@ getargs (int argc, char *argv[])
|
||||
int c;
|
||||
|
||||
while ((c = getopt_long (argc, argv, short_options, long_options, NULL))
|
||||
!= -1)
|
||||
!= -1)
|
||||
switch (c)
|
||||
{
|
||||
/* ASCII Sorting for short options (i.e., upper case then
|
||||
lower case), and then long-only options. */
|
||||
|
||||
case 0:
|
||||
/* Certain long options cause getopt_long to return 0. */
|
||||
break;
|
||||
/* Certain long options cause getopt_long to return 0. */
|
||||
break;
|
||||
|
||||
case 'D': /* -DNAME[=VALUE]. */
|
||||
case 'F': /* -FNAME[=VALUE]. */
|
||||
@@ -567,37 +567,37 @@ getargs (int argc, char *argv[])
|
||||
c == 'D' ? MUSCLE_PERCENT_DEFINE_D
|
||||
: MUSCLE_PERCENT_DEFINE_F);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
include = AS_FILE_NAME (optarg);
|
||||
break;
|
||||
include = AS_FILE_NAME (optarg);
|
||||
break;
|
||||
|
||||
case 'L':
|
||||
language_argmatch (optarg, command_line_prio,
|
||||
command_line_location ());
|
||||
break;
|
||||
language_argmatch (optarg, command_line_prio,
|
||||
command_line_location ());
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
|
||||
command_line_location ());
|
||||
break;
|
||||
skeleton_arg (AS_FILE_NAME (optarg), command_line_prio,
|
||||
command_line_location ());
|
||||
break;
|
||||
|
||||
case 'T':
|
||||
FLAGS_ARGMATCH (trace, optarg);
|
||||
break;
|
||||
FLAGS_ARGMATCH (trace, optarg);
|
||||
break;
|
||||
|
||||
case 'V':
|
||||
version ();
|
||||
exit (EXIT_SUCCESS);
|
||||
version ();
|
||||
exit (EXIT_SUCCESS);
|
||||
|
||||
case 'W':
|
||||
FLAGS_ARGMATCH (warnings, optarg);
|
||||
break;
|
||||
FLAGS_ARGMATCH (warnings, optarg);
|
||||
break;
|
||||
|
||||
case 'b':
|
||||
spec_file_prefix = AS_FILE_NAME (optarg);
|
||||
break;
|
||||
spec_file_prefix = AS_FILE_NAME (optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
/* Here, the -d and --defines options are differentiated. */
|
||||
@@ -607,81 +607,81 @@ getargs (int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 'g':
|
||||
graph_flag = true;
|
||||
if (optarg)
|
||||
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
break;
|
||||
graph_flag = true;
|
||||
if (optarg)
|
||||
spec_graph_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
break;
|
||||
|
||||
case 'h':
|
||||
usage (EXIT_SUCCESS);
|
||||
usage (EXIT_SUCCESS);
|
||||
|
||||
case 'k':
|
||||
token_table_flag = true;
|
||||
break;
|
||||
token_table_flag = true;
|
||||
break;
|
||||
|
||||
case 'l':
|
||||
no_lines_flag = true;
|
||||
break;
|
||||
no_lines_flag = true;
|
||||
break;
|
||||
|
||||
case 'o':
|
||||
spec_outfile = AS_FILE_NAME (optarg);
|
||||
break;
|
||||
spec_outfile = AS_FILE_NAME (optarg);
|
||||
break;
|
||||
|
||||
case 'p':
|
||||
spec_name_prefix = optarg;
|
||||
break;
|
||||
spec_name_prefix = optarg;
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
FLAGS_ARGMATCH (report, optarg);
|
||||
break;
|
||||
FLAGS_ARGMATCH (report, optarg);
|
||||
break;
|
||||
|
||||
case 't':
|
||||
muscle_percent_define_insert ("parse.trace",
|
||||
command_line_location (), "",
|
||||
MUSCLE_PERCENT_DEFINE_D);
|
||||
break;
|
||||
break;
|
||||
|
||||
case 'v':
|
||||
report_flag |= report_states;
|
||||
break;
|
||||
report_flag |= report_states;
|
||||
break;
|
||||
|
||||
case 'x':
|
||||
xml_flag = true;
|
||||
if (optarg)
|
||||
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
break;
|
||||
xml_flag = true;
|
||||
if (optarg)
|
||||
spec_xml_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
yacc_flag = true;
|
||||
break;
|
||||
yacc_flag = true;
|
||||
break;
|
||||
|
||||
case LOCATIONS_OPTION:
|
||||
muscle_percent_define_ensure ("locations",
|
||||
command_line_location (), true);
|
||||
break;
|
||||
break;
|
||||
|
||||
case PRINT_LOCALEDIR_OPTION:
|
||||
printf ("%s\n", LOCALEDIR);
|
||||
exit (EXIT_SUCCESS);
|
||||
printf ("%s\n", LOCALEDIR);
|
||||
exit (EXIT_SUCCESS);
|
||||
|
||||
case PRINT_DATADIR_OPTION:
|
||||
printf ("%s\n", compute_pkgdatadir ());
|
||||
exit (EXIT_SUCCESS);
|
||||
printf ("%s\n", compute_pkgdatadir ());
|
||||
exit (EXIT_SUCCESS);
|
||||
|
||||
case REPORT_FILE_OPTION:
|
||||
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
break;
|
||||
spec_verbose_file = xstrdup (AS_FILE_NAME (optarg));
|
||||
break;
|
||||
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (argc - optind != 1)
|
||||
{
|
||||
if (argc - optind < 1)
|
||||
error (0, 0, _("missing operand after `%s'"), argv[argc - 1]);
|
||||
error (0, 0, _("missing operand after `%s'"), argv[argc - 1]);
|
||||
else
|
||||
error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
|
||||
error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,12 +35,12 @@ extern int skeleton_prio;
|
||||
/* for -I */
|
||||
extern char const *include;
|
||||
|
||||
extern bool defines_flag; /* for -d */
|
||||
extern bool graph_flag; /* for -g */
|
||||
extern bool xml_flag; /* for -x */
|
||||
extern bool no_lines_flag; /* for -l */
|
||||
extern bool token_table_flag; /* for -k */
|
||||
extern bool yacc_flag; /* for -y */
|
||||
extern bool defines_flag; /* for -d */
|
||||
extern bool graph_flag; /* for -g */
|
||||
extern bool xml_flag; /* for -x */
|
||||
extern bool no_lines_flag; /* for -l */
|
||||
extern bool token_table_flag; /* for -k */
|
||||
extern bool yacc_flag; /* for -y */
|
||||
|
||||
|
||||
/* GLR_PARSER is true if the input file says to use the GLR
|
||||
|
||||
72
src/gram.c
72
src/gram.c
@@ -78,7 +78,7 @@ rule_lhs_print (rule *r, symbol *previous_lhs, FILE *out)
|
||||
{
|
||||
int n;
|
||||
for (n = strlen (previous_lhs->tag); n > 0; --n)
|
||||
fputc (' ', out);
|
||||
fputc (' ', out);
|
||||
fputc ('|', out);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ rule_rhs_print (rule *r, FILE *out)
|
||||
{
|
||||
item_number *rp;
|
||||
for (rp = r->rhs; *rp >= 0; rp++)
|
||||
fprintf (out, " %s", symbols[*rp]->tag);
|
||||
fprintf (out, " %s", symbols[*rp]->tag);
|
||||
fputc ('\n', out);
|
||||
}
|
||||
else
|
||||
@@ -123,8 +123,8 @@ rule_rhs_print_xml (rule *r, FILE *out, int level)
|
||||
item_number *rp;
|
||||
xml_puts (out, level, "<rhs>");
|
||||
for (rp = r->rhs; *rp >= 0; rp++)
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[*rp]->tag));
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[*rp]->tag));
|
||||
xml_puts (out, level, "</rhs>");
|
||||
}
|
||||
else
|
||||
@@ -165,7 +165,7 @@ ritem_longest_rhs (void)
|
||||
{
|
||||
int length = rule_rhs_length (&rules[r]);
|
||||
if (length > max)
|
||||
max = length;
|
||||
max = length;
|
||||
}
|
||||
|
||||
return max;
|
||||
@@ -173,7 +173,7 @@ ritem_longest_rhs (void)
|
||||
|
||||
void
|
||||
grammar_rules_partial_print (FILE *out, const char *title,
|
||||
rule_filter filter)
|
||||
rule_filter filter)
|
||||
{
|
||||
rule_number r;
|
||||
bool first = true;
|
||||
@@ -183,11 +183,11 @@ grammar_rules_partial_print (FILE *out, const char *title,
|
||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
if (filter && !filter (&rules[r]))
|
||||
continue;
|
||||
continue;
|
||||
if (first)
|
||||
fprintf (out, "%s\n\n", title);
|
||||
fprintf (out, "%s\n\n", title);
|
||||
else if (previous_lhs && previous_lhs != rules[r].lhs)
|
||||
fputc ('\n', out);
|
||||
fputc ('\n', out);
|
||||
first = false;
|
||||
rule_lhs_print (&rules[r], previous_lhs, out);
|
||||
rule_rhs_print (&rules[r], out);
|
||||
@@ -212,7 +212,7 @@ grammar_rules_print_xml (FILE *out, int level)
|
||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
if (first)
|
||||
xml_puts (out, level + 1, "<rules>");
|
||||
xml_puts (out, level + 1, "<rules>");
|
||||
first = false;
|
||||
{
|
||||
char const *usefulness;
|
||||
@@ -245,8 +245,8 @@ grammar_dump (FILE *out, const char *title)
|
||||
{
|
||||
fprintf (out, "%s\n\n", title);
|
||||
fprintf (out,
|
||||
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
|
||||
ntokens, nvars, nsyms, nrules, nritems);
|
||||
"ntokens = %d, nvars = %d, nsyms = %d, nrules = %d, nritems = %d\n\n",
|
||||
ntokens, nvars, nsyms, nrules, nritems);
|
||||
|
||||
|
||||
fprintf (out, "Variables\n---------\n\n");
|
||||
@@ -256,9 +256,9 @@ grammar_dump (FILE *out, const char *title)
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
fprintf (out, "%5d %5d %5d %s\n",
|
||||
i,
|
||||
symbols[i]->prec, symbols[i]->assoc,
|
||||
symbols[i]->tag);
|
||||
i,
|
||||
symbols[i]->prec, symbols[i]->assoc,
|
||||
symbols[i]->tag);
|
||||
fprintf (out, "\n\n");
|
||||
}
|
||||
|
||||
@@ -268,25 +268,25 @@ grammar_dump (FILE *out, const char *title)
|
||||
fprintf (out, "Num (Prec, Assoc, Useful, Ritem Range) Lhs -> Rhs (Ritem range) [Num]\n");
|
||||
for (i = 0; i < nrules + nuseless_productions; i++)
|
||||
{
|
||||
rule *rule_i = &rules[i];
|
||||
item_number *rp = NULL;
|
||||
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
||||
unsigned int rhs_count = 0;
|
||||
/* Find the last RHS index in ritems. */
|
||||
for (rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
++rhs_count;
|
||||
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
||||
i,
|
||||
rule_i->prec ? rule_i->prec->prec : 0,
|
||||
rule_i->prec ? rule_i->prec->assoc : 0,
|
||||
rule_i->useful,
|
||||
rhs_itemno,
|
||||
rhs_itemno + rhs_count - 1,
|
||||
rule_i->lhs->number);
|
||||
/* Dumped the RHS. */
|
||||
for (rp = rule_i->rhs; *rp >= 0; rp++)
|
||||
fprintf (out, " %3d", *rp);
|
||||
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
|
||||
rule *rule_i = &rules[i];
|
||||
item_number *rp = NULL;
|
||||
unsigned int rhs_itemno = rule_i->rhs - ritem;
|
||||
unsigned int rhs_count = 0;
|
||||
/* Find the last RHS index in ritems. */
|
||||
for (rp = rule_i->rhs; *rp >= 0; ++rp)
|
||||
++rhs_count;
|
||||
fprintf (out, "%3d (%2d, %2d, %2d, %2u-%2u) %2d ->",
|
||||
i,
|
||||
rule_i->prec ? rule_i->prec->prec : 0,
|
||||
rule_i->prec ? rule_i->prec->assoc : 0,
|
||||
rule_i->useful,
|
||||
rhs_itemno,
|
||||
rhs_itemno + rhs_count - 1,
|
||||
rule_i->lhs->number);
|
||||
/* Dumped the RHS. */
|
||||
for (rp = rule_i->rhs; *rp >= 0; rp++)
|
||||
fprintf (out, " %3d", *rp);
|
||||
fprintf (out, " [%d]\n", item_number_as_rule_number (*rp));
|
||||
}
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
@@ -296,8 +296,8 @@ grammar_dump (FILE *out, const char *title)
|
||||
rule_number r;
|
||||
for (r = 0; r < nrules + nuseless_productions; r++)
|
||||
{
|
||||
fprintf (out, "%-5d ", r);
|
||||
rule_print (&rules[r], out);
|
||||
fprintf (out, "%-5d ", r);
|
||||
rule_print (&rules[r], out);
|
||||
}
|
||||
}
|
||||
fprintf (out, "\n\n");
|
||||
|
||||
@@ -105,8 +105,8 @@
|
||||
# include "location.h"
|
||||
# include "symtab.h"
|
||||
|
||||
# define ISTOKEN(i) ((i) < ntokens)
|
||||
# define ISVAR(i) ((i) >= ntokens)
|
||||
# define ISTOKEN(i) ((i) < ntokens)
|
||||
# define ISVAR(i) ((i) >= ntokens)
|
||||
|
||||
extern int nsyms;
|
||||
extern int ntokens;
|
||||
@@ -254,7 +254,7 @@ size_t ritem_longest_rhs (void);
|
||||
|
||||
/* Print the grammar's rules that match FILTER on OUT under TITLE. */
|
||||
void grammar_rules_partial_print (FILE *out, const char *title,
|
||||
rule_filter filter);
|
||||
rule_filter filter);
|
||||
|
||||
/* Print the grammar's useful rules on OUT. */
|
||||
void grammar_rules_print (FILE *out);
|
||||
|
||||
@@ -61,7 +61,7 @@ output_node (int id, char const *label, FILE *fout)
|
||||
|
||||
void
|
||||
output_edge (int source, int destination, char const *label,
|
||||
char const *style, FILE *fout)
|
||||
char const *style, FILE *fout)
|
||||
{
|
||||
fprintf (fout, " %d -> %d [style=%s", source, destination, style);
|
||||
if (label)
|
||||
|
||||
@@ -40,7 +40,7 @@ void output_node (int id, char const *label, FILE *fout);
|
||||
/// \param style Dot style of the edge (e.g., "dotted" or "solid").
|
||||
/// \param fout output stream.
|
||||
void output_edge (int source, int destination, char const *label,
|
||||
char const *style, FILE *fout);
|
||||
char const *style, FILE *fout);
|
||||
|
||||
/// End a Dot graph.
|
||||
/// \param fout output stream.
|
||||
|
||||
170
src/lalr.c
170
src/lalr.c
@@ -85,14 +85,14 @@ set_goto_map (void)
|
||||
transitions *sp = states[s]->transitions;
|
||||
int i;
|
||||
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
||||
{
|
||||
ngotos++;
|
||||
{
|
||||
ngotos++;
|
||||
|
||||
/* Abort if (ngotos + 1) would overflow. */
|
||||
aver (ngotos != GOTO_NUMBER_MAXIMUM);
|
||||
/* Abort if (ngotos + 1) would overflow. */
|
||||
aver (ngotos != GOTO_NUMBER_MAXIMUM);
|
||||
|
||||
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||
}
|
||||
goto_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@@ -100,8 +100,8 @@ set_goto_map (void)
|
||||
int i;
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
{
|
||||
temp_map[i - ntokens] = k;
|
||||
k += goto_map[i - ntokens];
|
||||
temp_map[i - ntokens] = k;
|
||||
k += goto_map[i - ntokens];
|
||||
}
|
||||
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
@@ -119,11 +119,11 @@ set_goto_map (void)
|
||||
transitions *sp = states[s]->transitions;
|
||||
int i;
|
||||
for (i = sp->num - 1; i >= 0 && TRANSITION_IS_GOTO (sp, i); --i)
|
||||
{
|
||||
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||
from_state[k] = s;
|
||||
to_state[k] = sp->states[i]->number;
|
||||
}
|
||||
{
|
||||
goto_number k = temp_map[TRANSITION_SYMBOL (sp, i) - ntokens]++;
|
||||
from_state[k] = s;
|
||||
to_state[k] = sp->states[i]->number;
|
||||
}
|
||||
}
|
||||
|
||||
free (temp_map);
|
||||
@@ -147,11 +147,11 @@ map_goto (state_number s0, symbol_number sym)
|
||||
middle = (low + high) / 2;
|
||||
s = from_state[middle];
|
||||
if (s == s0)
|
||||
return middle;
|
||||
return middle;
|
||||
else if (s < s0)
|
||||
low = middle + 1;
|
||||
low = middle + 1;
|
||||
else
|
||||
high = middle - 1;
|
||||
high = middle - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,24 +174,24 @@ initialize_F (void)
|
||||
|
||||
int j;
|
||||
FOR_EACH_SHIFT (sp, j)
|
||||
bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j));
|
||||
bitset_set (goto_follows[i], TRANSITION_SYMBOL (sp, j));
|
||||
|
||||
for (; j < sp->num; j++)
|
||||
{
|
||||
symbol_number sym = TRANSITION_SYMBOL (sp, j);
|
||||
if (nullable[sym - ntokens])
|
||||
edge[nedges++] = map_goto (stateno, sym);
|
||||
}
|
||||
{
|
||||
symbol_number sym = TRANSITION_SYMBOL (sp, j);
|
||||
if (nullable[sym - ntokens])
|
||||
edge[nedges++] = map_goto (stateno, sym);
|
||||
}
|
||||
|
||||
if (nedges == 0)
|
||||
reads[i] = NULL;
|
||||
reads[i] = NULL;
|
||||
else
|
||||
{
|
||||
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
|
||||
memcpy (reads[i], edge, nedges * sizeof edge[0]);
|
||||
reads[i][nedges] = END_NODE;
|
||||
nedges = 0;
|
||||
}
|
||||
{
|
||||
reads[i] = xnmalloc (nedges + 1, sizeof reads[i][0]);
|
||||
memcpy (reads[i], edge, nedges * sizeof edge[0]);
|
||||
reads[i][nedges] = END_NODE;
|
||||
nedges = 0;
|
||||
}
|
||||
}
|
||||
|
||||
relation_digraph (reads, ngotos, &goto_follows);
|
||||
@@ -232,53 +232,53 @@ build_relations (void)
|
||||
rule **rulep;
|
||||
|
||||
for (rulep = derives[symbol1 - ntokens]; *rulep; rulep++)
|
||||
{
|
||||
bool done;
|
||||
int length = 1;
|
||||
item_number const *rp;
|
||||
state *s = states[from_state[i]];
|
||||
states1[0] = s->number;
|
||||
{
|
||||
bool done;
|
||||
int length = 1;
|
||||
item_number const *rp;
|
||||
state *s = states[from_state[i]];
|
||||
states1[0] = s->number;
|
||||
|
||||
for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
|
||||
{
|
||||
s = transitions_to (s->transitions,
|
||||
item_number_as_symbol_number (*rp));
|
||||
states1[length++] = s->number;
|
||||
}
|
||||
for (rp = (*rulep)->rhs; ! item_number_is_rule_number (*rp); rp++)
|
||||
{
|
||||
s = transitions_to (s->transitions,
|
||||
item_number_as_symbol_number (*rp));
|
||||
states1[length++] = s->number;
|
||||
}
|
||||
|
||||
if (!s->consistent)
|
||||
add_lookback_edge (s, *rulep, i);
|
||||
if (!s->consistent)
|
||||
add_lookback_edge (s, *rulep, i);
|
||||
|
||||
length--;
|
||||
done = false;
|
||||
while (!done)
|
||||
{
|
||||
done = true;
|
||||
/* Each rhs ends in a rule number, and there is a
|
||||
sentinel (ritem[-1]=0) before the first rhs, so it is safe to
|
||||
decrement RP here. */
|
||||
rp--;
|
||||
if (ISVAR (*rp))
|
||||
{
|
||||
/* Downcasting from item_number to symbol_number. */
|
||||
edge[nedges++] = map_goto (states1[--length],
|
||||
item_number_as_symbol_number (*rp));
|
||||
if (nullable[*rp - ntokens])
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
length--;
|
||||
done = false;
|
||||
while (!done)
|
||||
{
|
||||
done = true;
|
||||
/* Each rhs ends in a rule number, and there is a
|
||||
sentinel (ritem[-1]=0) before the first rhs, so it is safe to
|
||||
decrement RP here. */
|
||||
rp--;
|
||||
if (ISVAR (*rp))
|
||||
{
|
||||
/* Downcasting from item_number to symbol_number. */
|
||||
edge[nedges++] = map_goto (states1[--length],
|
||||
item_number_as_symbol_number (*rp));
|
||||
if (nullable[*rp - ntokens])
|
||||
done = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nedges == 0)
|
||||
includes[i] = NULL;
|
||||
includes[i] = NULL;
|
||||
else
|
||||
{
|
||||
int j;
|
||||
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
|
||||
for (j = 0; j < nedges; j++)
|
||||
includes[i][j] = edge[j];
|
||||
includes[i][nedges] = END_NODE;
|
||||
}
|
||||
{
|
||||
int j;
|
||||
includes[i] = xnmalloc (nedges + 1, sizeof includes[i][0]);
|
||||
for (j = 0; j < nedges; j++)
|
||||
includes[i][j] = edge[j];
|
||||
includes[i][nedges] = END_NODE;
|
||||
}
|
||||
}
|
||||
|
||||
free (edge);
|
||||
@@ -398,10 +398,10 @@ initialize_LA (void)
|
||||
state_lookahead_tokens_count (states[i],
|
||||
default_reduction_only_for_accept);
|
||||
if (count)
|
||||
{
|
||||
states[i]->reductions->lookahead_tokens = pLA;
|
||||
pLA += count;
|
||||
}
|
||||
{
|
||||
states[i]->reductions->lookahead_tokens = pLA;
|
||||
pLA += count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -423,21 +423,21 @@ lookahead_tokens_print (FILE *out)
|
||||
int n_lookahead_tokens = 0;
|
||||
|
||||
if (reds->lookahead_tokens)
|
||||
for (k = 0; k < reds->num; ++k)
|
||||
if (reds->lookahead_tokens[k])
|
||||
++n_lookahead_tokens;
|
||||
for (k = 0; k < reds->num; ++k)
|
||||
if (reds->lookahead_tokens[k])
|
||||
++n_lookahead_tokens;
|
||||
|
||||
fprintf (out, "State %d: %d lookahead tokens\n",
|
||||
i, n_lookahead_tokens);
|
||||
i, n_lookahead_tokens);
|
||||
|
||||
if (reds->lookahead_tokens)
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
|
||||
{
|
||||
fprintf (out, " on %d (%s) -> rule %d\n",
|
||||
k, symbols[k]->tag,
|
||||
reds->rules[j]->number);
|
||||
};
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
BITSET_FOR_EACH (iter, reds->lookahead_tokens[j], k, 0)
|
||||
{
|
||||
fprintf (out, " on %d (%s) -> rule %d\n",
|
||||
k, symbols[k]->tag,
|
||||
reds->rules[j]->number);
|
||||
};
|
||||
}
|
||||
fprintf (out, "Lookahead tokens: END\n");
|
||||
}
|
||||
|
||||
162
src/local.mk
162
src/local.mk
@@ -32,91 +32,91 @@ bin_SCRIPTS = $(YACC_SCRIPT)
|
||||
EXTRA_SCRIPTS = src/yacc
|
||||
|
||||
src_bison_CFLAGS = $(AM_CFLAGS) $(WERROR_CFLAGS)
|
||||
src_bison_SOURCES = \
|
||||
src/AnnotationList.c \
|
||||
src/AnnotationList.h \
|
||||
src/InadequacyList.c \
|
||||
src/InadequacyList.h \
|
||||
src/LR0.c \
|
||||
src/LR0.h \
|
||||
src/Sbitset.c \
|
||||
src/Sbitset.h \
|
||||
src/assoc.c \
|
||||
src/assoc.h \
|
||||
src/closure.c \
|
||||
src/closure.h \
|
||||
src/complain.c \
|
||||
src/complain.h \
|
||||
src/conflicts.c \
|
||||
src/conflicts.h \
|
||||
src/derives.c \
|
||||
src/derives.h \
|
||||
src/files.c \
|
||||
src/files.h \
|
||||
src/flex-scanner.h \
|
||||
src/getargs.c \
|
||||
src/getargs.h \
|
||||
src/gram.c \
|
||||
src/gram.h \
|
||||
src/graphviz.c \
|
||||
src/graphviz.h \
|
||||
src/lalr.c \
|
||||
src/lalr.h \
|
||||
src/ielr.c \
|
||||
src/ielr.h \
|
||||
src/location.c \
|
||||
src/location.h \
|
||||
src/main.c \
|
||||
src/muscle-tab.c \
|
||||
src/muscle-tab.h \
|
||||
src/named-ref.c \
|
||||
src/named-ref.h \
|
||||
src/nullable.c \
|
||||
src/nullable.h \
|
||||
src/output.c \
|
||||
src/output.h \
|
||||
src/parse-gram.h \
|
||||
src/parse-gram.y \
|
||||
src/print-xml.c \
|
||||
src/print-xml.h \
|
||||
src/print.c \
|
||||
src/print.h \
|
||||
src/print_graph.c \
|
||||
src/print_graph.h \
|
||||
src/reader.c \
|
||||
src/reader.h \
|
||||
src/reduce.c \
|
||||
src/reduce.h \
|
||||
src/relation.c \
|
||||
src/relation.h \
|
||||
src/scan-code-c.c \
|
||||
src/scan-code.h \
|
||||
src/scan-gram-c.c \
|
||||
src/scan-gram.h \
|
||||
src/scan-skel-c.c \
|
||||
src/scan-skel.h \
|
||||
src/state.c \
|
||||
src/state.h \
|
||||
src/symlist.c \
|
||||
src/symlist.h \
|
||||
src/symtab.c \
|
||||
src/symtab.h \
|
||||
src/system.h \
|
||||
src/tables.c \
|
||||
src/tables.h \
|
||||
src/uniqstr.c \
|
||||
src_bison_SOURCES = \
|
||||
src/AnnotationList.c \
|
||||
src/AnnotationList.h \
|
||||
src/InadequacyList.c \
|
||||
src/InadequacyList.h \
|
||||
src/LR0.c \
|
||||
src/LR0.h \
|
||||
src/Sbitset.c \
|
||||
src/Sbitset.h \
|
||||
src/assoc.c \
|
||||
src/assoc.h \
|
||||
src/closure.c \
|
||||
src/closure.h \
|
||||
src/complain.c \
|
||||
src/complain.h \
|
||||
src/conflicts.c \
|
||||
src/conflicts.h \
|
||||
src/derives.c \
|
||||
src/derives.h \
|
||||
src/files.c \
|
||||
src/files.h \
|
||||
src/flex-scanner.h \
|
||||
src/getargs.c \
|
||||
src/getargs.h \
|
||||
src/gram.c \
|
||||
src/gram.h \
|
||||
src/graphviz.c \
|
||||
src/graphviz.h \
|
||||
src/lalr.c \
|
||||
src/lalr.h \
|
||||
src/ielr.c \
|
||||
src/ielr.h \
|
||||
src/location.c \
|
||||
src/location.h \
|
||||
src/main.c \
|
||||
src/muscle-tab.c \
|
||||
src/muscle-tab.h \
|
||||
src/named-ref.c \
|
||||
src/named-ref.h \
|
||||
src/nullable.c \
|
||||
src/nullable.h \
|
||||
src/output.c \
|
||||
src/output.h \
|
||||
src/parse-gram.h \
|
||||
src/parse-gram.y \
|
||||
src/print-xml.c \
|
||||
src/print-xml.h \
|
||||
src/print.c \
|
||||
src/print.h \
|
||||
src/print_graph.c \
|
||||
src/print_graph.h \
|
||||
src/reader.c \
|
||||
src/reader.h \
|
||||
src/reduce.c \
|
||||
src/reduce.h \
|
||||
src/relation.c \
|
||||
src/relation.h \
|
||||
src/scan-code-c.c \
|
||||
src/scan-code.h \
|
||||
src/scan-gram-c.c \
|
||||
src/scan-gram.h \
|
||||
src/scan-skel-c.c \
|
||||
src/scan-skel.h \
|
||||
src/state.c \
|
||||
src/state.h \
|
||||
src/symlist.c \
|
||||
src/symlist.h \
|
||||
src/symtab.c \
|
||||
src/symtab.h \
|
||||
src/system.h \
|
||||
src/tables.c \
|
||||
src/tables.h \
|
||||
src/uniqstr.c \
|
||||
src/uniqstr.h
|
||||
|
||||
EXTRA_src_bison_SOURCES = \
|
||||
src/scan-code.l \
|
||||
src/scan-gram.l \
|
||||
EXTRA_src_bison_SOURCES = \
|
||||
src/scan-code.l \
|
||||
src/scan-gram.l \
|
||||
src/scan-skel.l
|
||||
|
||||
BUILT_SOURCES += \
|
||||
src/parse-gram.c \
|
||||
src/parse-gram.h \
|
||||
src/scan-code.c \
|
||||
src/scan-gram.c \
|
||||
BUILT_SOURCES += \
|
||||
src/parse-gram.c \
|
||||
src/parse-gram.h \
|
||||
src/scan-code.c \
|
||||
src/scan-gram.c \
|
||||
src/scan-skel.c
|
||||
|
||||
MOSTLYCLEANFILES += src/yacc
|
||||
|
||||
@@ -42,7 +42,7 @@ add_column_width (int column, char const *buf, size_t bufsize)
|
||||
if (buf)
|
||||
{
|
||||
if (INT_MAX / 2 <= bufsize)
|
||||
return INT_MAX;
|
||||
return INT_MAX;
|
||||
width = mbsnwidth (buf, bufsize, 0);
|
||||
}
|
||||
else
|
||||
@@ -69,19 +69,19 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
|
||||
switch (*p)
|
||||
{
|
||||
case '\n':
|
||||
line += line < INT_MAX;
|
||||
column = 1;
|
||||
p0 = p + 1;
|
||||
break;
|
||||
line += line < INT_MAX;
|
||||
column = 1;
|
||||
p0 = p + 1;
|
||||
break;
|
||||
|
||||
case '\t':
|
||||
column = add_column_width (column, p0, p - p0);
|
||||
column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
|
||||
p0 = p + 1;
|
||||
break;
|
||||
column = add_column_width (column, p0, p - p0);
|
||||
column = add_column_width (column, NULL, 8 - ((column - 1) & 7));
|
||||
p0 = p + 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
cur->line = line;
|
||||
|
||||
@@ -73,8 +73,8 @@ static inline bool
|
||||
equal_boundaries (boundary a, boundary b)
|
||||
{
|
||||
return (a.column == b.column
|
||||
&& a.line == b.line
|
||||
&& UNIQSTR_EQ (a.file, b.file));
|
||||
&& a.line == b.line
|
||||
&& UNIQSTR_EQ (a.file, b.file));
|
||||
}
|
||||
|
||||
/* A location, that is, a region of source code. */
|
||||
@@ -96,7 +96,7 @@ extern location const empty_location;
|
||||
/* Set *LOC and adjust scanner cursor to account for token TOKEN of
|
||||
size SIZE. */
|
||||
void location_compute (location *loc,
|
||||
boundary *cur, char const *token, size_t size);
|
||||
boundary *cur, char const *token, size_t size);
|
||||
|
||||
/* Print location to file. Return number of actually printed
|
||||
characters. */
|
||||
|
||||
@@ -80,7 +80,7 @@ muscle_init (void)
|
||||
obstack_init (&muscle_obstack);
|
||||
|
||||
muscle_table = hash_initialize (HT_INITIAL_CAPACITY, NULL, hash_muscle,
|
||||
hash_compare_muscles, muscle_entry_free);
|
||||
hash_compare_muscles, muscle_entry_free);
|
||||
|
||||
/* Version and input file. */
|
||||
MUSCLE_INSERT_STRING ("version", VERSION);
|
||||
@@ -179,7 +179,7 @@ muscle_syncline_grow (char const *key, location loc)
|
||||
char *extension = NULL;
|
||||
obstack_fgrow1 (&muscle_obstack, "]b4_syncline(%d, [[", loc.start.line);
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack,
|
||||
quotearg_style (c_quoting_style, loc.start.file));
|
||||
quotearg_style (c_quoting_style, loc.start.file));
|
||||
obstack_sgrow (&muscle_obstack, "]])[");
|
||||
obstack_1grow (&muscle_obstack, 0);
|
||||
extension = obstack_finish (&muscle_obstack);
|
||||
@@ -202,7 +202,7 @@ muscle_code_grow (const char *key, const char *val, location loc)
|
||||
|
||||
|
||||
void muscle_pair_list_grow (const char *muscle,
|
||||
const char *a1, const char *a2)
|
||||
const char *a1, const char *a2)
|
||||
{
|
||||
char *pair;
|
||||
obstack_sgrow (&muscle_obstack, "[[[");
|
||||
|
||||
@@ -32,40 +32,40 @@ void muscle_free (void);
|
||||
/* An obstack dedicated to receive muscle keys and values. */
|
||||
extern struct obstack muscle_obstack;
|
||||
|
||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||
do { \
|
||||
int v__ = Value; \
|
||||
MUSCLE_INSERT_INT (Key, v__); \
|
||||
#define MUSCLE_INSERT_BOOL(Key, Value) \
|
||||
do { \
|
||||
int v__ = Value; \
|
||||
MUSCLE_INSERT_INT (Key, v__); \
|
||||
} while(0)
|
||||
|
||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
#define MUSCLE_INSERT_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_fgrow1 (&muscle_obstack, "%d", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
|
||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
#define MUSCLE_INSERT_LONG_INT(Key, Value) \
|
||||
do { \
|
||||
obstack_fgrow1 (&muscle_obstack, "%ld", Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
|
||||
/* Key -> Value, but don't apply escaping to Value. */
|
||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||
do { \
|
||||
obstack_sgrow (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
#define MUSCLE_INSERT_STRING_RAW(Key, Value) \
|
||||
do { \
|
||||
obstack_sgrow (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
|
||||
/* Key -> Value, applying M4 escaping to Value. */
|
||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||
do { \
|
||||
#define MUSCLE_INSERT_STRING(Key, Value) \
|
||||
do { \
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, Value); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
|
||||
#define MUSCLE_OBSTACK_SGROW(Obstack, Value) \
|
||||
@@ -74,21 +74,21 @@ do { \
|
||||
for (p__ = Value; *p__; p__++) \
|
||||
switch (*p__) \
|
||||
{ \
|
||||
case '$': obstack_sgrow (Obstack, "$]["); break; \
|
||||
case '@': obstack_sgrow (Obstack, "@@" ); break; \
|
||||
case '[': obstack_sgrow (Obstack, "@{" ); break; \
|
||||
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
||||
case '$': obstack_sgrow (Obstack, "$]["); break; \
|
||||
case '@': obstack_sgrow (Obstack, "@@" ); break; \
|
||||
case '[': obstack_sgrow (Obstack, "@{" ); break; \
|
||||
case ']': obstack_sgrow (Obstack, "@}" ); break; \
|
||||
default: obstack_1grow (Obstack, *p__); break; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||
do { \
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
||||
quotearg_style (c_quoting_style, \
|
||||
Value)); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
#define MUSCLE_INSERT_C_STRING(Key, Value) \
|
||||
do { \
|
||||
MUSCLE_OBSTACK_SGROW (&muscle_obstack, \
|
||||
quotearg_style (c_quoting_style, \
|
||||
Value)); \
|
||||
obstack_1grow (&muscle_obstack, 0); \
|
||||
muscle_insert (Key, obstack_finish (&muscle_obstack)); \
|
||||
} while(0)
|
||||
|
||||
/* Append VALUE to the current value of KEY. If KEY did not already
|
||||
@@ -109,7 +109,7 @@ void muscle_code_grow (const char *key, const char *value, location loc);
|
||||
muscle values are output *double* quoted, one needs to strip the first level
|
||||
of quotes to reach the list itself. */
|
||||
void muscle_pair_list_grow (const char *muscle,
|
||||
const char *a1, const char *a2);
|
||||
const char *a1, const char *a2);
|
||||
|
||||
/* In the format `[[file_name:line.column]], [[file_name:line.column]]', append
|
||||
LOC to MUSCLE. Use digraphs for special characters in each file name. */
|
||||
|
||||
@@ -48,7 +48,7 @@ nullable_print (FILE *out)
|
||||
fputs ("NULLABLE\n", out);
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
fprintf (out, "\t%s: %s\n", symbols[i]->tag,
|
||||
nullable[i - ntokens] ? "yes" : "no");
|
||||
nullable[i - ntokens] ? "yes" : "no");
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
@@ -77,52 +77,52 @@ nullable_compute (void)
|
||||
for (ruleno = 0; ruleno < nrules; ++ruleno)
|
||||
if (rules[ruleno].useful)
|
||||
{
|
||||
rule *rules_ruleno = &rules[ruleno];
|
||||
if (rules_ruleno->rhs[0] >= 0)
|
||||
{
|
||||
/* This rule has a non empty RHS. */
|
||||
item_number *rp = NULL;
|
||||
bool any_tokens = false;
|
||||
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
||||
if (ISTOKEN (*rp))
|
||||
any_tokens = true;
|
||||
rule *rules_ruleno = &rules[ruleno];
|
||||
if (rules_ruleno->rhs[0] >= 0)
|
||||
{
|
||||
/* This rule has a non empty RHS. */
|
||||
item_number *rp = NULL;
|
||||
bool any_tokens = false;
|
||||
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
||||
if (ISTOKEN (*rp))
|
||||
any_tokens = true;
|
||||
|
||||
/* This rule has only nonterminals: schedule it for the second
|
||||
pass. */
|
||||
if (!any_tokens)
|
||||
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
||||
{
|
||||
rcount[ruleno]++;
|
||||
p->next = rsets[*rp - ntokens];
|
||||
p->value = rules_ruleno;
|
||||
rsets[*rp - ntokens] = p;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This rule has an empty RHS. */
|
||||
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
|
||||
== ruleno);
|
||||
if (rules_ruleno->useful
|
||||
&& ! nullable[rules_ruleno->lhs->number - ntokens])
|
||||
{
|
||||
nullable[rules_ruleno->lhs->number - ntokens] = true;
|
||||
*s2++ = rules_ruleno->lhs->number;
|
||||
}
|
||||
}
|
||||
/* This rule has only nonterminals: schedule it for the second
|
||||
pass. */
|
||||
if (!any_tokens)
|
||||
for (rp = rules_ruleno->rhs; *rp >= 0; ++rp)
|
||||
{
|
||||
rcount[ruleno]++;
|
||||
p->next = rsets[*rp - ntokens];
|
||||
p->value = rules_ruleno;
|
||||
rsets[*rp - ntokens] = p;
|
||||
p++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This rule has an empty RHS. */
|
||||
aver (item_number_as_rule_number (rules_ruleno->rhs[0])
|
||||
== ruleno);
|
||||
if (rules_ruleno->useful
|
||||
&& ! nullable[rules_ruleno->lhs->number - ntokens])
|
||||
{
|
||||
nullable[rules_ruleno->lhs->number - ntokens] = true;
|
||||
*s2++ = rules_ruleno->lhs->number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (s1 < s2)
|
||||
for (p = rsets[*s1++ - ntokens]; p; p = p->next)
|
||||
{
|
||||
rule *r = p->value;
|
||||
if (--rcount[r->number] == 0)
|
||||
if (r->useful && ! nullable[r->lhs->number - ntokens])
|
||||
{
|
||||
nullable[r->lhs->number - ntokens] = true;
|
||||
*s2++ = r->lhs->number;
|
||||
}
|
||||
rule *r = p->value;
|
||||
if (--rcount[r->number] == 0)
|
||||
if (r->useful && ! nullable[r->lhs->number - ntokens])
|
||||
{
|
||||
nullable[r->lhs->number - ntokens] = true;
|
||||
*s2++ = r->lhs->number;
|
||||
}
|
||||
}
|
||||
|
||||
free (squeue);
|
||||
|
||||
168
src/output.c
168
src/output.c
@@ -54,51 +54,51 @@ static struct obstack format_obstack;
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
|
||||
\
|
||||
static void \
|
||||
Name (char const *name, \
|
||||
Type *table_data, \
|
||||
Type first, \
|
||||
int begin, \
|
||||
int end) \
|
||||
{ \
|
||||
Type min = first; \
|
||||
Type max = first; \
|
||||
long int lmin; \
|
||||
long int lmax; \
|
||||
int i; \
|
||||
int j = 1; \
|
||||
\
|
||||
obstack_fgrow1 (&format_obstack, "%6d", first); \
|
||||
for (i = begin; i < end; ++i) \
|
||||
{ \
|
||||
obstack_1grow (&format_obstack, ','); \
|
||||
if (j >= 10) \
|
||||
{ \
|
||||
obstack_sgrow (&format_obstack, "\n "); \
|
||||
j = 1; \
|
||||
} \
|
||||
else \
|
||||
++j; \
|
||||
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
|
||||
if (table_data[i] < min) \
|
||||
min = table_data[i]; \
|
||||
if (max < table_data[i]) \
|
||||
max = table_data[i]; \
|
||||
} \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
muscle_insert (name, obstack_finish (&format_obstack)); \
|
||||
\
|
||||
lmin = min; \
|
||||
lmax = max; \
|
||||
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
||||
obstack_fgrow1 (&format_obstack, "%s_min", name); \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
||||
obstack_fgrow1 (&format_obstack, "%s_max", name); \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
||||
#define GENERATE_MUSCLE_INSERT_TABLE(Name, Type) \
|
||||
\
|
||||
static void \
|
||||
Name (char const *name, \
|
||||
Type *table_data, \
|
||||
Type first, \
|
||||
int begin, \
|
||||
int end) \
|
||||
{ \
|
||||
Type min = first; \
|
||||
Type max = first; \
|
||||
long int lmin; \
|
||||
long int lmax; \
|
||||
int i; \
|
||||
int j = 1; \
|
||||
\
|
||||
obstack_fgrow1 (&format_obstack, "%6d", first); \
|
||||
for (i = begin; i < end; ++i) \
|
||||
{ \
|
||||
obstack_1grow (&format_obstack, ','); \
|
||||
if (j >= 10) \
|
||||
{ \
|
||||
obstack_sgrow (&format_obstack, "\n "); \
|
||||
j = 1; \
|
||||
} \
|
||||
else \
|
||||
++j; \
|
||||
obstack_fgrow1 (&format_obstack, "%6d", table_data[i]); \
|
||||
if (table_data[i] < min) \
|
||||
min = table_data[i]; \
|
||||
if (max < table_data[i]) \
|
||||
max = table_data[i]; \
|
||||
} \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
muscle_insert (name, obstack_finish (&format_obstack)); \
|
||||
\
|
||||
lmin = min; \
|
||||
lmax = max; \
|
||||
/* Build `NAME_min' and `NAME_max' in the obstack. */ \
|
||||
obstack_fgrow1 (&format_obstack, "%s_min", name); \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmin); \
|
||||
obstack_fgrow1 (&format_obstack, "%s_max", name); \
|
||||
obstack_1grow (&format_obstack, 0); \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish (&format_obstack), lmax); \
|
||||
}
|
||||
|
||||
GENERATE_MUSCLE_INSERT_TABLE(muscle_insert_unsigned_int_table, unsigned int)
|
||||
@@ -149,9 +149,9 @@ prepare_symbols (void)
|
||||
MUSCLE_INSERT_INT ("user_token_number_max", max_user_token_number);
|
||||
|
||||
muscle_insert_symbol_number_table ("translate",
|
||||
token_translations,
|
||||
token_translations[0],
|
||||
1, max_user_token_number + 1);
|
||||
token_translations,
|
||||
token_translations[0],
|
||||
1, max_user_token_number + 1);
|
||||
|
||||
/* tname -- token names. */
|
||||
{
|
||||
@@ -163,23 +163,23 @@ prepare_symbols (void)
|
||||
set_quoting_flags (qo, QA_SPLIT_TRIGRAPHS);
|
||||
for (i = 0; i < nsyms; i++)
|
||||
{
|
||||
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
|
||||
/* Width of the next token, including the two quotes, the
|
||||
comma and the space. */
|
||||
int width = strlen (cp) + 2;
|
||||
char *cp = quotearg_alloc (symbols[i]->tag, -1, qo);
|
||||
/* Width of the next token, including the two quotes, the
|
||||
comma and the space. */
|
||||
int width = strlen (cp) + 2;
|
||||
|
||||
if (j + width > 75)
|
||||
{
|
||||
obstack_sgrow (&format_obstack, "\n ");
|
||||
j = 1;
|
||||
}
|
||||
if (j + width > 75)
|
||||
{
|
||||
obstack_sgrow (&format_obstack, "\n ");
|
||||
j = 1;
|
||||
}
|
||||
|
||||
if (i)
|
||||
obstack_1grow (&format_obstack, ' ');
|
||||
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
|
||||
if (i)
|
||||
obstack_1grow (&format_obstack, ' ');
|
||||
MUSCLE_OBSTACK_SGROW (&format_obstack, cp);
|
||||
free (cp);
|
||||
obstack_1grow (&format_obstack, ',');
|
||||
j += width;
|
||||
obstack_1grow (&format_obstack, ',');
|
||||
j += width;
|
||||
}
|
||||
free (qo);
|
||||
obstack_sgrow (&format_obstack, " ]b4_null[");
|
||||
@@ -196,7 +196,7 @@ prepare_symbols (void)
|
||||
for (i = 0; i < ntokens; ++i)
|
||||
values[i] = symbols[i]->user_token_number;
|
||||
muscle_insert_int_table ("toknum", values,
|
||||
values[0], 1, ntokens);
|
||||
values[0], 1, ntokens);
|
||||
free (values);
|
||||
}
|
||||
}
|
||||
@@ -264,7 +264,7 @@ prepare_states (void)
|
||||
for (i = 0; i < nstates; ++i)
|
||||
values[i] = states[i]->accessing_symbol;
|
||||
muscle_insert_symbol_number_table ("stos", values,
|
||||
0, 1, nstates);
|
||||
0, 1, nstates);
|
||||
free (values);
|
||||
|
||||
MUSCLE_INSERT_INT ("last", high);
|
||||
@@ -354,11 +354,11 @@ user_actions_output (FILE *out)
|
||||
for (r = 0; r < nrules; ++r)
|
||||
if (rules[r].action)
|
||||
{
|
||||
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
|
||||
rules[r].is_predicate ? "predicate_" : "",
|
||||
r + 1, rules[r].action_location.start.line);
|
||||
escaped_output (out, rules[r].action_location.start.file);
|
||||
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
||||
fprintf (out, "b4_%scase(%d, [b4_syncline(%d, ",
|
||||
rules[r].is_predicate ? "predicate_" : "",
|
||||
r + 1, rules[r].action_location.start.line);
|
||||
escaped_output (out, rules[r].action_location.start.file);
|
||||
fprintf (out, ")\n[ %s]])\n\n", rules[r].action);
|
||||
}
|
||||
fputs ("])\n\n", out);
|
||||
}
|
||||
@@ -377,11 +377,11 @@ merger_output (FILE *out)
|
||||
for (n = 1, p = merge_functions; p != NULL; n += 1, p = p->next)
|
||||
{
|
||||
if (p->type[0] == '\0')
|
||||
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
|
||||
n, p->name);
|
||||
fprintf (out, " case %d: *yy0 = %s (*yy0, *yy1); break;\n",
|
||||
n, p->name);
|
||||
else
|
||||
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
|
||||
n, p->type, p->name);
|
||||
fprintf (out, " case %d: yy0->%s = %s (*yy0, *yy1); break;\n",
|
||||
n, p->type, p->name);
|
||||
}
|
||||
fputs ("]])\n\n", out);
|
||||
}
|
||||
@@ -503,30 +503,30 @@ prepare_actions (void)
|
||||
lookahead token type. */
|
||||
|
||||
muscle_insert_rule_number_table ("defact", yydefact,
|
||||
yydefact[0], 1, nstates);
|
||||
yydefact[0], 1, nstates);
|
||||
|
||||
/* Figure out what to do after reducing with each rule, depending on
|
||||
the saved state from before the beginning of parsing the data
|
||||
that matched this rule. */
|
||||
muscle_insert_state_number_table ("defgoto", yydefgoto,
|
||||
yydefgoto[0], 1, nsyms - ntokens);
|
||||
yydefgoto[0], 1, nsyms - ntokens);
|
||||
|
||||
|
||||
/* Output PACT. */
|
||||
muscle_insert_base_table ("pact", base,
|
||||
base[0], 1, nstates);
|
||||
base[0], 1, nstates);
|
||||
MUSCLE_INSERT_INT ("pact_ninf", base_ninf);
|
||||
|
||||
/* Output PGOTO. */
|
||||
muscle_insert_base_table ("pgoto", base,
|
||||
base[nstates], nstates + 1, nvectors);
|
||||
base[nstates], nstates + 1, nvectors);
|
||||
|
||||
muscle_insert_base_table ("table", table,
|
||||
table[0], 1, high + 1);
|
||||
table[0], 1, high + 1);
|
||||
MUSCLE_INSERT_INT ("table_ninf", table_ninf);
|
||||
|
||||
muscle_insert_base_table ("check", check,
|
||||
check[0], 1, high + 1);
|
||||
check[0], 1, high + 1);
|
||||
|
||||
/* GLR parsing slightly modifies YYTABLE and YYCHECK (and thus
|
||||
YYPACT) so that in states with unresolved conflicts, the default
|
||||
@@ -538,9 +538,9 @@ prepare_actions (void)
|
||||
that case. Nevertheless, it seems even better to be able to use
|
||||
the GLR skeletons even without the non-deterministic tables. */
|
||||
muscle_insert_unsigned_int_table ("conflict_list_heads", conflict_table,
|
||||
conflict_table[0], 1, high + 1);
|
||||
conflict_table[0], 1, high + 1);
|
||||
muscle_insert_unsigned_int_table ("conflicting_rules", conflict_list,
|
||||
0, 1, conflict_list_cnt);
|
||||
0, 1, conflict_list_cnt);
|
||||
}
|
||||
|
||||
|
||||
@@ -587,8 +587,8 @@ output_skeleton (void)
|
||||
while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/')
|
||||
pkgdatadirlen--;
|
||||
full_skeleton = xmalloc (pkgdatadirlen + 1
|
||||
+ (skeleton_size < sizeof m4sugar
|
||||
? sizeof m4sugar : skeleton_size));
|
||||
+ (skeleton_size < sizeof m4sugar
|
||||
? sizeof m4sugar : skeleton_size));
|
||||
strncpy (full_skeleton, pkgdatadir, pkgdatadirlen);
|
||||
full_skeleton[pkgdatadirlen] = '/';
|
||||
strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar);
|
||||
@@ -669,7 +669,7 @@ output_skeleton (void)
|
||||
in = fdopen (filter_fd[0], "r");
|
||||
if (! in)
|
||||
error (EXIT_FAILURE, get_errno (),
|
||||
"fdopen");
|
||||
"fdopen");
|
||||
scan_skel (in);
|
||||
/* scan_skel should have read all of M4's output. Otherwise, when we
|
||||
close the pipe, we risk letting M4 report a broken-pipe to the
|
||||
|
||||
354
src/parse-gram.c
354
src/parse-gram.c
@@ -113,7 +113,7 @@
|
||||
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
||||
|
||||
#define YY_LOCATION_PRINT(File, Loc) \
|
||||
location_print (File, Loc)
|
||||
location_print (File, Loc)
|
||||
|
||||
static void version_check (location const *loc, char const *version);
|
||||
|
||||
@@ -121,7 +121,7 @@ static void version_check (location const *loc, char const *version);
|
||||
FIXME: depends on the undocumented availability of YYLLOC. */
|
||||
#undef yyerror
|
||||
#define yyerror(Msg) \
|
||||
gram_error (&yylloc, Msg)
|
||||
gram_error (&yylloc, Msg)
|
||||
static void gram_error (location const *, char const *);
|
||||
|
||||
static char const *char_name (char);
|
||||
@@ -493,7 +493,7 @@ YYID (yyi)
|
||||
# endif
|
||||
# if (defined __cplusplus && ! defined EXIT_SUCCESS \
|
||||
&& ! ((defined YYMALLOC || defined malloc) \
|
||||
&& (defined YYFREE || defined free)))
|
||||
&& (defined YYFREE || defined free)))
|
||||
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# ifndef EXIT_SUCCESS
|
||||
# define EXIT_SUCCESS 0
|
||||
@@ -520,8 +520,8 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
|
||||
|
||||
#if (! defined yyoverflow \
|
||||
&& (! defined __cplusplus \
|
||||
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
||||
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
||||
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
|
||||
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
|
||||
|
||||
/* A type that is properly aligned for any stack member. */
|
||||
union yyalloc
|
||||
@@ -547,15 +547,15 @@ union yyalloc
|
||||
elements in the stack, and YYPTR gives the new location of the
|
||||
stack. Advance YYPTR to a properly aligned location for the next
|
||||
stack. */
|
||||
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yynewbytes; \
|
||||
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
||||
Stack = &yyptr->Stack_alloc; \
|
||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||
} \
|
||||
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yynewbytes; \
|
||||
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
|
||||
Stack = &yyptr->Stack_alloc; \
|
||||
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
|
||||
yyptr += yynewbytes / sizeof (*yyptr); \
|
||||
} \
|
||||
while (YYID (0))
|
||||
|
||||
#endif
|
||||
@@ -568,13 +568,13 @@ union yyalloc
|
||||
# define YYCOPY(To, From, Count) \
|
||||
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
|
||||
# else
|
||||
# define YYCOPY(To, From, Count) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yyi; \
|
||||
for (yyi = 0; yyi < (Count); yyi++) \
|
||||
(To)[yyi] = (From)[yyi]; \
|
||||
} \
|
||||
# define YYCOPY(To, From, Count) \
|
||||
do \
|
||||
{ \
|
||||
YYSIZE_T yyi; \
|
||||
for (yyi = 0; yyi < (Count); yyi++) \
|
||||
(To)[yyi] = (From)[yyi]; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
# endif
|
||||
# endif
|
||||
@@ -599,7 +599,7 @@ union yyalloc
|
||||
#define YYUNDEFTOK 2
|
||||
#define YYMAXUTOK 311
|
||||
|
||||
#define YYTRANSLATE(YYX) \
|
||||
#define YYTRANSLATE(YYX) \
|
||||
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
@@ -875,14 +875,14 @@ static const yytype_uint8 yyr2[] =
|
||||
};
|
||||
|
||||
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define YYEMPTY (-2)
|
||||
#define YYEOF 0
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
#define yyclearin (yychar = YYEMPTY)
|
||||
#define YYEMPTY (-2)
|
||||
#define YYEOF 0
|
||||
|
||||
#define YYACCEPT goto yyacceptlab
|
||||
#define YYABORT goto yyabortlab
|
||||
#define YYERROR goto yyerrorlab
|
||||
#define YYACCEPT goto yyacceptlab
|
||||
#define YYABORT goto yyabortlab
|
||||
#define YYERROR goto yyerrorlab
|
||||
|
||||
|
||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||
@@ -892,7 +892,7 @@ static const yytype_uint8 yyr2[] =
|
||||
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||
discussed. */
|
||||
|
||||
#define YYFAIL goto yyerrlab
|
||||
#define YYFAIL goto yyerrlab
|
||||
#if defined YYFAIL
|
||||
/* This is here to suppress warnings from the GCC cpp's
|
||||
-Wunused-macros. Normally we don't worry about that warning, but
|
||||
@@ -902,26 +902,26 @@ static const yytype_uint8 yyr2[] =
|
||||
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
|
||||
#define YYBACKUP(Token, Value) \
|
||||
do \
|
||||
if (yychar == YYEMPTY && yylen == 1) \
|
||||
{ \
|
||||
yychar = (Token); \
|
||||
yylval = (Value); \
|
||||
YYPOPSTACK (1); \
|
||||
YY_LAC_DISCARD ("YYBACKUP"); \
|
||||
goto yybackup; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
#define YYBACKUP(Token, Value) \
|
||||
do \
|
||||
if (yychar == YYEMPTY && yylen == 1) \
|
||||
{ \
|
||||
yychar = (Token); \
|
||||
yylval = (Value); \
|
||||
YYPOPSTACK (1); \
|
||||
YY_LAC_DISCARD ("YYBACKUP"); \
|
||||
goto yybackup; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
yyerror (YY_("syntax error: cannot back up")); \
|
||||
YYERROR; \
|
||||
} \
|
||||
YYERROR; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
|
||||
|
||||
#define YYTERROR 1
|
||||
#define YYERRCODE 256
|
||||
#define YYTERROR 1
|
||||
#define YYERRCODE 256
|
||||
|
||||
|
||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
@@ -930,22 +930,22 @@ while (YYID (0))
|
||||
|
||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
|
||||
#ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
if (YYID (N)) \
|
||||
{ \
|
||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).first_line = (Current).last_line = \
|
||||
YYRHSLOC (Rhs, 0).last_line; \
|
||||
(Current).first_column = (Current).last_column = \
|
||||
YYRHSLOC (Rhs, 0).last_column; \
|
||||
} \
|
||||
{ \
|
||||
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
|
||||
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
|
||||
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
|
||||
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).first_line = (Current).last_line = \
|
||||
YYRHSLOC (Rhs, 0).last_line; \
|
||||
(Current).first_column = (Current).last_column = \
|
||||
YYRHSLOC (Rhs, 0).last_column; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
#endif
|
||||
|
||||
@@ -956,10 +956,10 @@ while (YYID (0))
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
fprintf (File, "%d.%d-%d.%d", \
|
||||
(Loc).first_line, (Loc).first_column, \
|
||||
(Loc).last_line, (Loc).last_column)
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
fprintf (File, "%d.%d-%d.%d", \
|
||||
(Loc).first_line, (Loc).first_column, \
|
||||
(Loc).last_line, (Loc).last_column)
|
||||
# else
|
||||
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
|
||||
# endif
|
||||
@@ -982,21 +982,21 @@ while (YYID (0))
|
||||
# define YYFPRINTF fprintf
|
||||
# endif
|
||||
|
||||
# define YYDPRINTF(Args) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
YYFPRINTF Args; \
|
||||
# define YYDPRINTF(Args) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
YYFPRINTF Args; \
|
||||
} while (YYID (0))
|
||||
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value, Location); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value, Location); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (YYID (0))
|
||||
|
||||
|
||||
@@ -1221,7 +1221,7 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1279,10 +1279,10 @@ yy_stack_print (yybottom, yytop)
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
|
||||
# define YY_STACK_PRINT(Bottom, Top) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
yy_stack_print ((Bottom), (Top)); \
|
||||
# define YY_STACK_PRINT(Bottom, Top) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
yy_stack_print ((Bottom), (Top)); \
|
||||
} while (YYID (0))
|
||||
|
||||
|
||||
@@ -1320,9 +1320,9 @@ yy_reduce_print (yyssp, yyvsp, yylsp, yyrule)
|
||||
}
|
||||
}
|
||||
|
||||
# define YY_REDUCE_PRINT(Rule) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
# define YY_REDUCE_PRINT(Rule) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
|
||||
} while (YYID (0))
|
||||
|
||||
@@ -1338,7 +1338,7 @@ int yydebug;
|
||||
|
||||
|
||||
/* YYINITDEPTH -- initial size of the parser's stacks. */
|
||||
#ifndef YYINITDEPTH
|
||||
#ifndef YYINITDEPTH
|
||||
# define YYINITDEPTH 200
|
||||
#endif
|
||||
|
||||
@@ -1657,27 +1657,27 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
switch (*++yyp)
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
goto do_not_strip_quotes;
|
||||
switch (*++yyp)
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
goto do_not_strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
/* Fall through. */
|
||||
default:
|
||||
if (yyres)
|
||||
yyres[yyn] = *yyp;
|
||||
yyn++;
|
||||
break;
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
/* Fall through. */
|
||||
default:
|
||||
if (yyres)
|
||||
yyres[yyn] = *yyp;
|
||||
yyn++;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
if (yyres)
|
||||
yyres[yyn] = '\0';
|
||||
return yyn;
|
||||
}
|
||||
case '"':
|
||||
if (yyres)
|
||||
yyres[yyn] = '\0';
|
||||
return yyn;
|
||||
}
|
||||
do_not_strip_quotes: ;
|
||||
}
|
||||
|
||||
@@ -1858,7 +1858,7 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp)
|
||||
switch (yytype)
|
||||
{
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2043,26 +2043,26 @@ YYLTYPE yylloc;
|
||||
|
||||
#ifdef yyoverflow
|
||||
{
|
||||
/* Give user a chance to reallocate the stack. Use copies of
|
||||
these so that the &'s don't force the real ones into
|
||||
memory. */
|
||||
YYSTYPE *yyvs1 = yyvs;
|
||||
yytype_int16 *yyss1 = yyss;
|
||||
YYLTYPE *yyls1 = yyls;
|
||||
/* Give user a chance to reallocate the stack. Use copies of
|
||||
these so that the &'s don't force the real ones into
|
||||
memory. */
|
||||
YYSTYPE *yyvs1 = yyvs;
|
||||
yytype_int16 *yyss1 = yyss;
|
||||
YYLTYPE *yyls1 = yyls;
|
||||
|
||||
/* Each stack pointer address is followed by the size of the
|
||||
data in use in that stack, in bytes. This used to be a
|
||||
conditional around just the two extra args, but that might
|
||||
be undefined if yyoverflow is a macro. */
|
||||
yyoverflow (YY_("memory exhausted"),
|
||||
&yyss1, yysize * sizeof (*yyssp),
|
||||
&yyvs1, yysize * sizeof (*yyvsp),
|
||||
&yyls1, yysize * sizeof (*yylsp),
|
||||
&yystacksize);
|
||||
/* Each stack pointer address is followed by the size of the
|
||||
data in use in that stack, in bytes. This used to be a
|
||||
conditional around just the two extra args, but that might
|
||||
be undefined if yyoverflow is a macro. */
|
||||
yyoverflow (YY_("memory exhausted"),
|
||||
&yyss1, yysize * sizeof (*yyssp),
|
||||
&yyvs1, yysize * sizeof (*yyvsp),
|
||||
&yyls1, yysize * sizeof (*yylsp),
|
||||
&yystacksize);
|
||||
|
||||
yyls = yyls1;
|
||||
yyss = yyss1;
|
||||
yyvs = yyvs1;
|
||||
yyls = yyls1;
|
||||
yyss = yyss1;
|
||||
yyvs = yyvs1;
|
||||
}
|
||||
#else /* no yyoverflow */
|
||||
# ifndef YYSTACK_RELOCATE
|
||||
@@ -2070,23 +2070,23 @@ YYLTYPE yylloc;
|
||||
# else
|
||||
/* Extend the stack our own way. */
|
||||
if (YYMAXDEPTH <= yystacksize)
|
||||
goto yyexhaustedlab;
|
||||
goto yyexhaustedlab;
|
||||
yystacksize *= 2;
|
||||
if (YYMAXDEPTH < yystacksize)
|
||||
yystacksize = YYMAXDEPTH;
|
||||
yystacksize = YYMAXDEPTH;
|
||||
|
||||
{
|
||||
yytype_int16 *yyss1 = yyss;
|
||||
union yyalloc *yyptr =
|
||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
||||
if (! yyptr)
|
||||
goto yyexhaustedlab;
|
||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
||||
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
||||
yytype_int16 *yyss1 = yyss;
|
||||
union yyalloc *yyptr =
|
||||
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
|
||||
if (! yyptr)
|
||||
goto yyexhaustedlab;
|
||||
YYSTACK_RELOCATE (yyss_alloc, yyss);
|
||||
YYSTACK_RELOCATE (yyvs_alloc, yyvs);
|
||||
YYSTACK_RELOCATE (yyls_alloc, yyls);
|
||||
# undef YYSTACK_RELOCATE
|
||||
if (yyss1 != yyssa)
|
||||
YYSTACK_FREE (yyss1);
|
||||
if (yyss1 != yyssa)
|
||||
YYSTACK_FREE (yyss1);
|
||||
}
|
||||
# endif
|
||||
#endif /* no yyoverflow */
|
||||
@@ -2096,10 +2096,10 @@ YYLTYPE yylloc;
|
||||
yylsp = yyls + yysize - 1;
|
||||
|
||||
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
|
||||
(unsigned long int) yystacksize));
|
||||
(unsigned long int) yystacksize));
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
YYABORT;
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
@@ -2503,7 +2503,7 @@ yyreduce:
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = (yyvsp[0].list); list; list = list->next)
|
||||
symbol_list_destructor_set (list, (yyvsp[-1].code), (yylsp[-1]));
|
||||
symbol_list_destructor_set (list, (yyvsp[-1].code), (yylsp[-1]));
|
||||
symbol_list_free ((yyvsp[0].list));
|
||||
}
|
||||
/* Line 1740 of yacc.c */
|
||||
@@ -2516,7 +2516,7 @@ yyreduce:
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = (yyvsp[0].list); list; list = list->next)
|
||||
symbol_list_printer_set (list, (yyvsp[-1].code), (yylsp[-1]));
|
||||
symbol_list_printer_set (list, (yyvsp[-1].code), (yylsp[-1]));
|
||||
symbol_list_free ((yyvsp[0].list));
|
||||
}
|
||||
/* Line 1740 of yacc.c */
|
||||
@@ -2640,7 +2640,7 @@ yyreduce:
|
||||
symbol_list *list;
|
||||
tag_seen = true;
|
||||
for (list = (yyvsp[0].list); list; list = list->next)
|
||||
symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1]));
|
||||
symbol_type_set (list->content.sym, (yyvsp[-1].uniqstr), (yylsp[-1]));
|
||||
symbol_list_free ((yyvsp[0].list));
|
||||
}
|
||||
/* Line 1740 of yacc.c */
|
||||
@@ -2654,10 +2654,10 @@ yyreduce:
|
||||
symbol_list *list;
|
||||
++current_prec;
|
||||
for (list = (yyvsp[0].list); list; list = list->next)
|
||||
{
|
||||
symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
|
||||
symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
|
||||
}
|
||||
{
|
||||
symbol_type_set (list->content.sym, current_type, (yylsp[-1]));
|
||||
symbol_precedence_set (list->content.sym, current_prec, (yyvsp[-2].assoc), (yylsp[-2]));
|
||||
}
|
||||
symbol_list_free ((yyvsp[0].list));
|
||||
current_type = NULL;
|
||||
}
|
||||
@@ -2917,7 +2917,7 @@ yyreduce:
|
||||
/* Line 1740 of yacc.c */
|
||||
#line 605 "src/parse-gram.y"
|
||||
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
||||
current_lhs_named_ref); }
|
||||
current_lhs_named_ref); }
|
||||
/* Line 1740 of yacc.c */
|
||||
#line 2923 "src/parse-gram.c"
|
||||
break;
|
||||
@@ -3178,20 +3178,20 @@ yyerrlab:
|
||||
if (yyerrstatus == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
error, discard it. */
|
||||
error, discard it. */
|
||||
|
||||
if (yychar <= YYEOF)
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == YYEOF)
|
||||
YYABORT;
|
||||
}
|
||||
{
|
||||
/* Return failure if at end of input. */
|
||||
if (yychar == YYEOF)
|
||||
YYABORT;
|
||||
}
|
||||
else
|
||||
{
|
||||
yydestruct ("Error: discarding",
|
||||
yytoken, &yylval, &yylloc);
|
||||
yychar = YYEMPTY;
|
||||
}
|
||||
{
|
||||
yydestruct ("Error: discarding",
|
||||
yytoken, &yylval, &yylloc);
|
||||
yychar = YYEMPTY;
|
||||
}
|
||||
}
|
||||
|
||||
/* Else will try to reuse lookahead token after shifting the error
|
||||
@@ -3224,29 +3224,29 @@ yyerrorlab:
|
||||
| yyerrlab1 -- common code for both syntax error and YYERROR. |
|
||||
`-------------------------------------------------------------*/
|
||||
yyerrlab1:
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||
yyerrstatus = 3; /* Each real token shifted decrements this. */
|
||||
|
||||
for (;;)
|
||||
{
|
||||
yyn = yypact[yystate];
|
||||
if (!yypact_value_is_default (yyn))
|
||||
{
|
||||
yyn += YYTERROR;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
if (0 < yyn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
yyn += YYTERROR;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
||||
{
|
||||
yyn = yytable[yyn];
|
||||
if (0 < yyn)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Pop the current state because it cannot handle the error token. */
|
||||
if (yyssp == yyss)
|
||||
YYABORT;
|
||||
YYABORT;
|
||||
|
||||
yyerror_range[1] = *yylsp;
|
||||
yydestruct ("Error: popping",
|
||||
yystos[yystate], yyvsp, yylsp);
|
||||
yystos[yystate], yyvsp, yylsp);
|
||||
YYPOPSTACK (1);
|
||||
yystate = *yyssp;
|
||||
YY_STACK_PRINT (yyss, yyssp);
|
||||
@@ -3311,7 +3311,7 @@ yyreturn:
|
||||
while (yyssp != yyss)
|
||||
{
|
||||
yydestruct ("Cleanup: popping",
|
||||
yystos[*yyssp], yyvsp, yylsp);
|
||||
yystos[*yyssp], yyvsp, yylsp);
|
||||
YYPOPSTACK (1);
|
||||
}
|
||||
#ifndef yyoverflow
|
||||
@@ -3355,8 +3355,8 @@ lloc_default (YYLTYPE const *rhs, int n)
|
||||
for (i = 1; i <= n; i++)
|
||||
if (! equal_boundaries (rhs[i].start, rhs[i].end))
|
||||
{
|
||||
loc.start = rhs[i].start;
|
||||
break;
|
||||
loc.start = rhs[i].start;
|
||||
break;
|
||||
}
|
||||
|
||||
return loc;
|
||||
@@ -3399,9 +3399,9 @@ add_param (param_type type, char *decl, location loc)
|
||||
size_t name_len;
|
||||
|
||||
for (name_len = 1;
|
||||
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
||||
name_len++)
|
||||
continue;
|
||||
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
||||
name_len++)
|
||||
continue;
|
||||
|
||||
name = xmalloc (name_len + 1);
|
||||
memcpy (name, name_start, name_len);
|
||||
@@ -3423,7 +3423,7 @@ version_check (location const *loc, char const *version)
|
||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||
{
|
||||
complain_at (*loc, "require bison %s, but have %s",
|
||||
version, PACKAGE_VERSION);
|
||||
version, PACKAGE_VERSION);
|
||||
exit (63);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
static YYLTYPE lloc_default (YYLTYPE const *, int);
|
||||
|
||||
#define YY_LOCATION_PRINT(File, Loc) \
|
||||
location_print (File, Loc)
|
||||
location_print (File, Loc)
|
||||
|
||||
static void version_check (location const *loc, char const *version);
|
||||
|
||||
@@ -45,7 +45,7 @@ static void version_check (location const *loc, char const *version);
|
||||
FIXME: depends on the undocumented availability of YYLLOC. */
|
||||
#undef yyerror
|
||||
#define yyerror(Msg) \
|
||||
gram_error (&yylloc, Msg)
|
||||
gram_error (&yylloc, Msg)
|
||||
static void gram_error (location const *, char const *);
|
||||
|
||||
static char const *char_name (char);
|
||||
@@ -191,9 +191,9 @@ static char const *char_name (char);
|
||||
%type <chars> STRING "%{...%}" EPILOGUE braceless content.opt
|
||||
%type <code> "{...}" "%?{...}"
|
||||
%printer { fputs (quotearg_style (c_quoting_style, $$), stderr); }
|
||||
STRING
|
||||
STRING
|
||||
%printer { fprintf (stderr, "{\n%s\n}", $$); }
|
||||
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
||||
braceless content.opt "{...}" "%{...%}" EPILOGUE
|
||||
|
||||
%type <uniqstr> BRACKETED_ID ID ID_COLON PERCENT_FLAG TAG variable
|
||||
%printer { fputs ($$, stderr); } <uniqstr>
|
||||
@@ -270,9 +270,9 @@ input:
|
||||
;
|
||||
|
||||
|
||||
/*------------------------------------.
|
||||
| Declarations: before the first %%. |
|
||||
`------------------------------------*/
|
||||
/*------------------------------------.
|
||||
| Declarations: before the first %%. |
|
||||
`------------------------------------*/
|
||||
|
||||
prologue_declarations:
|
||||
/* Nothing */
|
||||
@@ -312,7 +312,7 @@ prologue_declaration:
|
||||
MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE);
|
||||
}
|
||||
| "%expect" INT { expected_sr_conflicts = $2; }
|
||||
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
||||
| "%expect-rr" INT { expected_rr_conflicts = $2; }
|
||||
| "%file-prefix" STRING { spec_file_prefix = $2; }
|
||||
| "%file-prefix" "=" STRING { spec_file_prefix = $3; } /* deprecated */
|
||||
| "%glr-parser"
|
||||
@@ -329,11 +329,11 @@ prologue_declaration:
|
||||
muscle_code_grow ("initial_action", action.code, @2);
|
||||
code_scanner_last_string_free ();
|
||||
}
|
||||
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
|
||||
| "%language" STRING { language_argmatch ($2, grammar_prio, @1); }
|
||||
| "%name-prefix" STRING { spec_name_prefix = $2; }
|
||||
| "%name-prefix" "=" STRING { spec_name_prefix = $3; } /* deprecated */
|
||||
| "%no-lines" { no_lines_flag = true; }
|
||||
| "%nondeterministic-parser" { nondeterministic_parser = true; }
|
||||
| "%nondeterministic-parser" { nondeterministic_parser = true; }
|
||||
| "%output" STRING { spec_outfile = $2; }
|
||||
| "%output" "=" STRING { spec_outfile = $3; } /* deprecated */
|
||||
| "%param" { current_param = $1; } params { current_param = param_none; }
|
||||
@@ -389,14 +389,14 @@ grammar_declaration:
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_destructor_set (list, $2, @2);
|
||||
symbol_list_destructor_set (list, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
| "%printer" "{...}" generic_symlist
|
||||
{
|
||||
symbol_list *list;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_list_printer_set (list, $2, @2);
|
||||
symbol_list_printer_set (list, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
| "%default-prec"
|
||||
@@ -461,7 +461,7 @@ symbol_declaration:
|
||||
symbol_list *list;
|
||||
tag_seen = true;
|
||||
for (list = $3; list; list = list->next)
|
||||
symbol_type_set (list->content.sym, $2, @2);
|
||||
symbol_type_set (list->content.sym, $2, @2);
|
||||
symbol_list_free ($3);
|
||||
}
|
||||
;
|
||||
@@ -472,10 +472,10 @@ precedence_declaration:
|
||||
symbol_list *list;
|
||||
++current_prec;
|
||||
for (list = $3; list; list = list->next)
|
||||
{
|
||||
symbol_type_set (list->content.sym, current_type, @2);
|
||||
symbol_precedence_set (list->content.sym, current_prec, $1, @1);
|
||||
}
|
||||
{
|
||||
symbol_type_set (list->content.sym, current_type, @2);
|
||||
symbol_precedence_set (list->content.sym, current_prec, $1, @1);
|
||||
}
|
||||
symbol_list_free ($3);
|
||||
current_type = NULL;
|
||||
}
|
||||
@@ -566,9 +566,9 @@ symbol_defs.1:
|
||||
;
|
||||
|
||||
|
||||
/*------------------------------------------.
|
||||
| The grammar section: between the two %%. |
|
||||
`------------------------------------------*/
|
||||
/*------------------------------------------.
|
||||
| The grammar section: between the two %%. |
|
||||
`------------------------------------------*/
|
||||
|
||||
grammar:
|
||||
rules_or_grammar_declaration
|
||||
@@ -603,7 +603,7 @@ rhses.1:
|
||||
rhs:
|
||||
/* Nothing. */
|
||||
{ grammar_current_rule_begin (current_lhs_symbol, current_lhs_location,
|
||||
current_lhs_named_ref); }
|
||||
current_lhs_named_ref); }
|
||||
| rhs symbol named_ref.opt
|
||||
{ grammar_current_rule_symbol_append ($2, @2, $3); }
|
||||
| rhs "{...}" named_ref.opt
|
||||
@@ -735,8 +735,8 @@ lloc_default (YYLTYPE const *rhs, int n)
|
||||
for (i = 1; i <= n; i++)
|
||||
if (! equal_boundaries (rhs[i].start, rhs[i].end))
|
||||
{
|
||||
loc.start = rhs[i].start;
|
||||
break;
|
||||
loc.start = rhs[i].start;
|
||||
break;
|
||||
}
|
||||
|
||||
return loc;
|
||||
@@ -779,9 +779,9 @@ add_param (param_type type, char *decl, location loc)
|
||||
size_t name_len;
|
||||
|
||||
for (name_len = 1;
|
||||
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
||||
name_len++)
|
||||
continue;
|
||||
memchr (alphanum, name_start[name_len], sizeof alphanum);
|
||||
name_len++)
|
||||
continue;
|
||||
|
||||
name = xmalloc (name_len + 1);
|
||||
memcpy (name, name_start, name_len);
|
||||
@@ -803,7 +803,7 @@ version_check (location const *loc, char const *version)
|
||||
if (strverscmp (version, PACKAGE_VERSION) > 0)
|
||||
{
|
||||
complain_at (*loc, "require bison %s, but have %s",
|
||||
version, PACKAGE_VERSION);
|
||||
version, PACKAGE_VERSION);
|
||||
exit (63);
|
||||
}
|
||||
}
|
||||
|
||||
186
src/print-xml.c
186
src/print-xml.c
@@ -82,36 +82,36 @@ print_core (FILE *out, int level, state *s)
|
||||
sp1 = sp = ritem + sitems[i];
|
||||
|
||||
while (*sp >= 0)
|
||||
sp++;
|
||||
sp++;
|
||||
|
||||
r = item_number_as_rule_number (*sp);
|
||||
sp = rules[r].rhs;
|
||||
|
||||
/* Display the lookahead tokens? */
|
||||
if (item_number_is_rule_number (*sp1))
|
||||
{
|
||||
reductions *reds = s->reductions;
|
||||
int red = state_reduction_find (s, &rules[r]);
|
||||
/* Print item with lookaheads if there are. */
|
||||
if (reds->lookahead_tokens && red != -1)
|
||||
{
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\">",
|
||||
rules[r].number, sp1 - sp);
|
||||
state_rule_lookahead_tokens_print_xml (s, &rules[r],
|
||||
out, level + 2);
|
||||
xml_puts (out, level + 1, "</item>");
|
||||
printed = true;
|
||||
}
|
||||
}
|
||||
{
|
||||
reductions *reds = s->reductions;
|
||||
int red = state_reduction_find (s, &rules[r]);
|
||||
/* Print item with lookaheads if there are. */
|
||||
if (reds->lookahead_tokens && red != -1)
|
||||
{
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\">",
|
||||
rules[r].number, sp1 - sp);
|
||||
state_rule_lookahead_tokens_print_xml (s, &rules[r],
|
||||
out, level + 2);
|
||||
xml_puts (out, level + 1, "</item>");
|
||||
printed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!printed)
|
||||
{
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\"/>",
|
||||
rules[r].number,
|
||||
sp1 - sp);
|
||||
}
|
||||
{
|
||||
xml_printf (out, level + 1,
|
||||
"<item rule-number=\"%d\" point=\"%d\"/>",
|
||||
rules[r].number,
|
||||
sp1 - sp);
|
||||
}
|
||||
}
|
||||
xml_puts (out, level, "</itemset>");
|
||||
}
|
||||
@@ -132,7 +132,7 @@ print_transitions (state *s, FILE *out, int level)
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i))
|
||||
{
|
||||
n++;
|
||||
n++;
|
||||
}
|
||||
|
||||
/* Nothing to report. */
|
||||
@@ -146,28 +146,28 @@ print_transitions (state *s, FILE *out, int level)
|
||||
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||
&& TRANSITION_IS_SHIFT (trans, i))
|
||||
&& TRANSITION_IS_SHIFT (trans, i))
|
||||
{
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
char const *tag = sym->tag;
|
||||
state *s1 = trans->states[i];
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
char const *tag = sym->tag;
|
||||
state *s1 = trans->states[i];
|
||||
|
||||
xml_printf (out, level + 1,
|
||||
"<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
|
||||
xml_escape (tag), s1->number);
|
||||
xml_printf (out, level + 1,
|
||||
"<transition type=\"shift\" symbol=\"%s\" state=\"%d\"/>",
|
||||
xml_escape (tag), s1->number);
|
||||
}
|
||||
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||
&& !TRANSITION_IS_SHIFT (trans, i))
|
||||
&& !TRANSITION_IS_SHIFT (trans, i))
|
||||
{
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
char const *tag = sym->tag;
|
||||
state *s1 = trans->states[i];
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
char const *tag = sym->tag;
|
||||
state *s1 = trans->states[i];
|
||||
|
||||
xml_printf (out, level + 1,
|
||||
"<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
|
||||
xml_escape (tag), s1->number);
|
||||
xml_printf (out, level + 1,
|
||||
"<transition type=\"goto\" symbol=\"%s\" state=\"%d\"/>",
|
||||
xml_escape (tag), s1->number);
|
||||
}
|
||||
|
||||
xml_puts (out, level, "</transitions>");
|
||||
@@ -200,10 +200,10 @@ print_errs (FILE *out, int level, state *s)
|
||||
for (i = 0; i < errp->num; ++i)
|
||||
if (errp->symbols[i])
|
||||
{
|
||||
char const *tag = errp->symbols[i]->tag;
|
||||
xml_printf (out, level + 1,
|
||||
"<error symbol=\"%s\">nonassociative</error>",
|
||||
xml_escape (tag));
|
||||
char const *tag = errp->symbols[i]->tag;
|
||||
xml_printf (out, level + 1,
|
||||
"<error symbol=\"%s\">nonassociative</error>",
|
||||
xml_escape (tag));
|
||||
}
|
||||
xml_puts (out, level, "</errors>");
|
||||
}
|
||||
@@ -217,19 +217,19 @@ print_errs (FILE *out, int level, state *s)
|
||||
|
||||
static void
|
||||
print_reduction (FILE *out, int level, char const *lookahead_token,
|
||||
rule *r, bool enabled)
|
||||
rule *r, bool enabled)
|
||||
{
|
||||
if (r->number)
|
||||
xml_printf (out, level,
|
||||
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
|
||||
xml_escape (lookahead_token),
|
||||
r->number,
|
||||
enabled ? "true" : "false");
|
||||
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
|
||||
xml_escape (lookahead_token),
|
||||
r->number,
|
||||
enabled ? "true" : "false");
|
||||
else
|
||||
xml_printf (out, level,
|
||||
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
|
||||
xml_escape (lookahead_token),
|
||||
enabled ? "true" : "false");
|
||||
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
|
||||
xml_escape (lookahead_token),
|
||||
enabled ? "true" : "false");
|
||||
}
|
||||
|
||||
|
||||
@@ -268,22 +268,22 @@ print_reductions (FILE *out, int level, state *s)
|
||||
if (reds->lookahead_tokens)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
report = true;
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
report = true;
|
||||
}
|
||||
}
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
report = true;
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
report = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing to report. */
|
||||
@@ -298,36 +298,36 @@ print_reductions (FILE *out, int level, state *s)
|
||||
if (reds->lookahead_tokens)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
bool defaulted = false;
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
bool defaulted = false;
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
print_reduction (out, level + 1, symbols[i]->tag,
|
||||
reds->rules[j], true);
|
||||
else
|
||||
defaulted = true;
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (defaulted)
|
||||
print_reduction (out, level + 1, symbols[i]->tag,
|
||||
default_reduction, true);
|
||||
defaulted = false;
|
||||
print_reduction (out, level + 1, symbols[i]->tag,
|
||||
reds->rules[j], false);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
print_reduction (out, level + 1, symbols[i]->tag,
|
||||
reds->rules[j], true);
|
||||
else
|
||||
defaulted = true;
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (defaulted)
|
||||
print_reduction (out, level + 1, symbols[i]->tag,
|
||||
default_reduction, true);
|
||||
defaulted = false;
|
||||
print_reduction (out, level + 1, symbols[i]->tag,
|
||||
reds->rules[j], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (default_reduction)
|
||||
print_reduction (out, level + 1,
|
||||
"$default", default_reduction, true);
|
||||
"$default", default_reduction, true);
|
||||
|
||||
xml_puts (out, level, "</reductions>");
|
||||
}
|
||||
@@ -390,7 +390,7 @@ print_grammar (FILE *out, int level)
|
||||
for (i = 0; i < max_user_token_number + 1; i++)
|
||||
if (token_translations[i] != undeftoken->number)
|
||||
{
|
||||
char const *tag = symbols[token_translations[i]]->tag;
|
||||
char const *tag = symbols[token_translations[i]]->tag;
|
||||
int precedence = symbols[token_translations[i]]->prec;
|
||||
assoc associativity = symbols[token_translations[i]]->assoc;
|
||||
xml_indent (out, level + 2);
|
||||
@@ -414,9 +414,9 @@ print_grammar (FILE *out, int level)
|
||||
{
|
||||
char const *tag = symbols[i]->tag;
|
||||
xml_printf (out, level + 2,
|
||||
"<nonterminal symbol-number=\"%d\" name=\"%s\""
|
||||
"<nonterminal symbol-number=\"%d\" name=\"%s\""
|
||||
" usefulness=\"%s\"/>",
|
||||
i, xml_escape (tag),
|
||||
i, xml_escape (tag),
|
||||
reduce_nonterminal_useless_in_grammar (i)
|
||||
? "useless-in-grammar" : "useful");
|
||||
}
|
||||
@@ -512,7 +512,7 @@ print_xml (void)
|
||||
|
||||
fputc ('\n', out);
|
||||
xml_printf (out, level + 1, "<filename>%s</filename>",
|
||||
xml_escape (grammar_file));
|
||||
xml_escape (grammar_file));
|
||||
|
||||
/* print grammar */
|
||||
print_grammar (out, level + 1);
|
||||
|
||||
248
src/print.c
248
src/print.c
@@ -97,7 +97,7 @@ print_core (FILE *out, state *s)
|
||||
sp1 = sp = ritem + sitems[i];
|
||||
|
||||
while (*sp >= 0)
|
||||
sp++;
|
||||
sp++;
|
||||
|
||||
r = item_number_as_rule_number (*sp);
|
||||
|
||||
@@ -105,15 +105,15 @@ print_core (FILE *out, state *s)
|
||||
previous_lhs = rules[r].lhs;
|
||||
|
||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
fputs (" .", out);
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
fprintf (out, " %s", symbols[*sp]->tag);
|
||||
|
||||
/* Display the lookahead tokens? */
|
||||
if (report_flag & report_lookahead_tokens
|
||||
&& item_number_is_rule_number (*sp1))
|
||||
state_rule_lookahead_tokens_print (s, &rules[r], out);
|
||||
state_rule_lookahead_tokens_print (s, &rules[r], out);
|
||||
|
||||
fputc ('\n', out);
|
||||
}
|
||||
@@ -135,10 +135,10 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
|
||||
/* Compute the width of the lookahead token column. */
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
|
||||
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
|
||||
{
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
max_length (&width, sym->tag);
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
max_length (&width, sym->tag);
|
||||
}
|
||||
|
||||
/* Nothing to report. */
|
||||
@@ -151,20 +151,20 @@ print_transitions (state *s, FILE *out, bool display_transitions_p)
|
||||
/* Report lookahead tokens and shifts. */
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i)
|
||||
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
|
||||
&& TRANSITION_IS_SHIFT (trans, i) == display_transitions_p)
|
||||
{
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
const char *tag = sym->tag;
|
||||
state *s1 = trans->states[i];
|
||||
int j;
|
||||
symbol *sym = symbols[TRANSITION_SYMBOL (trans, i)];
|
||||
const char *tag = sym->tag;
|
||||
state *s1 = trans->states[i];
|
||||
int j;
|
||||
|
||||
fprintf (out, " %s", tag);
|
||||
for (j = width - strlen (tag); j > 0; --j)
|
||||
fputc (' ', out);
|
||||
if (display_transitions_p)
|
||||
fprintf (out, _("shift, and go to state %d\n"), s1->number);
|
||||
else
|
||||
fprintf (out, _("go to state %d\n"), s1->number);
|
||||
fprintf (out, " %s", tag);
|
||||
for (j = width - strlen (tag); j > 0; --j)
|
||||
fputc (' ', out);
|
||||
if (display_transitions_p)
|
||||
fprintf (out, _("shift, and go to state %d\n"), s1->number);
|
||||
else
|
||||
fprintf (out, _("go to state %d\n"), s1->number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,12 +196,12 @@ print_errs (FILE *out, state *s)
|
||||
for (i = 0; i < errp->num; ++i)
|
||||
if (errp->symbols[i])
|
||||
{
|
||||
const char *tag = errp->symbols[i]->tag;
|
||||
int j;
|
||||
fprintf (out, " %s", tag);
|
||||
for (j = width - strlen (tag); j > 0; --j)
|
||||
fputc (' ', out);
|
||||
fputs (_("error (nonassociative)\n"), out);
|
||||
const char *tag = errp->symbols[i]->tag;
|
||||
int j;
|
||||
fprintf (out, " %s", tag);
|
||||
for (j = width - strlen (tag); j > 0; --j)
|
||||
fputc (' ', out);
|
||||
fputs (_("error (nonassociative)\n"), out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,8 +214,8 @@ print_errs (FILE *out, state *s)
|
||||
|
||||
static void
|
||||
print_reduction (FILE *out, size_t width,
|
||||
const char *lookahead_token,
|
||||
rule *r, bool enabled)
|
||||
const char *lookahead_token,
|
||||
rule *r, bool enabled)
|
||||
{
|
||||
int j;
|
||||
fprintf (out, " %s", lookahead_token);
|
||||
@@ -267,22 +267,22 @@ print_reductions (FILE *out, state *s)
|
||||
if (reds->lookahead_tokens)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
max_length (&width, symbols[i]->tag);
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_length (&width, symbols[i]->tag);
|
||||
}
|
||||
}
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
max_length (&width, symbols[i]->tag);
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
max_length (&width, symbols[i]->tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Nothing to report. */
|
||||
@@ -296,40 +296,40 @@ print_reductions (FILE *out, state *s)
|
||||
if (reds->lookahead_tokens)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
{
|
||||
bool defaulted = false;
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
bool defaulted = false;
|
||||
bool count = bitset_test (no_reduce_set, i);
|
||||
if (count)
|
||||
default_reduction_only = false;
|
||||
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
for (j = 0; j < reds->num; ++j)
|
||||
if (bitset_test (reds->lookahead_tokens[j], i))
|
||||
{
|
||||
if (! count)
|
||||
{
|
||||
if (reds->rules[j] != default_reduction)
|
||||
{
|
||||
default_reduction_only = false;
|
||||
print_reduction (out, width,
|
||||
symbols[i]->tag,
|
||||
reds->rules[j], true);
|
||||
}
|
||||
else
|
||||
defaulted = true;
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
defaulted = true;
|
||||
count = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
default_reduction_only = false;
|
||||
if (defaulted)
|
||||
print_reduction (out, width,
|
||||
symbols[i]->tag,
|
||||
default_reduction, true);
|
||||
defaulted = false;
|
||||
print_reduction (out, width,
|
||||
symbols[i]->tag,
|
||||
reds->rules[j], false);
|
||||
}
|
||||
}
|
||||
if (defaulted)
|
||||
print_reduction (out, width,
|
||||
symbols[i]->tag,
|
||||
default_reduction, true);
|
||||
defaulted = false;
|
||||
print_reduction (out, width,
|
||||
symbols[i]->tag,
|
||||
reds->rules[j], false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (default_reduction)
|
||||
@@ -411,25 +411,25 @@ print_grammar (FILE *out)
|
||||
for (i = 0; i < max_user_token_number + 1; i++)
|
||||
if (token_translations[i] != undeftoken->number)
|
||||
{
|
||||
const char *tag = symbols[token_translations[i]]->tag;
|
||||
rule_number r;
|
||||
item_number *rhsp;
|
||||
const char *tag = symbols[token_translations[i]]->tag;
|
||||
rule_number r;
|
||||
item_number *rhsp;
|
||||
|
||||
buffer[0] = 0;
|
||||
column = strlen (tag);
|
||||
fputs (tag, out);
|
||||
END_TEST (65);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
buffer[0] = 0;
|
||||
column = strlen (tag);
|
||||
fputs (tag, out);
|
||||
END_TEST (65);
|
||||
sprintf (buffer, " (%d)", i);
|
||||
|
||||
for (r = 0; r < nrules; r++)
|
||||
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);
|
||||
break;
|
||||
}
|
||||
fprintf (out, "%s\n", buffer);
|
||||
for (r = 0; r < nrules; r++)
|
||||
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);
|
||||
break;
|
||||
}
|
||||
fprintf (out, "%s\n", buffer);
|
||||
}
|
||||
fputs ("\n\n", out);
|
||||
|
||||
@@ -442,17 +442,17 @@ print_grammar (FILE *out)
|
||||
const char *tag = symbols[i]->tag;
|
||||
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
item_number *rhsp;
|
||||
if (rules[r].lhs->number == i)
|
||||
left_count++;
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||
if (item_number_as_symbol_number (*rhsp) == i)
|
||||
{
|
||||
right_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
{
|
||||
item_number *rhsp;
|
||||
if (rules[r].lhs->number == i)
|
||||
left_count++;
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||
if (item_number_as_symbol_number (*rhsp) == i)
|
||||
{
|
||||
right_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
buffer[0] = 0;
|
||||
fputs (tag, out);
|
||||
@@ -461,38 +461,38 @@ print_grammar (FILE *out)
|
||||
END_TEST (0);
|
||||
|
||||
if (left_count > 0)
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), _(" on left:"));
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), _(" on left:"));
|
||||
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
if (rules[r].lhs->number == i)
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), " %d", r);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
if (rules[r].lhs->number == i)
|
||||
{
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), " %d", r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (right_count > 0)
|
||||
{
|
||||
if (left_count > 0)
|
||||
sprintf (buffer + strlen (buffer), ",");
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), _(" on right:"));
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
item_number *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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
if (left_count > 0)
|
||||
sprintf (buffer + strlen (buffer), ",");
|
||||
END_TEST (65);
|
||||
sprintf (buffer + strlen (buffer), _(" on right:"));
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
item_number *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);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
fprintf (out, "%s\n", buffer);
|
||||
}
|
||||
}
|
||||
@@ -508,7 +508,7 @@ print_results (void)
|
||||
|
||||
reduce_output (out);
|
||||
grammar_rules_partial_print (out,
|
||||
_("Rules useless in parser due to conflicts"),
|
||||
_("Rules useless in parser due to conflicts"),
|
||||
rule_useless_in_parser_p);
|
||||
conflicts_output (out);
|
||||
|
||||
|
||||
@@ -66,43 +66,43 @@ print_core (struct obstack *oout, state *s)
|
||||
sp1 = sp = ritem + sitems[i];
|
||||
|
||||
while (*sp >= 0)
|
||||
sp++;
|
||||
sp++;
|
||||
|
||||
r = item_number_as_rule_number (*sp);
|
||||
|
||||
obstack_fgrow1 (oout, "\n%s -> ", rules[r].lhs->tag);
|
||||
|
||||
for (sp = rules[r].rhs; sp < sp1; sp++)
|
||||
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
|
||||
obstack_fgrow1 (oout, "%s ", symbols[*sp]->tag);
|
||||
|
||||
obstack_1grow (oout, '.');
|
||||
|
||||
for (/* Nothing */; *sp >= 0; ++sp)
|
||||
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
|
||||
obstack_fgrow1 (oout, " %s", symbols[*sp]->tag);
|
||||
|
||||
/* Experimental feature: display the lookahead tokens. */
|
||||
if (report_flag & report_lookahead_tokens
|
||||
&& item_number_is_rule_number (*sp1))
|
||||
{
|
||||
/* Find the reduction we are handling. */
|
||||
reductions *reds = s->reductions;
|
||||
int redno = state_reduction_find (s, &rules[r]);
|
||||
{
|
||||
/* 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->lookahead_tokens && redno != -1)
|
||||
{
|
||||
bitset_iterator biter;
|
||||
int k;
|
||||
char const *sep = "";
|
||||
obstack_sgrow (oout, "[");
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
||||
{
|
||||
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
obstack_sgrow (oout, "]");
|
||||
}
|
||||
}
|
||||
/* Print them if there are. */
|
||||
if (reds->lookahead_tokens && redno != -1)
|
||||
{
|
||||
bitset_iterator biter;
|
||||
int k;
|
||||
char const *sep = "";
|
||||
obstack_sgrow (oout, "[");
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[redno], k, 0)
|
||||
{
|
||||
obstack_fgrow2 (oout, "%s%s", sep, symbols[k]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
obstack_sgrow (oout, "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,21 +125,21 @@ print_actions (state const *s, FILE *fgraph)
|
||||
for (i = 0; i < trans->num; i++)
|
||||
if (!TRANSITION_IS_DISABLED (trans, i))
|
||||
{
|
||||
state *s1 = trans->states[i];
|
||||
symbol_number sym = s1->accessing_symbol;
|
||||
state *s1 = trans->states[i];
|
||||
symbol_number sym = s1->accessing_symbol;
|
||||
|
||||
/* Shifts are solid, gotos are dashed, and error is dotted. */
|
||||
char const *style =
|
||||
(TRANSITION_IS_ERROR (trans, i) ? "dotted"
|
||||
: TRANSITION_IS_SHIFT (trans, i) ? "solid"
|
||||
: "dashed");
|
||||
/* Shifts are solid, gotos are dashed, and error is dotted. */
|
||||
char const *style =
|
||||
(TRANSITION_IS_ERROR (trans, i) ? "dotted"
|
||||
: TRANSITION_IS_SHIFT (trans, i) ? "solid"
|
||||
: "dashed");
|
||||
|
||||
if (TRANSITION_IS_ERROR (trans, i)
|
||||
&& strcmp (symbols[sym]->tag, "error") != 0)
|
||||
abort ();
|
||||
output_edge (s->number, s1->number,
|
||||
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
||||
style, fgraph);
|
||||
if (TRANSITION_IS_ERROR (trans, i)
|
||||
&& strcmp (symbols[sym]->tag, "error") != 0)
|
||||
abort ();
|
||||
output_edge (s->number, s1->number,
|
||||
TRANSITION_IS_ERROR (trans, i) ? NULL : symbols[sym]->tag,
|
||||
style, fgraph);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
102
src/reader.c
102
src/reader.c
@@ -95,7 +95,7 @@ get_merge_function (uniqstr name)
|
||||
syms->next = xmalloc (sizeof syms->next[0]);
|
||||
syms->next->name = uniqstr_new (name);
|
||||
/* After all symbol type declarations have been parsed, packgram invokes
|
||||
record_merge_function_type to set the type. */
|
||||
record_merge_function_type to set the type. */
|
||||
syms->next->type = NULL;
|
||||
syms->next->next = NULL;
|
||||
merge_functions = head.next;
|
||||
@@ -130,17 +130,17 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
|
||||
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
||||
{
|
||||
complain_at (declaration_loc,
|
||||
_("result type clash on merge function `%s': <%s> != <%s>"),
|
||||
merge_function->name, type, merge_function->type);
|
||||
_("result type clash on merge function `%s': <%s> != <%s>"),
|
||||
merge_function->name, type, merge_function->type);
|
||||
complain_at (merge_function->type_declaration_location,
|
||||
_("previous declaration"));
|
||||
_("previous declaration"));
|
||||
}
|
||||
merge_function->type = uniqstr_new (type);
|
||||
merge_function->type_declaration_location = declaration_loc;
|
||||
}
|
||||
|
||||
/*--------------------------------------.
|
||||
| Free all merge-function definitions. |
|
||||
| Free all merge-function definitions. |
|
||||
`--------------------------------------*/
|
||||
|
||||
void
|
||||
@@ -199,8 +199,8 @@ assign_named_ref (symbol_list *p, named_ref *name)
|
||||
if (name->id == sym->tag)
|
||||
{
|
||||
warn_at (name->loc,
|
||||
_("duplicated symbol name for %s ignored"),
|
||||
quote (sym->tag));
|
||||
_("duplicated symbol name for %s ignored"),
|
||||
quote (sym->tag));
|
||||
named_ref_free (name);
|
||||
}
|
||||
else
|
||||
@@ -221,7 +221,7 @@ static symbol_list *previous_rule_end = NULL;
|
||||
|
||||
void
|
||||
grammar_current_rule_begin (symbol *lhs, location loc,
|
||||
named_ref *lhs_name)
|
||||
named_ref *lhs_name)
|
||||
{
|
||||
symbol_list* p;
|
||||
|
||||
@@ -292,19 +292,19 @@ grammar_rule_check (const symbol_list *r)
|
||||
symbol *first_rhs = r->next->content.sym;
|
||||
/* If $$ is being set in default way, report if any type mismatch. */
|
||||
if (first_rhs)
|
||||
{
|
||||
char const *lhs_type = r->content.sym->type_name;
|
||||
const char *rhs_type =
|
||||
first_rhs->type_name ? first_rhs->type_name : "";
|
||||
if (!UNIQSTR_EQ (lhs_type, rhs_type))
|
||||
warn_at (r->location,
|
||||
_("type clash on default action: <%s> != <%s>"),
|
||||
lhs_type, rhs_type);
|
||||
}
|
||||
{
|
||||
char const *lhs_type = r->content.sym->type_name;
|
||||
const char *rhs_type =
|
||||
first_rhs->type_name ? first_rhs->type_name : "";
|
||||
if (!UNIQSTR_EQ (lhs_type, rhs_type))
|
||||
warn_at (r->location,
|
||||
_("type clash on default action: <%s> != <%s>"),
|
||||
lhs_type, rhs_type);
|
||||
}
|
||||
/* Warn if there is no default for $$ but we need one. */
|
||||
else
|
||||
warn_at (r->location,
|
||||
_("empty rule for typed nonterminal, and no action"));
|
||||
warn_at (r->location,
|
||||
_("empty rule for typed nonterminal, and no action"));
|
||||
}
|
||||
|
||||
/* Check that symbol values that should be used are in fact used. */
|
||||
@@ -386,7 +386,7 @@ grammar_midrule_action (void)
|
||||
current_rule->action_props.code,
|
||||
current_rule->action_props.location,
|
||||
midrule, 0,
|
||||
current_rule->action_props.is_predicate);
|
||||
current_rule->action_props.is_predicate);
|
||||
code_props_none_init (¤t_rule->action_props);
|
||||
|
||||
if (previous_rule_end)
|
||||
@@ -463,7 +463,7 @@ grammar_current_rule_merge_set (uniqstr name, location loc)
|
||||
|
||||
void
|
||||
grammar_current_rule_symbol_append (symbol *sym, location loc,
|
||||
named_ref *name)
|
||||
named_ref *name)
|
||||
{
|
||||
symbol_list *p;
|
||||
if (current_rule->action_props.code)
|
||||
@@ -477,7 +477,7 @@ grammar_current_rule_symbol_append (symbol *sym, location loc,
|
||||
|
||||
void
|
||||
grammar_current_rule_action_append (const char *action, location loc,
|
||||
named_ref *name, bool is_predicate)
|
||||
named_ref *name, bool is_predicate)
|
||||
{
|
||||
if (current_rule->action_props.code)
|
||||
grammar_midrule_action ();
|
||||
@@ -512,7 +512,7 @@ packgram (void)
|
||||
int rule_length = 0;
|
||||
symbol *ruleprec = p->ruleprec;
|
||||
record_merge_function_type (p->merger, p->content.sym->type_name,
|
||||
p->merger_declaration_location);
|
||||
p->merger_declaration_location);
|
||||
rules[ruleno].user_number = ruleno;
|
||||
rules[ruleno].number = ruleno;
|
||||
rules[ruleno].lhs = p->content.sym;
|
||||
@@ -528,47 +528,47 @@ packgram (void)
|
||||
rules[ruleno].is_predicate = p->action_props.is_predicate;
|
||||
|
||||
/* If the midrule's $$ is set or its $n is used, remove the `$' from the
|
||||
symbol name so that it's a user-defined symbol so that the default
|
||||
%destructor and %printer apply. */
|
||||
symbol name so that it's a user-defined symbol so that the default
|
||||
%destructor and %printer apply. */
|
||||
if (p->midrule_parent_rule
|
||||
&& (p->action_props.is_value_used
|
||||
|| symbol_list_n_get (p->midrule_parent_rule,
|
||||
p->midrule_parent_rhs_index)
|
||||
|| symbol_list_n_get (p->midrule_parent_rule,
|
||||
p->midrule_parent_rhs_index)
|
||||
->action_props.is_value_used))
|
||||
p->content.sym->tag += 1;
|
||||
p->content.sym->tag += 1;
|
||||
|
||||
/* Don't check the generated rule 0. It has no action, so some rhs
|
||||
symbols may appear unused, but the parsing algorithm ensures that
|
||||
%destructor's are invoked appropriately. */
|
||||
symbols may appear unused, but the parsing algorithm ensures that
|
||||
%destructor's are invoked appropriately. */
|
||||
if (p != grammar)
|
||||
grammar_rule_check (p);
|
||||
grammar_rule_check (p);
|
||||
|
||||
for (p = p->next; p && p->content.sym; p = p->next)
|
||||
{
|
||||
++rule_length;
|
||||
{
|
||||
++rule_length;
|
||||
|
||||
/* Don't allow rule_length == INT_MAX, since that might
|
||||
cause confusion with strtol if INT_MAX == LONG_MAX. */
|
||||
if (rule_length == INT_MAX)
|
||||
fatal_at (rules[ruleno].location, _("rule is too long"));
|
||||
/* Don't allow rule_length == INT_MAX, since that might
|
||||
cause confusion with strtol if INT_MAX == LONG_MAX. */
|
||||
if (rule_length == INT_MAX)
|
||||
fatal_at (rules[ruleno].location, _("rule is too long"));
|
||||
|
||||
/* item_number = symbol_number.
|
||||
But the former needs to contain more: negative rule numbers. */
|
||||
ritem[itemno++] =
|
||||
/* item_number = symbol_number.
|
||||
But the former needs to contain more: negative rule numbers. */
|
||||
ritem[itemno++] =
|
||||
symbol_number_as_item_number (p->content.sym->number);
|
||||
/* A rule gets by default the precedence and associativity
|
||||
of its last token. */
|
||||
if (p->content.sym->class == token_sym && default_prec)
|
||||
rules[ruleno].prec = p->content.sym;
|
||||
}
|
||||
/* A rule gets by default the precedence and associativity
|
||||
of its last token. */
|
||||
if (p->content.sym->class == token_sym && default_prec)
|
||||
rules[ruleno].prec = p->content.sym;
|
||||
}
|
||||
|
||||
/* If this rule has a %prec,
|
||||
the specified symbol's precedence replaces the default. */
|
||||
if (ruleprec)
|
||||
{
|
||||
rules[ruleno].precsym = ruleprec;
|
||||
rules[ruleno].prec = ruleprec;
|
||||
}
|
||||
{
|
||||
rules[ruleno].precsym = ruleprec;
|
||||
rules[ruleno].prec = ruleprec;
|
||||
}
|
||||
/* An item ends by the rule number (negated). */
|
||||
ritem[itemno++] = rule_number_as_item_number (ruleno);
|
||||
aver (itemno < ITEM_NUMBER_MAX);
|
||||
@@ -576,7 +576,7 @@ packgram (void)
|
||||
aver (ruleno < RULE_NUMBER_MAX);
|
||||
|
||||
if (p)
|
||||
p = p->next;
|
||||
p = p->next;
|
||||
}
|
||||
|
||||
aver (itemno == nritems);
|
||||
@@ -660,7 +660,7 @@ prepare_percent_define_front_end_variables (void)
|
||||
|
||||
/*-------------------------------------------------------------.
|
||||
| Check the grammar that has just been read, and convert it to |
|
||||
| internal form. |
|
||||
| internal form. |
|
||||
`-------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
|
||||
@@ -44,16 +44,16 @@ char const *token_name (int type);
|
||||
/* From reader.c. */
|
||||
void grammar_start_symbol_set (symbol *sym, location loc);
|
||||
void grammar_current_rule_begin (symbol *lhs, location loc,
|
||||
named_ref *lhs_named_ref);
|
||||
named_ref *lhs_named_ref);
|
||||
void grammar_current_rule_end (location loc);
|
||||
void grammar_midrule_action (void);
|
||||
void grammar_current_rule_prec_set (symbol *precsym, location loc);
|
||||
void grammar_current_rule_dprec_set (int dprec, location loc);
|
||||
void grammar_current_rule_merge_set (uniqstr name, location loc);
|
||||
void grammar_current_rule_symbol_append (symbol *sym, location loc,
|
||||
named_ref *named_ref);
|
||||
named_ref *named_ref);
|
||||
void grammar_current_rule_action_append (const char *action, location loc,
|
||||
named_ref *named_ref, bool);
|
||||
named_ref *named_ref, bool);
|
||||
void reader (void);
|
||||
void free_merger_functions (void);
|
||||
|
||||
|
||||
120
src/reduce.c
120
src/reduce.c
@@ -115,14 +115,14 @@ useless_nonterminals (void)
|
||||
{
|
||||
bitset_copy (Np, N);
|
||||
for (r = 0; r < nrules; r++)
|
||||
if (!bitset_test (P, r)
|
||||
&& useful_production (r, N))
|
||||
{
|
||||
bitset_set (Np, rules[r].lhs->number - ntokens);
|
||||
bitset_set (P, r);
|
||||
}
|
||||
if (!bitset_test (P, r)
|
||||
&& useful_production (r, N))
|
||||
{
|
||||
bitset_set (Np, rules[r].lhs->number - ntokens);
|
||||
bitset_set (P, r);
|
||||
}
|
||||
if (bitset_equal_p (N, Np))
|
||||
break;
|
||||
break;
|
||||
Ns = Np;
|
||||
Np = N;
|
||||
N = Ns;
|
||||
@@ -169,37 +169,37 @@ inaccessable_symbols (void)
|
||||
bitset_set (V, accept->number);
|
||||
|
||||
while (1)
|
||||
{
|
||||
rule_number r;
|
||||
bitset_copy (Vp, V);
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
if (!bitset_test (Pp, r)
|
||||
&& bitset_test (P, r)
|
||||
&& bitset_test (V, rules[r].lhs->number))
|
||||
{
|
||||
item_number *rhsp;
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
|
||||
bitset_set (Vp, *rhsp);
|
||||
bitset_set (Pp, r);
|
||||
}
|
||||
}
|
||||
if (bitset_equal_p (V, Vp))
|
||||
break;
|
||||
Vs = Vp;
|
||||
Vp = V;
|
||||
V = Vs;
|
||||
}
|
||||
{
|
||||
rule_number r;
|
||||
bitset_copy (Vp, V);
|
||||
for (r = 0; r < nrules; r++)
|
||||
{
|
||||
if (!bitset_test (Pp, r)
|
||||
&& bitset_test (P, r)
|
||||
&& bitset_test (V, rules[r].lhs->number))
|
||||
{
|
||||
item_number *rhsp;
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; rhsp++)
|
||||
if (ISTOKEN (*rhsp) || bitset_test (N, *rhsp - ntokens))
|
||||
bitset_set (Vp, *rhsp);
|
||||
bitset_set (Pp, r);
|
||||
}
|
||||
}
|
||||
if (bitset_equal_p (V, Vp))
|
||||
break;
|
||||
Vs = Vp;
|
||||
Vp = V;
|
||||
V = Vs;
|
||||
}
|
||||
}
|
||||
|
||||
bitset_free (V);
|
||||
V = Vp;
|
||||
|
||||
/* Tokens 0, 1, and 2 are internal to Bison. Consider them useful. */
|
||||
bitset_set (V, endtoken->number); /* end-of-input token */
|
||||
bitset_set (V, errtoken->number); /* error token */
|
||||
bitset_set (V, undeftoken->number); /* some undefined token */
|
||||
bitset_set (V, endtoken->number); /* end-of-input token */
|
||||
bitset_set (V, errtoken->number); /* error token */
|
||||
bitset_set (V, undeftoken->number); /* some undefined token */
|
||||
|
||||
bitset_free (P);
|
||||
P = Pp;
|
||||
@@ -212,7 +212,7 @@ inaccessable_symbols (void)
|
||||
symbol_number i;
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
if (bitset_test (V, i))
|
||||
nuseful_nonterminals++;
|
||||
nuseful_nonterminals++;
|
||||
}
|
||||
nuseless_nonterminals = nvars - nuseful_nonterminals;
|
||||
|
||||
@@ -221,7 +221,7 @@ inaccessable_symbols (void)
|
||||
rule_number r;
|
||||
for (r = 0; r < nrules; ++r)
|
||||
if (rules[r].precsym != 0)
|
||||
bitset_set (V1, rules[r].precsym->number);
|
||||
bitset_set (V1, rules[r].precsym->number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -257,11 +257,11 @@ reduce_grammar_tables (void)
|
||||
/* Renumber the rules markers in RITEMS. */
|
||||
for (r = 0; r < nrules; ++r)
|
||||
{
|
||||
item_number *rhsp = rules[r].rhs;
|
||||
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
|
||||
/* Nothing. */;
|
||||
*rhsp = rule_number_as_item_number (r);
|
||||
rules[r].number = r;
|
||||
item_number *rhsp = rules[r].rhs;
|
||||
for (/* Nothing. */; *rhsp >= 0; ++rhsp)
|
||||
/* Nothing. */;
|
||||
*rhsp = rule_number_as_item_number (r);
|
||||
rules[r].number = r;
|
||||
}
|
||||
nrules -= nuseless_productions;
|
||||
}
|
||||
@@ -272,8 +272,8 @@ reduce_grammar_tables (void)
|
||||
int length;
|
||||
for (r = nrules; r < nrules + nuseless_productions; ++r)
|
||||
{
|
||||
length = rule_rhs_length (&rules[r]);
|
||||
nritems -= length + 1;
|
||||
length = rule_rhs_length (&rules[r]);
|
||||
nritems -= length + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -299,9 +299,9 @@ nonterminals_reduce (void)
|
||||
for (i = ntokens; i < nsyms; i++)
|
||||
if (!bitset_test (V, i))
|
||||
{
|
||||
nontermmap[i - ntokens] = n++;
|
||||
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
|
||||
symbols[i]->tag);
|
||||
nontermmap[i - ntokens] = n++;
|
||||
warn_at (symbols[i]->location, _("nonterminal useless in grammar: %s"),
|
||||
symbols[i]->tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -322,11 +322,11 @@ nonterminals_reduce (void)
|
||||
rule_number r;
|
||||
for (r = 0; r < nrules; ++r)
|
||||
{
|
||||
item_number *rhsp;
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||
if (ISVAR (*rhsp))
|
||||
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
|
||||
- ntokens]);
|
||||
item_number *rhsp;
|
||||
for (rhsp = rules[r].rhs; *rhsp >= 0; ++rhsp)
|
||||
if (ISVAR (*rhsp))
|
||||
*rhsp = symbol_number_as_item_number (nontermmap[*rhsp
|
||||
- ntokens]);
|
||||
}
|
||||
accept->number = nontermmap[accept->number - ntokens];
|
||||
}
|
||||
@@ -350,7 +350,7 @@ reduce_output (FILE *out)
|
||||
int i;
|
||||
fprintf (out, "%s\n\n", _("Nonterminals useless in grammar"));
|
||||
for (i = 0; i < nuseless_nonterminals; ++i)
|
||||
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
|
||||
fprintf (out, " %s\n", symbols[nsyms + i]->tag);
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
@@ -359,19 +359,19 @@ reduce_output (FILE *out)
|
||||
int i;
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (reduce_token_unused_in_grammar (i))
|
||||
{
|
||||
if (!b)
|
||||
fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
|
||||
b = true;
|
||||
fprintf (out, " %s\n", symbols[i]->tag);
|
||||
}
|
||||
{
|
||||
if (!b)
|
||||
fprintf (out, "%s\n\n", _("Terminals unused in grammar"));
|
||||
b = true;
|
||||
fprintf (out, " %s\n", symbols[i]->tag);
|
||||
}
|
||||
if (b)
|
||||
fputs ("\n\n", out);
|
||||
}
|
||||
|
||||
if (nuseless_productions > 0)
|
||||
grammar_rules_partial_print (out, _("Rules useless in grammar"),
|
||||
rule_useless_in_grammar_p);
|
||||
rule_useless_in_grammar_p);
|
||||
}
|
||||
|
||||
|
||||
@@ -417,8 +417,8 @@ reduce_grammar (void)
|
||||
|
||||
if (!bitset_test (N, accept->number - ntokens))
|
||||
fatal_at (startsymbol_location,
|
||||
_("start symbol %s does not derive any sentence"),
|
||||
startsymbol->tag);
|
||||
_("start symbol %s does not derive any sentence"),
|
||||
startsymbol->tag);
|
||||
|
||||
/* First reduce the nonterminals, as they renumber themselves in the
|
||||
whole grammar. If you change the order, nonterms would be
|
||||
@@ -434,7 +434,7 @@ reduce_grammar (void)
|
||||
|
||||
fprintf (stderr, "reduced %s defines %d terminals, %d nonterminals\
|
||||
, and %d productions.\n",
|
||||
grammar_file, ntokens, nvars, nrules);
|
||||
grammar_file, ntokens, nvars, nrules);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ relation_print (relation r, relation_node size, FILE *out)
|
||||
{
|
||||
fprintf (out, "%3lu: ", (unsigned long int) i);
|
||||
if (r[i])
|
||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||
fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
|
||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||
fprintf (out, "%3lu ", (unsigned long int) r[i][j]);
|
||||
fputc ('\n', out);
|
||||
}
|
||||
fputc ('\n', out);
|
||||
@@ -70,25 +70,25 @@ traverse (relation_node i)
|
||||
if (R[i])
|
||||
for (j = 0; R[i][j] != END_NODE; ++j)
|
||||
{
|
||||
if (INDEX[R[i][j]] == 0)
|
||||
traverse (R[i][j]);
|
||||
if (INDEX[R[i][j]] == 0)
|
||||
traverse (R[i][j]);
|
||||
|
||||
if (INDEX[i] > INDEX[R[i][j]])
|
||||
INDEX[i] = INDEX[R[i][j]];
|
||||
if (INDEX[i] > INDEX[R[i][j]])
|
||||
INDEX[i] = INDEX[R[i][j]];
|
||||
|
||||
bitset_or (F[i], F[i], F[R[i][j]]);
|
||||
bitset_or (F[i], F[i], F[R[i][j]]);
|
||||
}
|
||||
|
||||
if (INDEX[i] == height)
|
||||
for (;;)
|
||||
{
|
||||
j = VERTICES[top--];
|
||||
INDEX[j] = infinity;
|
||||
j = VERTICES[top--];
|
||||
INDEX[j] = infinity;
|
||||
|
||||
if (i == j)
|
||||
break;
|
||||
if (i == j)
|
||||
break;
|
||||
|
||||
bitset_copy (F[j], F[i]);
|
||||
bitset_copy (F[j], F[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,17 +144,17 @@ relation_transpose (relation *R_arg, relation_node n)
|
||||
for (i = 0; i < n; i++)
|
||||
if (r[i])
|
||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||
++nedges[r[i][j]];
|
||||
++nedges[r[i][j]];
|
||||
|
||||
/* Allocate. */
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
relation_node *sp = NULL;
|
||||
if (nedges[i] > 0)
|
||||
{
|
||||
sp = xnmalloc (nedges[i] + 1, sizeof *sp);
|
||||
sp[nedges[i]] = END_NODE;
|
||||
}
|
||||
{
|
||||
sp = xnmalloc (nedges[i] + 1, sizeof *sp);
|
||||
sp[nedges[i]] = END_NODE;
|
||||
}
|
||||
new_R[i] = sp;
|
||||
end_R[i] = sp;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ relation_transpose (relation *R_arg, relation_node n)
|
||||
for (i = 0; i < n; i++)
|
||||
if (r[i])
|
||||
for (j = 0; r[i][j] != END_NODE; ++j)
|
||||
*end_R[r[i][j]]++ = i;
|
||||
*end_R[r[i][j]]++ = i;
|
||||
|
||||
free (nedges);
|
||||
free (end_R);
|
||||
|
||||
238
src/scan-code.l
238
src/scan-code.l
@@ -48,7 +48,7 @@ YY_DECL;
|
||||
#define YY_USER_ACTION location_compute (loc, &loc->end, yytext, yyleng);
|
||||
|
||||
static void handle_action_dollar (symbol_list *rule, char *cp,
|
||||
location dollar_loc);
|
||||
location dollar_loc);
|
||||
static void handle_action_at (symbol_list *rule, char *cp, location at_loc);
|
||||
|
||||
/* A string to be pushed to obstack after dollar/at has been handled. */
|
||||
@@ -76,17 +76,17 @@ static bool untyped_var_seen;
|
||||
/* POSIX says that a tag must be both an id and a C union member, but
|
||||
historically almost any character is allowed in a tag. We disallow
|
||||
NUL and newline, as this simplifies our implementation. */
|
||||
tag [^\0\n>]+
|
||||
tag [^\0\n>]+
|
||||
|
||||
/* Zero or more instances of backslash-newline. Following GCC, allow
|
||||
white space between the backslash and the newline. */
|
||||
splice (\\[ \f\t\v]*\n)*
|
||||
splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
/* C style identifier. Must start with letter. Will be used for
|
||||
named symbol references. Shall be kept synchronized with
|
||||
scan-gram.l "letter" and "id". */
|
||||
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
||||
id {letter}({letter}|[-0-9])*
|
||||
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
||||
id {letter}({letter}|[-0-9])*
|
||||
ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
|
||||
%%
|
||||
@@ -112,8 +112,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
is expected to return only once. This initialization is
|
||||
therefore done once per action to translate. */
|
||||
aver (sc_context == SC_SYMBOL_ACTION
|
||||
|| sc_context == SC_RULE_ACTION
|
||||
|| sc_context == INITIAL);
|
||||
|| sc_context == SC_RULE_ACTION
|
||||
|| sc_context == INITIAL);
|
||||
BEGIN sc_context;
|
||||
%}
|
||||
|
||||
@@ -133,8 +133,8 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
|
||||
<SC_LINE_COMMENT>
|
||||
{
|
||||
"\n" STRING_GROW; BEGIN sc_context;
|
||||
{splice} STRING_GROW;
|
||||
"\n" STRING_GROW; BEGIN sc_context;
|
||||
{splice} STRING_GROW;
|
||||
}
|
||||
|
||||
|
||||
@@ -144,17 +144,17 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
|
||||
<SC_CHARACTER,SC_STRING>
|
||||
{
|
||||
{splice}|\\{splice}. STRING_GROW;
|
||||
{splice}|\\{splice}. STRING_GROW;
|
||||
}
|
||||
|
||||
<SC_CHARACTER>
|
||||
{
|
||||
"'" STRING_GROW; BEGIN sc_context;
|
||||
"'" STRING_GROW; BEGIN sc_context;
|
||||
}
|
||||
|
||||
<SC_STRING>
|
||||
{
|
||||
"\"" STRING_GROW; BEGIN sc_context;
|
||||
"\"" STRING_GROW; BEGIN sc_context;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,9 +228,9 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
if (outer_brace && !yacc_flag && language_prio == default_prio
|
||||
&& skeleton_prio == default_prio && need_semicolon && ! in_cpp)
|
||||
{
|
||||
warn_at (*loc, _("a `;' might be needed at the end of action code"));
|
||||
warn_at (*loc, _("future versions of Bison will not add the `;'"));
|
||||
obstack_1grow (&obstack_for_string, ';');
|
||||
warn_at (*loc, _("a `;' might be needed at the end of action code"));
|
||||
warn_at (*loc, _("future versions of Bison will not add the `;'"));
|
||||
obstack_1grow (&obstack_for_string, ';');
|
||||
}
|
||||
|
||||
STRING_GROW;
|
||||
@@ -281,20 +281,20 @@ ref -?[0-9]+|{id}|"["{id}"]"|"$"
|
||||
|
||||
<*>
|
||||
{
|
||||
\$ obstack_sgrow (&obstack_for_string, "$][");
|
||||
\@ obstack_sgrow (&obstack_for_string, "@@");
|
||||
\[ obstack_sgrow (&obstack_for_string, "@{");
|
||||
\] obstack_sgrow (&obstack_for_string, "@}");
|
||||
\$ obstack_sgrow (&obstack_for_string, "$][");
|
||||
\@ obstack_sgrow (&obstack_for_string, "@@");
|
||||
\[ obstack_sgrow (&obstack_for_string, "@{");
|
||||
\] obstack_sgrow (&obstack_for_string, "@}");
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------.
|
||||
| By default, grow the string obstack with the input. |
|
||||
`-----------------------------------------------------*/
|
||||
|
||||
<*>.|\n STRING_GROW;
|
||||
<*>.|\n STRING_GROW;
|
||||
|
||||
/* End of processing. */
|
||||
<*><<EOF>> {
|
||||
<*><<EOF>> {
|
||||
STRING_FINISH;
|
||||
return last_string;
|
||||
}
|
||||
@@ -357,9 +357,9 @@ variant_table_grow (void)
|
||||
if (variant_count > variant_table_size)
|
||||
{
|
||||
while (variant_count > variant_table_size)
|
||||
variant_table_size = 2 * variant_table_size + 3;
|
||||
variant_table_size = 2 * variant_table_size + 3;
|
||||
variant_table = xnrealloc (variant_table, variant_table_size,
|
||||
sizeof *variant_table);
|
||||
sizeof *variant_table);
|
||||
}
|
||||
return &variant_table[variant_count - 1];
|
||||
}
|
||||
@@ -389,7 +389,7 @@ find_prefix_end (const char *prefix, char *begin, char *end)
|
||||
|
||||
static variant *
|
||||
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
||||
char *cp, char *cp_end, bool explicit_bracketing)
|
||||
char *cp, char *cp_end, bool explicit_bracketing)
|
||||
{
|
||||
char *prefix_end;
|
||||
|
||||
@@ -443,53 +443,53 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
|
||||
dollar_or_at, var->id, at_spec);
|
||||
}
|
||||
else
|
||||
{
|
||||
static struct obstack msg_buf;
|
||||
const char *tail = explicit_bracketing ? "" :
|
||||
cp + strlen (var->id);
|
||||
const char *id = var->hidden_by ? var->hidden_by->id :
|
||||
var->id;
|
||||
location id_loc = var->hidden_by ? var->hidden_by->loc :
|
||||
var->loc;
|
||||
{
|
||||
static struct obstack msg_buf;
|
||||
const char *tail = explicit_bracketing ? "" :
|
||||
cp + strlen (var->id);
|
||||
const char *id = var->hidden_by ? var->hidden_by->id :
|
||||
var->id;
|
||||
location id_loc = var->hidden_by ? var->hidden_by->loc :
|
||||
var->loc;
|
||||
|
||||
/* Create the explanation message. */
|
||||
obstack_init (&msg_buf);
|
||||
/* Create the explanation message. */
|
||||
obstack_init (&msg_buf);
|
||||
|
||||
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
||||
if (contains_dot_or_dash (id))
|
||||
obstack_fgrow1 (&msg_buf, "[%s]", id);
|
||||
else
|
||||
obstack_sgrow (&msg_buf, id);
|
||||
obstack_sgrow (&msg_buf, tail);
|
||||
obstack_fgrow1 (&msg_buf, _("possibly meant: %c"), dollar_or_at);
|
||||
if (contains_dot_or_dash (id))
|
||||
obstack_fgrow1 (&msg_buf, "[%s]", id);
|
||||
else
|
||||
obstack_sgrow (&msg_buf, id);
|
||||
obstack_sgrow (&msg_buf, tail);
|
||||
|
||||
if (var->err & VARIANT_HIDDEN)
|
||||
{
|
||||
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
|
||||
if (contains_dot_or_dash (var->id))
|
||||
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
|
||||
else
|
||||
obstack_sgrow (&msg_buf, var->id);
|
||||
obstack_sgrow (&msg_buf, tail);
|
||||
}
|
||||
if (var->err & VARIANT_HIDDEN)
|
||||
{
|
||||
obstack_fgrow1 (&msg_buf, _(", hiding %c"), dollar_or_at);
|
||||
if (contains_dot_or_dash (var->id))
|
||||
obstack_fgrow1 (&msg_buf, "[%s]", var->id);
|
||||
else
|
||||
obstack_sgrow (&msg_buf, var->id);
|
||||
obstack_sgrow (&msg_buf, tail);
|
||||
}
|
||||
|
||||
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
|
||||
obstack_fgrow1 (&msg_buf, _(" at %s"), at_spec);
|
||||
|
||||
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
||||
if (var->err & VARIANT_NOT_VISIBLE_FROM_MIDRULE)
|
||||
{
|
||||
const char *format =
|
||||
_(", cannot be accessed from mid-rule action at $%d");
|
||||
obstack_fgrow1 (&msg_buf, format, midrule_rhs_index);
|
||||
}
|
||||
|
||||
obstack_1grow (&msg_buf, '\0');
|
||||
obstack_1grow (&msg_buf, '\0');
|
||||
if (is_warning)
|
||||
warn_at_indent (id_loc, &indent, "%s",
|
||||
(char *) obstack_finish (&msg_buf));
|
||||
else
|
||||
complain_at_indent (id_loc, &indent, "%s",
|
||||
(char *) obstack_finish (&msg_buf));
|
||||
obstack_free (&msg_buf, 0);
|
||||
}
|
||||
obstack_free (&msg_buf, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,8 +509,8 @@ show_sub_messages (const char* cp, bool explicit_bracketing,
|
||||
accesses. */
|
||||
static long int
|
||||
parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
int midrule_rhs_index, char *text, location text_loc,
|
||||
char dollar_or_at)
|
||||
int midrule_rhs_index, char *text, location text_loc,
|
||||
char dollar_or_at)
|
||||
{
|
||||
symbol_list *l;
|
||||
char *cp_end;
|
||||
@@ -526,13 +526,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
{
|
||||
long int num = strtol (cp, &cp, 10);
|
||||
if (1 - INT_MAX + rule_length <= num && num <= rule_length)
|
||||
return num;
|
||||
return num;
|
||||
else
|
||||
{
|
||||
complain_at (text_loc, _("integer out of range: %s"),
|
||||
{
|
||||
complain_at (text_loc, _("integer out of range: %s"),
|
||||
quote (text));
|
||||
return INVALID_REF;
|
||||
}
|
||||
return INVALID_REF;
|
||||
}
|
||||
}
|
||||
|
||||
if ('[' == *cp)
|
||||
@@ -540,7 +540,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
/* Ignore the brackets. */
|
||||
char *p;
|
||||
for (p = ++cp; *p != ']'; ++p)
|
||||
continue;
|
||||
continue;
|
||||
cp_end = p;
|
||||
|
||||
explicit_bracketing = true;
|
||||
@@ -550,13 +550,13 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
/* Take all characters of the name. */
|
||||
char* p;
|
||||
for (p = cp; *p; ++p)
|
||||
if (is_dot_or_dash (*p))
|
||||
{
|
||||
ref_tail_fields = p;
|
||||
break;
|
||||
}
|
||||
if (is_dot_or_dash (*p))
|
||||
{
|
||||
ref_tail_fields = p;
|
||||
break;
|
||||
}
|
||||
for (p = cp; *p; ++p)
|
||||
continue;
|
||||
continue;
|
||||
cp_end = p;
|
||||
|
||||
explicit_bracketing = false;
|
||||
@@ -569,17 +569,17 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
for (symbol_index = 0, l = rule; !symbol_list_null (l);
|
||||
++symbol_index, l = l->next)
|
||||
{
|
||||
variant *var;
|
||||
if (l->content_type != SYMLIST_SYMBOL)
|
||||
continue;
|
||||
variant *var;
|
||||
if (l->content_type != SYMLIST_SYMBOL)
|
||||
continue;
|
||||
|
||||
var = variant_add (l->content.sym->tag, l->sym_loc,
|
||||
var = variant_add (l->content.sym->tag, l->sym_loc,
|
||||
symbol_index, cp, cp_end, explicit_bracketing);
|
||||
if (var && l->named_ref)
|
||||
var->hidden_by = l->named_ref;
|
||||
if (var && l->named_ref)
|
||||
var->hidden_by = l->named_ref;
|
||||
|
||||
if (l->named_ref)
|
||||
variant_add (l->named_ref->id, l->named_ref->loc,
|
||||
if (l->named_ref)
|
||||
variant_add (l->named_ref->id, l->named_ref->loc,
|
||||
symbol_index, cp, cp_end, explicit_bracketing);
|
||||
}
|
||||
}
|
||||
@@ -592,7 +592,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
|
||||
/* Check visibility from mid-rule actions. */
|
||||
if (midrule_rhs_index != 0
|
||||
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
|
||||
&& (symbol_index == 0 || midrule_rhs_index < symbol_index))
|
||||
var->err |= VARIANT_NOT_VISIBLE_FROM_MIDRULE;
|
||||
|
||||
/* Check correct bracketing. */
|
||||
@@ -723,19 +723,19 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
{
|
||||
type_name = ++cp;
|
||||
while (*cp != '>')
|
||||
++cp;
|
||||
++cp;
|
||||
|
||||
/* The '>' symbol will be later replaced by '\0'. Original
|
||||
'text' is needed for error messages. */
|
||||
'text' is needed for error messages. */
|
||||
gt_ptr = cp;
|
||||
++cp;
|
||||
if (untyped_var_seen)
|
||||
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
|
||||
complain_at (dollar_loc, _("explicit type given in untyped grammar"));
|
||||
tag_seen = true;
|
||||
}
|
||||
|
||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
|
||||
rule->midrule_parent_rhs_index, text, dollar_loc, '$');
|
||||
|
||||
if (gt_ptr)
|
||||
*gt_ptr = '\0';
|
||||
@@ -747,54 +747,54 @@ handle_action_dollar (symbol_list *rule, char *text, location dollar_loc)
|
||||
|
||||
case LHS_REF:
|
||||
if (!type_name)
|
||||
type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
|
||||
type_name = symbol_list_n_type_name_get (rule, dollar_loc, 0);
|
||||
|
||||
if (!type_name)
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
{
|
||||
if (rule->midrule_parent_rule)
|
||||
complain_at (dollar_loc,
|
||||
_("$$ for the midrule at $%d of `%s'"
|
||||
" has no declared type"),
|
||||
rule->midrule_parent_rhs_index,
|
||||
effective_rule->content.sym->tag);
|
||||
else
|
||||
complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
|
||||
rule->content.sym->tag);
|
||||
}
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
type_name = "";
|
||||
}
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
{
|
||||
if (rule->midrule_parent_rule)
|
||||
complain_at (dollar_loc,
|
||||
_("$$ for the midrule at $%d of `%s'"
|
||||
" has no declared type"),
|
||||
rule->midrule_parent_rhs_index,
|
||||
effective_rule->content.sym->tag);
|
||||
else
|
||||
complain_at (dollar_loc, _("$$ of `%s' has no declared type"),
|
||||
rule->content.sym->tag);
|
||||
}
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
type_name = "";
|
||||
}
|
||||
|
||||
obstack_fgrow1 (&obstack_for_string,
|
||||
"]b4_lhs_value([%s])[", type_name);
|
||||
"]b4_lhs_value([%s])[", type_name);
|
||||
rule->action_props.is_value_used = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (max_left_semantic_context < 1 - n)
|
||||
max_left_semantic_context = 1 - n;
|
||||
max_left_semantic_context = 1 - n;
|
||||
if (!type_name && 0 < n)
|
||||
type_name =
|
||||
symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
|
||||
type_name =
|
||||
symbol_list_n_type_name_get (effective_rule, dollar_loc, n);
|
||||
if (!type_name)
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
|
||||
cp, effective_rule->content.sym->tag);
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
type_name = "";
|
||||
}
|
||||
{
|
||||
if (union_seen | tag_seen)
|
||||
complain_at (dollar_loc, _("$%s of `%s' has no declared type"),
|
||||
cp, effective_rule->content.sym->tag);
|
||||
else
|
||||
untyped_var_seen = true;
|
||||
type_name = "";
|
||||
}
|
||||
|
||||
obstack_fgrow3 (&obstack_for_string,
|
||||
"]b4_rhs_value(%d, %d, [%s])[",
|
||||
effective_rule_length, n, type_name);
|
||||
"]b4_rhs_value(%d, %d, [%s])[",
|
||||
effective_rule_length, n, type_name);
|
||||
if (n > 0)
|
||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
||||
true;
|
||||
symbol_list_n_get (effective_rule, n)->action_props.is_value_used =
|
||||
true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -827,7 +827,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
||||
muscle_percent_define_ensure("locations", at_loc, true);
|
||||
|
||||
n = parse_ref (cp, effective_rule, effective_rule_length,
|
||||
rule->midrule_parent_rhs_index, text, at_loc, '@');
|
||||
rule->midrule_parent_rhs_index, text, at_loc, '@');
|
||||
switch (n)
|
||||
{
|
||||
case INVALID_REF:
|
||||
@@ -839,7 +839,7 @@ handle_action_at (symbol_list *rule, char *text, location at_loc)
|
||||
|
||||
default:
|
||||
obstack_fgrow2 (&obstack_for_string, "]b4_rhs_location(%d, %d)[",
|
||||
effective_rule_length, n);
|
||||
effective_rule_length, n);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -886,7 +886,7 @@ code_props const code_props_none = CODE_PROPS_NONE_INIT;
|
||||
|
||||
void
|
||||
code_props_plain_init (code_props *self, char const *code,
|
||||
location code_loc)
|
||||
location code_loc)
|
||||
{
|
||||
self->kind = CODE_PROPS_PLAIN;
|
||||
self->code = code;
|
||||
@@ -911,7 +911,7 @@ code_props_symbol_action_init (code_props *self, char const *code,
|
||||
void
|
||||
code_props_rule_action_init (code_props *self, char const *code,
|
||||
location code_loc, symbol_list *rule,
|
||||
named_ref *name, bool is_predicate)
|
||||
named_ref *name, bool is_predicate)
|
||||
{
|
||||
self->kind = CODE_PROPS_RULE_ACTION;
|
||||
self->code = code;
|
||||
|
||||
220
src/scan-gram.l
220
src/scan-gram.l
@@ -44,8 +44,8 @@
|
||||
|
||||
#define YY_DECL GRAM_LEX_DECL
|
||||
|
||||
#define YY_USER_INIT \
|
||||
code_start = scanner_cursor = loc->start; \
|
||||
#define YY_USER_INIT \
|
||||
code_start = scanner_cursor = loc->start; \
|
||||
|
||||
/* Location of scanner cursor. */
|
||||
static boundary scanner_cursor;
|
||||
@@ -69,7 +69,7 @@ static size_t no_cr_read (FILE *, char *, size_t);
|
||||
|
||||
#define ROLLBACK_CURRENT_TOKEN \
|
||||
do { \
|
||||
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
|
||||
scanner_cursor.column -= mbsnwidth (yytext, yyleng, 0); \
|
||||
yyless (0); \
|
||||
} while (0)
|
||||
|
||||
@@ -118,21 +118,21 @@ static void unexpected_newline (boundary, char const *);
|
||||
/* Bracketed identifiers support. */
|
||||
%x SC_BRACKETED_ID SC_RETURN_BRACKETED_ID
|
||||
|
||||
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
||||
id {letter}({letter}|[-0-9])*
|
||||
letter [.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_]
|
||||
id {letter}({letter}|[-0-9])*
|
||||
directive %{id}
|
||||
int [0-9]+
|
||||
int [0-9]+
|
||||
|
||||
/* POSIX says that a tag must be both an id and a C union member, but
|
||||
historically almost any character is allowed in a tag. We disallow
|
||||
NUL, as this simplifies our implementation. We disallow angle
|
||||
bracket to match them in nested pairs: several languages use them
|
||||
for generics/template types. */
|
||||
tag [^\0<>]+
|
||||
tag [^\0<>]+
|
||||
|
||||
/* Zero or more instances of backslash-newline. Following GCC, allow
|
||||
white space between the backslash and the newline. */
|
||||
splice (\\[ \f\t\v]*\n)*
|
||||
splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
%%
|
||||
%{
|
||||
@@ -164,7 +164,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
<INITIAL,SC_AFTER_IDENTIFIER,SC_BRACKETED_ID,SC_RETURN_BRACKETED_ID>
|
||||
{
|
||||
/* Comments and white space. */
|
||||
"," warn_at (*loc, _("stray `,' treated as white space"));
|
||||
"," warn_at (*loc, _("stray `,' treated as white space"));
|
||||
[ \f\n\t\v] |
|
||||
"//".* ;
|
||||
"/*" {
|
||||
@@ -186,7 +186,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
`----------------------------*/
|
||||
|
||||
/* For directives that are also command line options, the regex must be
|
||||
"%..."
|
||||
"%..."
|
||||
after "[-_]"s are removed, and the directive must match the --long
|
||||
option name, with a single string argument. Otherwise, add exceptions
|
||||
to ../build-aux/cross-options.pl. */
|
||||
@@ -269,10 +269,10 @@ splice (\\[ \f\t\v]*\n)*
|
||||
}
|
||||
|
||||
/* Characters. */
|
||||
"'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
|
||||
"'" token_start = loc->start; BEGIN SC_ESCAPED_CHARACTER;
|
||||
|
||||
/* Strings. */
|
||||
"\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
|
||||
"\"" token_start = loc->start; BEGIN SC_ESCAPED_STRING;
|
||||
|
||||
/* Prologue. */
|
||||
"%{" code_start = loc->start; BEGIN SC_PROLOGUE;
|
||||
@@ -340,7 +340,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
<SC_ESCAPED_CHARACTER,SC_ESCAPED_STRING,SC_TAG>
|
||||
{
|
||||
\0 complain_at (*loc, _("invalid null character"));
|
||||
\0 complain_at (*loc, _("invalid null character"));
|
||||
}
|
||||
|
||||
|
||||
@@ -353,16 +353,16 @@ splice (\\[ \f\t\v]*\n)*
|
||||
"[" {
|
||||
if (bracketed_id_str)
|
||||
{
|
||||
ROLLBACK_CURRENT_TOKEN;
|
||||
BEGIN SC_RETURN_BRACKETED_ID;
|
||||
*loc = id_loc;
|
||||
return ID;
|
||||
ROLLBACK_CURRENT_TOKEN;
|
||||
BEGIN SC_RETURN_BRACKETED_ID;
|
||||
*loc = id_loc;
|
||||
return ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
bracketed_id_start = loc->start;
|
||||
bracketed_id_context_state = YY_START;
|
||||
BEGIN SC_BRACKETED_ID;
|
||||
bracketed_id_start = loc->start;
|
||||
bracketed_id_context_state = YY_START;
|
||||
BEGIN SC_BRACKETED_ID;
|
||||
}
|
||||
}
|
||||
":" {
|
||||
@@ -392,33 +392,33 @@ splice (\\[ \f\t\v]*\n)*
|
||||
{id} {
|
||||
if (bracketed_id_str)
|
||||
{
|
||||
complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
|
||||
quote (yytext));
|
||||
complain_at (*loc, _("unexpected identifier in bracketed name: %s"),
|
||||
quote (yytext));
|
||||
}
|
||||
else
|
||||
{
|
||||
bracketed_id_str = uniqstr_new (yytext);
|
||||
bracketed_id_loc = *loc;
|
||||
bracketed_id_str = uniqstr_new (yytext);
|
||||
bracketed_id_loc = *loc;
|
||||
}
|
||||
}
|
||||
"]" {
|
||||
BEGIN bracketed_id_context_state;
|
||||
if (bracketed_id_str)
|
||||
{
|
||||
if (INITIAL == bracketed_id_context_state)
|
||||
{
|
||||
val->uniqstr = bracketed_id_str;
|
||||
bracketed_id_str = 0;
|
||||
*loc = bracketed_id_loc;
|
||||
return BRACKETED_ID;
|
||||
}
|
||||
if (INITIAL == bracketed_id_context_state)
|
||||
{
|
||||
val->uniqstr = bracketed_id_str;
|
||||
bracketed_id_str = 0;
|
||||
*loc = bracketed_id_loc;
|
||||
return BRACKETED_ID;
|
||||
}
|
||||
}
|
||||
else
|
||||
complain_at (*loc, _("an identifier expected"));
|
||||
}
|
||||
. {
|
||||
complain_at (*loc, _("invalid character in bracketed name: %s"),
|
||||
quote (yytext));
|
||||
quote (yytext));
|
||||
}
|
||||
<<EOF>> {
|
||||
BEGIN bracketed_id_context_state;
|
||||
@@ -446,7 +446,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
<SC_YACC_COMMENT>
|
||||
{
|
||||
"*/" BEGIN context_state;
|
||||
.|\n ;
|
||||
.|\n ;
|
||||
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
<SC_COMMENT>
|
||||
{
|
||||
"*"{splice}"/" STRING_GROW; BEGIN context_state;
|
||||
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
||||
<<EOF>> unexpected_eof (token_start, "*/"); BEGIN context_state;
|
||||
}
|
||||
|
||||
|
||||
@@ -468,9 +468,9 @@ splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
<SC_LINE_COMMENT>
|
||||
{
|
||||
"\n" STRING_GROW; BEGIN context_state;
|
||||
{splice} STRING_GROW;
|
||||
<<EOF>> BEGIN context_state;
|
||||
"\n" STRING_GROW; BEGIN context_state;
|
||||
{splice} STRING_GROW;
|
||||
<<EOF>> BEGIN context_state;
|
||||
}
|
||||
|
||||
|
||||
@@ -502,7 +502,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
/*----------------------------------------------------------.
|
||||
| Scanning a Bison character literal, decoding its escapes. |
|
||||
| The initial quote is already eaten. |
|
||||
| The initial quote is already eaten. |
|
||||
`----------------------------------------------------------*/
|
||||
|
||||
<SC_ESCAPED_CHARACTER>
|
||||
@@ -610,13 +610,13 @@ splice (\\[ \f\t\v]*\n)*
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
}
|
||||
|
||||
\\a obstack_1grow (&obstack_for_string, '\a');
|
||||
\\b obstack_1grow (&obstack_for_string, '\b');
|
||||
\\f obstack_1grow (&obstack_for_string, '\f');
|
||||
\\n obstack_1grow (&obstack_for_string, '\n');
|
||||
\\r obstack_1grow (&obstack_for_string, '\r');
|
||||
\\t obstack_1grow (&obstack_for_string, '\t');
|
||||
\\v obstack_1grow (&obstack_for_string, '\v');
|
||||
\\a obstack_1grow (&obstack_for_string, '\a');
|
||||
\\b obstack_1grow (&obstack_for_string, '\b');
|
||||
\\f obstack_1grow (&obstack_for_string, '\f');
|
||||
\\n obstack_1grow (&obstack_for_string, '\n');
|
||||
\\r obstack_1grow (&obstack_for_string, '\r');
|
||||
\\t obstack_1grow (&obstack_for_string, '\t');
|
||||
\\v obstack_1grow (&obstack_for_string, '\v');
|
||||
|
||||
/* \\[\"\'?\\] would be shorter, but it confuses xgettext. */
|
||||
\\("\""|"'"|"?"|"\\") obstack_1grow (&obstack_for_string, yytext[1]);
|
||||
@@ -629,7 +629,7 @@ splice (\\[ \f\t\v]*\n)*
|
||||
else
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
}
|
||||
\\(.|\n) {
|
||||
\\(.|\n) {
|
||||
char const *p = yytext + 1;
|
||||
/* Quote only if escaping won't make the character visible. */
|
||||
if (isspace ((unsigned char) *p) && isprint ((unsigned char) *p))
|
||||
@@ -646,21 +646,21 @@ splice (\\[ \f\t\v]*\n)*
|
||||
|
||||
<SC_CHARACTER,SC_STRING>
|
||||
{
|
||||
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
|
||||
{splice}|\\{splice}[^\n\[\]] STRING_GROW;
|
||||
}
|
||||
|
||||
<SC_CHARACTER>
|
||||
{
|
||||
"'" STRING_GROW; BEGIN context_state;
|
||||
\n unexpected_newline (token_start, "'"); BEGIN context_state;
|
||||
<<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
|
||||
"'" STRING_GROW; BEGIN context_state;
|
||||
\n unexpected_newline (token_start, "'"); BEGIN context_state;
|
||||
<<EOF>> unexpected_eof (token_start, "'"); BEGIN context_state;
|
||||
}
|
||||
|
||||
<SC_STRING>
|
||||
{
|
||||
"\"" STRING_GROW; BEGIN context_state;
|
||||
\n unexpected_newline (token_start, "\""); BEGIN context_state;
|
||||
<<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
|
||||
"\"" STRING_GROW; BEGIN context_state;
|
||||
\n unexpected_newline (token_start, "\""); BEGIN context_state;
|
||||
<<EOF>> unexpected_eof (token_start, "\""); BEGIN context_state;
|
||||
}
|
||||
|
||||
|
||||
@@ -730,11 +730,11 @@ splice (\\[ \f\t\v]*\n)*
|
||||
--nesting;
|
||||
if (nesting < 0)
|
||||
{
|
||||
STRING_FINISH;
|
||||
loc->start = code_start;
|
||||
val->code = last_string;
|
||||
BEGIN INITIAL;
|
||||
return BRACED_CODE;
|
||||
STRING_FINISH;
|
||||
loc->start = code_start;
|
||||
val->code = last_string;
|
||||
BEGIN INITIAL;
|
||||
return BRACED_CODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -745,11 +745,11 @@ splice (\\[ \f\t\v]*\n)*
|
||||
--nesting;
|
||||
if (nesting < 0)
|
||||
{
|
||||
STRING_FINISH;
|
||||
loc->start = code_start;
|
||||
val->code = last_string;
|
||||
BEGIN INITIAL;
|
||||
return BRACED_PREDICATE;
|
||||
STRING_FINISH;
|
||||
loc->start = code_start;
|
||||
val->code = last_string;
|
||||
BEGIN INITIAL;
|
||||
return BRACED_PREDICATE;
|
||||
}
|
||||
else
|
||||
obstack_1grow (&obstack_for_string, '}');
|
||||
@@ -802,8 +802,8 @@ splice (\\[ \f\t\v]*\n)*
|
||||
| By default, grow the string obstack with the input. |
|
||||
`-----------------------------------------------------*/
|
||||
|
||||
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>. |
|
||||
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE>\n STRING_GROW;
|
||||
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE,SC_STRING,SC_CHARACTER,SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>. |
|
||||
<SC_COMMENT,SC_LINE_COMMENT,SC_BRACED_CODE,SC_PREDICATE,SC_PROLOGUE,SC_EPILOGUE>\n STRING_GROW;
|
||||
|
||||
%%
|
||||
|
||||
@@ -819,35 +819,35 @@ no_cr_read (FILE *fp, char *buf, size_t size)
|
||||
{
|
||||
char *w = memchr (buf, '\r', bytes_read);
|
||||
if (w)
|
||||
{
|
||||
char const *r = ++w;
|
||||
char const *lim = buf + bytes_read;
|
||||
{
|
||||
char const *r = ++w;
|
||||
char const *lim = buf + bytes_read;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Found an '\r'. Treat it like '\n', but ignore any
|
||||
'\n' that immediately follows. */
|
||||
w[-1] = '\n';
|
||||
if (r == lim)
|
||||
{
|
||||
int ch = getc (fp);
|
||||
if (ch != '\n' && ungetc (ch, fp) != ch)
|
||||
break;
|
||||
}
|
||||
else if (*r == '\n')
|
||||
r++;
|
||||
for (;;)
|
||||
{
|
||||
/* Found an '\r'. Treat it like '\n', but ignore any
|
||||
'\n' that immediately follows. */
|
||||
w[-1] = '\n';
|
||||
if (r == lim)
|
||||
{
|
||||
int ch = getc (fp);
|
||||
if (ch != '\n' && ungetc (ch, fp) != ch)
|
||||
break;
|
||||
}
|
||||
else if (*r == '\n')
|
||||
r++;
|
||||
|
||||
/* Copy until the next '\r'. */
|
||||
do
|
||||
{
|
||||
if (r == lim)
|
||||
return w - buf;
|
||||
}
|
||||
while ((*w++ = *r++) != '\r');
|
||||
}
|
||||
/* Copy until the next '\r'. */
|
||||
do
|
||||
{
|
||||
if (r == lim)
|
||||
return w - buf;
|
||||
}
|
||||
while ((*w++ = *r++) != '\r');
|
||||
}
|
||||
|
||||
return w - buf;
|
||||
}
|
||||
return w - buf;
|
||||
}
|
||||
}
|
||||
|
||||
return bytes_read;
|
||||
@@ -878,7 +878,7 @@ scan_integer (char const *number, int base, location loc)
|
||||
/*------------------------------------------------------------------.
|
||||
| Convert universal character name UCN to a single-byte character, |
|
||||
| and return that character. Return -1 if UCN does not correspond |
|
||||
| to a single-byte character. |
|
||||
| to a single-byte character. |
|
||||
`------------------------------------------------------------------*/
|
||||
|
||||
static int
|
||||
@@ -906,22 +906,22 @@ convert_ucn_to_byte (char const *ucn)
|
||||
about. */
|
||||
static signed char const table[] =
|
||||
{
|
||||
'\0', -1, -1, -1, -1, -1, -1, '\a',
|
||||
'\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', '{', '|', '}', '~'
|
||||
'\0', -1, -1, -1, -1, -1, -1, '\a',
|
||||
'\b', '\t', '\n', '\v', '\f', '\r', -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1,
|
||||
' ', '!', '"', '#', '$', '%', '&', '\'',
|
||||
'(', ')', '*', '+', ',', '-', '.', '/',
|
||||
'0', '1', '2', '3', '4', '5', '6', '7',
|
||||
'8', '9', ':', ';', '<', '=', '>', '?',
|
||||
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
|
||||
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
|
||||
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
|
||||
'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
|
||||
'`', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
|
||||
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
|
||||
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
|
||||
'x', 'y', 'z', '{', '|', '}', '~'
|
||||
};
|
||||
|
||||
code = code < sizeof table ? table[code] : -1;
|
||||
@@ -955,8 +955,8 @@ handle_syncline (char *args, location loc)
|
||||
|
||||
/*----------------------------------------------------------------.
|
||||
| For a token or comment starting at START, report message MSGID, |
|
||||
| which should say that an end marker was found before |
|
||||
| the expected TOKEN_END. |
|
||||
| which should say that an end marker was found before |
|
||||
| the expected TOKEN_END. |
|
||||
`----------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
|
||||
@@ -89,8 +89,8 @@ static void fail_for_invalid_at (char const *at);
|
||||
|
||||
/* This pattern must not match more than the previous @ patterns. */
|
||||
@[^@{}`(\n]* fail_for_invalid_at (yytext);
|
||||
\n out_lineno++; ECHO;
|
||||
[^@\n]+ ECHO;
|
||||
\n out_lineno++; ECHO;
|
||||
[^@\n]+ ECHO;
|
||||
|
||||
<INITIAL><<EOF>> {
|
||||
if (outname)
|
||||
|
||||
54
src/state.c
54
src/state.c
@@ -28,9 +28,9 @@
|
||||
#include "print-xml.h"
|
||||
|
||||
|
||||
/*-------------------.
|
||||
| Shifts and Gotos. |
|
||||
`-------------------*/
|
||||
/*-------------------.
|
||||
| Shifts and Gotos. |
|
||||
`-------------------*/
|
||||
|
||||
|
||||
/*-----------------------------------------.
|
||||
@@ -61,14 +61,14 @@ transitions_to (transitions *shifts, symbol_number sym)
|
||||
{
|
||||
aver (j < shifts->num);
|
||||
if (TRANSITION_SYMBOL (shifts, j) == sym)
|
||||
return shifts->states[j];
|
||||
return shifts->states[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*--------------------.
|
||||
| Error transitions. |
|
||||
`--------------------*/
|
||||
/*--------------------.
|
||||
| Error transitions. |
|
||||
`--------------------*/
|
||||
|
||||
|
||||
/*---------------------------------.
|
||||
@@ -88,9 +88,9 @@ errs_new (int num, symbol **tokens)
|
||||
|
||||
|
||||
|
||||
/*-------------.
|
||||
| Reductions. |
|
||||
`-------------*/
|
||||
/*-------------.
|
||||
| Reductions. |
|
||||
`-------------*/
|
||||
|
||||
|
||||
/*---------------------------------------.
|
||||
@@ -110,9 +110,9 @@ reductions_new (int num, rule **reds)
|
||||
|
||||
|
||||
|
||||
/*---------.
|
||||
| States. |
|
||||
`---------*/
|
||||
/*---------.
|
||||
| States. |
|
||||
`---------*/
|
||||
|
||||
|
||||
state_number nstates = 0;
|
||||
@@ -128,7 +128,7 @@ state *final_state = NULL;
|
||||
|
||||
state *
|
||||
state_new (symbol_number accessing_symbol,
|
||||
size_t nitems, item_number *core)
|
||||
size_t nitems, item_number *core)
|
||||
{
|
||||
state *res;
|
||||
size_t items_size = nitems * sizeof *core;
|
||||
@@ -264,17 +264,17 @@ state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out)
|
||||
char const *sep = "";
|
||||
fprintf (out, " [");
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
||||
{
|
||||
fprintf (out, "%s%s", sep, symbols[k]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
{
|
||||
fprintf (out, "%s%s", sep, symbols[k]->tag);
|
||||
sep = ", ";
|
||||
}
|
||||
fprintf (out, "]");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
||||
FILE *out, int level)
|
||||
FILE *out, int level)
|
||||
{
|
||||
/* Find the reduction we are handling. */
|
||||
reductions *reds = s->reductions;
|
||||
@@ -287,10 +287,10 @@ state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
||||
int k;
|
||||
xml_puts (out, level, "<lookaheads>");
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[red], k, 0)
|
||||
{
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[k]->tag));
|
||||
}
|
||||
{
|
||||
xml_printf (out, level + 1, "<symbol>%s</symbol>",
|
||||
xml_escape (symbols[k]->tag));
|
||||
}
|
||||
xml_puts (out, level, "</lookaheads>");
|
||||
}
|
||||
}
|
||||
@@ -353,10 +353,10 @@ void
|
||||
state_hash_new (void)
|
||||
{
|
||||
state_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
state_hasher,
|
||||
state_comparator,
|
||||
NULL);
|
||||
NULL,
|
||||
state_hasher,
|
||||
state_comparator,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
16
src/state.h
16
src/state.h
@@ -148,12 +148,12 @@ typedef struct
|
||||
|
||||
|
||||
/* Iterate over each transition over a token (shifts). */
|
||||
#define FOR_EACH_SHIFT(Transitions, Iter) \
|
||||
for (Iter = 0; \
|
||||
Iter < Transitions->num \
|
||||
&& (TRANSITION_IS_DISABLED (Transitions, Iter) \
|
||||
|| TRANSITION_IS_SHIFT (Transitions, Iter)); \
|
||||
++Iter) \
|
||||
#define FOR_EACH_SHIFT(Transitions, Iter) \
|
||||
for (Iter = 0; \
|
||||
Iter < Transitions->num \
|
||||
&& (TRANSITION_IS_DISABLED (Transitions, Iter) \
|
||||
|| TRANSITION_IS_SHIFT (Transitions, Iter)); \
|
||||
++Iter) \
|
||||
if (!TRANSITION_IS_DISABLED (Transitions, Iter))
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ extern state *final_state;
|
||||
|
||||
/* Create a new state with ACCESSING_SYMBOL for those items. */
|
||||
state *state_new (symbol_number accessing_symbol,
|
||||
size_t core_size, item_number *core);
|
||||
size_t core_size, item_number *core);
|
||||
state *state_new_isocore (state const *s);
|
||||
|
||||
/* Set the transitions of STATE. */
|
||||
@@ -246,7 +246,7 @@ void state_errs_set (state *s, int num, symbol **errors);
|
||||
reduce R. */
|
||||
void state_rule_lookahead_tokens_print (state *s, rule *r, FILE *out);
|
||||
void state_rule_lookahead_tokens_print_xml (state *s, rule *r,
|
||||
FILE *out, int level);
|
||||
FILE *out, int level);
|
||||
|
||||
/* Create/destroy the states hash table. */
|
||||
void state_hash_new (void);
|
||||
|
||||
@@ -123,7 +123,7 @@ symbol_list_syms_print (const symbol_list *l, FILE *f)
|
||||
symbol_print (l->content.sym, f);
|
||||
fprintf (stderr, l->action_props.is_value_used ? " used" : " unused");
|
||||
if (l && l->content.sym)
|
||||
fprintf (f, ", ");
|
||||
fprintf (f, ", ");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ symbol_list_n_get (symbol_list *l, int n)
|
||||
l = l->next;
|
||||
if (l == NULL
|
||||
|| (l->content_type == SYMLIST_SYMBOL && l->content.sym == NULL))
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return l;
|
||||
|
||||
98
src/symtab.c
98
src/symtab.c
@@ -90,7 +90,7 @@ symbol_new (uniqstr tag, location loc)
|
||||
|
||||
if (nsyms == SYMBOL_NUMBER_MAXIMUM)
|
||||
fatal (_("too many symbols in input grammar (limit is %d)"),
|
||||
SYMBOL_NUMBER_MAXIMUM);
|
||||
SYMBOL_NUMBER_MAXIMUM);
|
||||
nsyms++;
|
||||
return res;
|
||||
}
|
||||
@@ -117,8 +117,8 @@ semantic_type_new (uniqstr tag)
|
||||
| Print a symbol. |
|
||||
`-----------------*/
|
||||
|
||||
#define SYMBOL_ATTR_PRINT(Attr) \
|
||||
if (s->Attr) \
|
||||
#define SYMBOL_ATTR_PRINT(Attr) \
|
||||
if (s->Attr) \
|
||||
fprintf (f, " %s { %s }", #Attr, s->Attr)
|
||||
|
||||
#define SYMBOL_CODE_PRINT(Attr) \
|
||||
@@ -211,7 +211,7 @@ symbol_type_set (symbol *sym, uniqstr type_name, location loc)
|
||||
if (type_name)
|
||||
{
|
||||
if (sym->type_name)
|
||||
symbol_redeclaration (sym, "%type", sym->type_location, loc);
|
||||
symbol_redeclaration (sym, "%type", sym->type_location, loc);
|
||||
uniqstr_assert (type_name);
|
||||
sym->type_name = type_name;
|
||||
sym->type_location = loc;
|
||||
@@ -340,7 +340,7 @@ symbol_precedence_set (symbol *sym, int prec, assoc a, location loc)
|
||||
if (a != undef_assoc)
|
||||
{
|
||||
if (sym->prec != 0)
|
||||
symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location,
|
||||
symbol_redeclaration (sym, assoc_to_string (a), sym->prec_location,
|
||||
loc);
|
||||
sym->prec = prec;
|
||||
sym->assoc = a;
|
||||
@@ -375,7 +375,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
|
||||
if (declaring)
|
||||
{
|
||||
if (sym->declared)
|
||||
warn_at (loc, _("symbol %s redeclared"), sym->tag);
|
||||
warn_at (loc, _("symbol %s redeclared"), sym->tag);
|
||||
sym->declared = true;
|
||||
}
|
||||
}
|
||||
@@ -404,7 +404,7 @@ symbol_user_token_number_set (symbol *sym, int user_token_number, location loc)
|
||||
{
|
||||
endtoken = sym;
|
||||
/* It is always mapped to 0, so it was already counted in
|
||||
NTOKENS. */
|
||||
NTOKENS. */
|
||||
if (endtoken->number != NUMBER_UNDEFINED)
|
||||
--ntokens;
|
||||
endtoken->number = 0;
|
||||
@@ -423,9 +423,9 @@ symbol_check_defined (symbol *sym)
|
||||
if (sym->class == unknown_sym)
|
||||
{
|
||||
complain_at
|
||||
(sym->location,
|
||||
_("symbol %s is used, but is not defined as a token and has no rules"),
|
||||
sym->tag);
|
||||
(sym->location,
|
||||
_("symbol %s is used, but is not defined as a token and has no rules"),
|
||||
sym->tag);
|
||||
sym->class = nterm_sym;
|
||||
sym->number = nvars++;
|
||||
}
|
||||
@@ -445,10 +445,10 @@ symbol_make_alias (symbol *sym, symbol *str, location loc)
|
||||
{
|
||||
if (str->alias)
|
||||
warn_at (loc, _("symbol `%s' used more than once as a literal string"),
|
||||
str->tag);
|
||||
str->tag);
|
||||
else if (sym->alias)
|
||||
warn_at (loc, _("symbol `%s' given more than one literal string"),
|
||||
sym->tag);
|
||||
sym->tag);
|
||||
else
|
||||
{
|
||||
str->class = token_sym;
|
||||
@@ -481,42 +481,42 @@ symbol_check_alias_consistency (symbol *this)
|
||||
if (str->type_name != sym->type_name)
|
||||
{
|
||||
if (str->type_name)
|
||||
symbol_type_set (sym, str->type_name, str->type_location);
|
||||
symbol_type_set (sym, str->type_name, str->type_location);
|
||||
else
|
||||
symbol_type_set (str, sym->type_name, sym->type_location);
|
||||
symbol_type_set (str, sym->type_name, sym->type_location);
|
||||
}
|
||||
|
||||
|
||||
if (str->destructor.code || sym->destructor.code)
|
||||
{
|
||||
if (str->destructor.code)
|
||||
symbol_destructor_set (sym, &str->destructor);
|
||||
symbol_destructor_set (sym, &str->destructor);
|
||||
else
|
||||
symbol_destructor_set (str, &sym->destructor);
|
||||
symbol_destructor_set (str, &sym->destructor);
|
||||
}
|
||||
|
||||
if (str->printer.code || sym->printer.code)
|
||||
{
|
||||
if (str->printer.code)
|
||||
symbol_printer_set (sym, &str->printer);
|
||||
symbol_printer_set (sym, &str->printer);
|
||||
else
|
||||
symbol_printer_set (str, &sym->printer);
|
||||
symbol_printer_set (str, &sym->printer);
|
||||
}
|
||||
|
||||
if (sym->prec || str->prec)
|
||||
{
|
||||
if (str->prec)
|
||||
symbol_precedence_set (sym, str->prec, str->assoc,
|
||||
str->prec_location);
|
||||
symbol_precedence_set (sym, str->prec, str->assoc,
|
||||
str->prec_location);
|
||||
else
|
||||
symbol_precedence_set (str, sym->prec, sym->assoc,
|
||||
sym->prec_location);
|
||||
symbol_precedence_set (str, sym->prec, sym->assoc,
|
||||
sym->prec_location);
|
||||
}
|
||||
}
|
||||
|
||||
static bool
|
||||
symbol_check_alias_consistency_processor (void *this,
|
||||
void *null ATTRIBUTE_UNUSED)
|
||||
void *null ATTRIBUTE_UNUSED)
|
||||
{
|
||||
symbol_check_alias_consistency (this);
|
||||
return true;
|
||||
@@ -582,7 +582,7 @@ symbol_translation (symbol *this)
|
||||
{
|
||||
/* A token which translation has already been set? */
|
||||
if (token_translations[this->user_token_number] != undeftoken->number)
|
||||
user_token_number_redeclaration
|
||||
user_token_number_redeclaration
|
||||
(this->user_token_number,
|
||||
symbols[token_translations[this->user_token_number]],
|
||||
this);
|
||||
@@ -670,15 +670,15 @@ void
|
||||
symbols_new (void)
|
||||
{
|
||||
symbol_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
hash_symbol_hasher,
|
||||
hash_symbol_comparator,
|
||||
free);
|
||||
NULL,
|
||||
hash_symbol_hasher,
|
||||
hash_symbol_comparator,
|
||||
free);
|
||||
semantic_type_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
hash_semantic_type_hasher,
|
||||
hash_semantic_type_comparator,
|
||||
free);
|
||||
NULL,
|
||||
hash_semantic_type_hasher,
|
||||
hash_semantic_type_comparator,
|
||||
free);
|
||||
}
|
||||
|
||||
|
||||
@@ -862,12 +862,12 @@ symbols_token_translations_init (void)
|
||||
{
|
||||
symbol *this = symbols[i];
|
||||
if (this->user_token_number != USER_NUMBER_UNDEFINED)
|
||||
{
|
||||
if (this->user_token_number > max_user_token_number)
|
||||
max_user_token_number = this->user_token_number;
|
||||
if (this->user_token_number == 256)
|
||||
num_256_available_p = false;
|
||||
}
|
||||
{
|
||||
if (this->user_token_number > max_user_token_number)
|
||||
max_user_token_number = this->user_token_number;
|
||||
if (this->user_token_number == 256)
|
||||
num_256_available_p = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* If 256 is not used, assign it to error, to follow POSIX. */
|
||||
@@ -883,13 +883,13 @@ symbols_token_translations_init (void)
|
||||
{
|
||||
symbol *this = symbols[i];
|
||||
if (this->user_token_number == USER_NUMBER_UNDEFINED)
|
||||
this->user_token_number = ++max_user_token_number;
|
||||
this->user_token_number = ++max_user_token_number;
|
||||
if (this->user_token_number > max_user_token_number)
|
||||
max_user_token_number = this->user_token_number;
|
||||
max_user_token_number = this->user_token_number;
|
||||
}
|
||||
|
||||
token_translations = xnmalloc (max_user_token_number + 1,
|
||||
sizeof *token_translations);
|
||||
sizeof *token_translations);
|
||||
|
||||
/* Initialize all entries for literal tokens to the internal token
|
||||
number for $undefined, which represents all invalid inputs. */
|
||||
@@ -940,12 +940,12 @@ symbols_pack (void)
|
||||
|
||||
if (startsymbol->class == unknown_sym)
|
||||
fatal_at (startsymbol_location,
|
||||
_("the start symbol %s is undefined"),
|
||||
startsymbol->tag);
|
||||
_("the start symbol %s is undefined"),
|
||||
startsymbol->tag);
|
||||
else if (startsymbol->class == token_sym)
|
||||
fatal_at (startsymbol_location,
|
||||
_("the start symbol %s is a token"),
|
||||
startsymbol->tag);
|
||||
_("the start symbol %s is a token"),
|
||||
startsymbol->tag);
|
||||
}
|
||||
|
||||
|
||||
@@ -961,7 +961,7 @@ default_tagged_destructor_set (code_props const *destructor)
|
||||
complain_at (destructor->location,
|
||||
_("redeclaration for default tagged %%destructor"));
|
||||
complain_at (default_tagged_destructor.location,
|
||||
_("previous declaration"));
|
||||
_("previous declaration"));
|
||||
}
|
||||
default_tagged_destructor = *destructor;
|
||||
}
|
||||
@@ -974,7 +974,7 @@ default_tagless_destructor_set (code_props const *destructor)
|
||||
complain_at (destructor->location,
|
||||
_("redeclaration for default tagless %%destructor"));
|
||||
complain_at (default_tagless_destructor.location,
|
||||
_("previous declaration"));
|
||||
_("previous declaration"));
|
||||
}
|
||||
default_tagless_destructor = *destructor;
|
||||
}
|
||||
@@ -987,7 +987,7 @@ default_tagged_printer_set (code_props const *printer)
|
||||
complain_at (printer->location,
|
||||
_("redeclaration for default tagged %%printer"));
|
||||
complain_at (default_tagged_printer.location,
|
||||
_("previous declaration"));
|
||||
_("previous declaration"));
|
||||
}
|
||||
default_tagged_printer = *printer;
|
||||
}
|
||||
@@ -1000,7 +1000,7 @@ default_tagless_printer_set (code_props const *printer)
|
||||
complain_at (printer->location,
|
||||
_("redeclaration for default tagless %%printer"));
|
||||
complain_at (default_tagless_printer.location,
|
||||
_("previous declaration"));
|
||||
_("previous declaration"));
|
||||
}
|
||||
default_tagless_printer = *printer;
|
||||
}
|
||||
|
||||
@@ -39,8 +39,8 @@
|
||||
typedef enum
|
||||
{
|
||||
unknown_sym, /**< Undefined. */
|
||||
token_sym, /**< Terminal. */
|
||||
nterm_sym /**< Non-terminal. */
|
||||
token_sym, /**< Terminal. */
|
||||
nterm_sym /**< Non-terminal. */
|
||||
} symbol_class;
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ void symbol_precedence_set (symbol *sym, int prec, assoc a, location loc);
|
||||
|
||||
/** Set the \c class associated with \c sym. */
|
||||
void symbol_class_set (symbol *sym, symbol_class class, location loc,
|
||||
bool declaring);
|
||||
bool declaring);
|
||||
|
||||
/** Set the \c user_token_number associated with \c sym. */
|
||||
void symbol_user_token_number_set (symbol *sym, int user_number, location loc);
|
||||
|
||||
56
src/system.h
56
src/system.h
@@ -161,32 +161,32 @@ typedef size_t uintptr_t;
|
||||
#define obstack_sgrow(Obs, Str) \
|
||||
obstack_grow (Obs, Str, strlen (Str))
|
||||
|
||||
#define obstack_fgrow1(Obs, Format, Arg1) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
#define obstack_fgrow1(Obs, Format, Arg1) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
|
||||
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
#define obstack_fgrow2(Obs, Format, Arg1, Arg2) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
|
||||
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2, Arg3); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
#define obstack_fgrow3(Obs, Format, Arg1, Arg2, Arg3) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2, Arg3); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
|
||||
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
#define obstack_fgrow4(Obs, Format, Arg1, Arg2, Arg3, Arg4) \
|
||||
do { \
|
||||
char buf[4096]; \
|
||||
sprintf (buf, Format, Arg1, Arg2, Arg3, Arg4); \
|
||||
obstack_grow (Obs, buf, strlen (buf)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
@@ -213,14 +213,14 @@ do { \
|
||||
| Free a linked list. |
|
||||
`---------------------*/
|
||||
|
||||
#define LIST_FREE(Type, List) \
|
||||
do { \
|
||||
Type *_node, *_next; \
|
||||
for (_node = List; _node; _node = _next) \
|
||||
{ \
|
||||
_next = _node->next; \
|
||||
free (_node); \
|
||||
} \
|
||||
#define LIST_FREE(Type, List) \
|
||||
do { \
|
||||
Type *_node, *_next; \
|
||||
for (_node = List; _node; _node = _next) \
|
||||
{ \
|
||||
_next = _node->next; \
|
||||
free (_node); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
|
||||
294
src/tables.c
294
src/tables.c
@@ -152,11 +152,11 @@ table_grow (int desired)
|
||||
|
||||
if (trace_flag & trace_resource)
|
||||
fprintf (stderr, "growing table and check from: %d to %d\n",
|
||||
old_size, table_size);
|
||||
old_size, table_size);
|
||||
|
||||
table = xnrealloc (table, table_size, sizeof *table);
|
||||
conflict_table = xnrealloc (conflict_table, table_size,
|
||||
sizeof *conflict_table);
|
||||
sizeof *conflict_table);
|
||||
check = xnrealloc (check, table_size, sizeof *check);
|
||||
|
||||
for (/* Nothing. */; old_size < table_size; ++old_size)
|
||||
@@ -172,12 +172,12 @@ table_grow (int desired)
|
||||
|
||||
/*-------------------------------------------------------------------.
|
||||
| For GLR parsers, for each conflicted token in S, as indicated |
|
||||
| by non-zero entries in CONFLROW, create a list of possible |
|
||||
| reductions that are alternatives to the shift or reduction |
|
||||
| by non-zero entries in CONFLROW, create a list of possible |
|
||||
| reductions that are alternatives to the shift or reduction |
|
||||
| currently recorded for that token in S. Store the alternative |
|
||||
| reductions followed by a 0 in CONFLICT_LIST, updating |
|
||||
| reductions followed by a 0 in CONFLICT_LIST, updating |
|
||||
| CONFLICT_LIST_CNT, and storing an index to the start of the list |
|
||||
| back into CONFLROW. |
|
||||
| back into CONFLROW. |
|
||||
`-------------------------------------------------------------------*/
|
||||
|
||||
static void
|
||||
@@ -192,26 +192,26 @@ conflict_row (state *s)
|
||||
for (j = 0; j < ntokens; j += 1)
|
||||
if (conflrow[j])
|
||||
{
|
||||
conflrow[j] = conflict_list_cnt;
|
||||
conflrow[j] = conflict_list_cnt;
|
||||
|
||||
/* 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->lookahead_tokens[i], j)
|
||||
&& (actrow[j]
|
||||
!= rule_number_as_item_number (reds->rules[i]->number)))
|
||||
{
|
||||
aver (0 < conflict_list_free);
|
||||
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
|
||||
conflict_list_cnt += 1;
|
||||
conflict_list_free -= 1;
|
||||
}
|
||||
/* 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->lookahead_tokens[i], j)
|
||||
&& (actrow[j]
|
||||
!= rule_number_as_item_number (reds->rules[i]->number)))
|
||||
{
|
||||
aver (0 < conflict_list_free);
|
||||
conflict_list[conflict_list_cnt] = reds->rules[i]->number + 1;
|
||||
conflict_list_cnt += 1;
|
||||
conflict_list_free -= 1;
|
||||
}
|
||||
|
||||
/* Leave a 0 at the end. */
|
||||
aver (0 < conflict_list_free);
|
||||
conflict_list[conflict_list_cnt] = 0;
|
||||
conflict_list_cnt += 1;
|
||||
conflict_list_free -= 1;
|
||||
/* Leave a 0 at the end. */
|
||||
aver (0 < conflict_list_free);
|
||||
conflict_list[conflict_list_cnt] = 0;
|
||||
conflict_list_cnt += 1;
|
||||
conflict_list_free -= 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,9 +222,9 @@ conflict_row (state *s)
|
||||
| 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 |
|
||||
| ACTION_NUMBER_MINIMUM, a very negative number, means this |
|
||||
| situation is an error. The parser recognizes this value |
|
||||
| specially. |
|
||||
| ACTION_NUMBER_MINIMUM, a very negative number, means this |
|
||||
| situation is an error. The parser recognizes this value |
|
||||
| specially. |
|
||||
| |
|
||||
| This is where conflicts are resolved. The loop over lookahead |
|
||||
| rules considered lower-numbered rules last, and the last rule |
|
||||
@@ -256,22 +256,22 @@ action_row (state *s)
|
||||
int j;
|
||||
bitset_iterator biter;
|
||||
/* loop over all the rules available here which require
|
||||
lookahead (in reverse order to give precedence to the first
|
||||
rule) */
|
||||
lookahead (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->lookahead_tokens[i], j, 0)
|
||||
{
|
||||
/* and record this rule as the rule to use if that
|
||||
token follows. */
|
||||
if (actrow[j] != 0)
|
||||
{
|
||||
conflicted = true;
|
||||
conflrow[j] = 1;
|
||||
}
|
||||
actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
|
||||
}
|
||||
/* and find each token which the rule finds acceptable
|
||||
to come next */
|
||||
BITSET_FOR_EACH (biter, reds->lookahead_tokens[i], j, 0)
|
||||
{
|
||||
/* and record this rule as the rule to use if that
|
||||
token follows. */
|
||||
if (actrow[j] != 0)
|
||||
{
|
||||
conflicted = true;
|
||||
conflrow[j] = 1;
|
||||
}
|
||||
actrow[j] = rule_number_as_item_number (reds->rules[i]->number);
|
||||
}
|
||||
}
|
||||
|
||||
/* Now see which tokens are allowed for shifts in this state. For
|
||||
@@ -283,16 +283,16 @@ action_row (state *s)
|
||||
state *shift_state = trans->states[i];
|
||||
|
||||
if (actrow[sym] != 0)
|
||||
{
|
||||
conflicted = true;
|
||||
conflrow[sym] = 1;
|
||||
}
|
||||
{
|
||||
conflicted = true;
|
||||
conflrow[sym] = 1;
|
||||
}
|
||||
actrow[sym] = state_number_as_int (shift_state->number);
|
||||
|
||||
/* Do not use any default reduction if there is a shift for
|
||||
error */
|
||||
error */
|
||||
if (sym == errtoken->number)
|
||||
nodefault = true;
|
||||
nodefault = true;
|
||||
}
|
||||
|
||||
/* See which tokens are an explicit error in this state (due to
|
||||
@@ -321,43 +321,43 @@ action_row (state *s)
|
||||
if (reds->num >= 1 && !nodefault)
|
||||
{
|
||||
if (s->consistent)
|
||||
default_reduction = reds->rules[0];
|
||||
default_reduction = reds->rules[0];
|
||||
else
|
||||
{
|
||||
int max = 0;
|
||||
for (i = 0; i < reds->num; i++)
|
||||
{
|
||||
int count = 0;
|
||||
rule *r = reds->rules[i];
|
||||
symbol_number j;
|
||||
{
|
||||
int max = 0;
|
||||
for (i = 0; i < reds->num; i++)
|
||||
{
|
||||
int count = 0;
|
||||
rule *r = reds->rules[i];
|
||||
symbol_number j;
|
||||
|
||||
for (j = 0; j < ntokens; j++)
|
||||
if (actrow[j] == rule_number_as_item_number (r->number))
|
||||
count++;
|
||||
for (j = 0; j < ntokens; j++)
|
||||
if (actrow[j] == rule_number_as_item_number (r->number))
|
||||
count++;
|
||||
|
||||
if (count > max)
|
||||
{
|
||||
max = count;
|
||||
default_reduction = r;
|
||||
}
|
||||
}
|
||||
if (count > max)
|
||||
{
|
||||
max = count;
|
||||
default_reduction = r;
|
||||
}
|
||||
}
|
||||
|
||||
/* GLR parsers need space for conflict lists, so we can't
|
||||
default conflicted entries. For non-conflicted entries
|
||||
or as long as we are not building a GLR parser,
|
||||
actions that match the default are replaced with zero,
|
||||
which means "use the default". */
|
||||
/* GLR parsers need space for conflict lists, so we can't
|
||||
default conflicted entries. For non-conflicted entries
|
||||
or as long as we are not building a GLR parser,
|
||||
actions that match the default are replaced with zero,
|
||||
which means "use the default". */
|
||||
|
||||
if (max > 0)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < ntokens; j++)
|
||||
if (actrow[j]
|
||||
if (max > 0)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < ntokens; j++)
|
||||
if (actrow[j]
|
||||
== rule_number_as_item_number (default_reduction->number)
|
||||
&& ! (nondeterministic_parser && conflrow[j]))
|
||||
actrow[j] = 0;
|
||||
}
|
||||
}
|
||||
&& ! (nondeterministic_parser && conflrow[j]))
|
||||
actrow[j] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If have no default reduction, the default is an error.
|
||||
@@ -366,7 +366,7 @@ action_row (state *s)
|
||||
if (!default_reduction)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (actrow[i] == ACTION_NUMBER_MINIMUM)
|
||||
actrow[i] = 0;
|
||||
actrow[i] = 0;
|
||||
|
||||
if (conflicted)
|
||||
conflict_row (s);
|
||||
@@ -408,10 +408,10 @@ save_row (state_number s)
|
||||
for (i = 0; i < ntokens; i++)
|
||||
if (actrow[i] != 0)
|
||||
{
|
||||
*sp1++ = i;
|
||||
*sp2++ = actrow[i];
|
||||
if (nondeterministic_parser)
|
||||
*sp3++ = conflrow[i];
|
||||
*sp1++ = i;
|
||||
*sp2++ = actrow[i];
|
||||
if (nondeterministic_parser)
|
||||
*sp3++ = conflrow[i];
|
||||
}
|
||||
|
||||
tally[s] = count;
|
||||
@@ -457,16 +457,16 @@ token_actions (void)
|
||||
save_row (i);
|
||||
|
||||
/* Now that the parser was computed, we can find which rules are
|
||||
really reduced, and which are not because of SR or RR
|
||||
conflicts. */
|
||||
really reduced, and which are not because of SR or RR
|
||||
conflicts. */
|
||||
if (!nondeterministic_parser)
|
||||
{
|
||||
for (j = 0; j < ntokens; ++j)
|
||||
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
|
||||
rules[item_number_as_rule_number (actrow[j])].useful = true;
|
||||
if (yydefact[i])
|
||||
rules[yydefact[i] - 1].useful = true;
|
||||
}
|
||||
{
|
||||
for (j = 0; j < ntokens; ++j)
|
||||
if (actrow[j] < 0 && actrow[j] != ACTION_NUMBER_MINIMUM)
|
||||
rules[item_number_as_rule_number (actrow[j])].useful = true;
|
||||
if (yydefact[i])
|
||||
rules[yydefact[i] - 1].useful = true;
|
||||
}
|
||||
}
|
||||
|
||||
free (actrow);
|
||||
@@ -513,8 +513,8 @@ save_column (symbol_number sym, state_number default_state)
|
||||
for (i = begin; i < end; i++)
|
||||
if (to_state[i] != default_state)
|
||||
{
|
||||
*sp1++ = from_state[i];
|
||||
*sp2++ = to_state[i];
|
||||
*sp1++ = from_state[i];
|
||||
*sp2++ = to_state[i];
|
||||
}
|
||||
|
||||
tally[symno] = count;
|
||||
@@ -548,8 +548,8 @@ default_goto (symbol_number sym, size_t state_count[])
|
||||
for (s = 0; s < nstates; s++)
|
||||
if (state_count[s] > max)
|
||||
{
|
||||
max = state_count[s];
|
||||
default_state = s;
|
||||
max = state_count[s];
|
||||
default_state = s;
|
||||
}
|
||||
|
||||
return default_state;
|
||||
@@ -599,22 +599,22 @@ sort_actions (void)
|
||||
for (i = 0; i < nvectors; i++)
|
||||
if (tally[i] > 0)
|
||||
{
|
||||
int k;
|
||||
int t = tally[i];
|
||||
int w = width[i];
|
||||
int j = nentries - 1;
|
||||
int k;
|
||||
int t = tally[i];
|
||||
int w = width[i];
|
||||
int j = nentries - 1;
|
||||
|
||||
while (j >= 0 && (width[order[j]] < w))
|
||||
j--;
|
||||
while (j >= 0 && (width[order[j]] < w))
|
||||
j--;
|
||||
|
||||
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
|
||||
j--;
|
||||
while (j >= 0 && (width[order[j]] == w) && (tally[order[j]] < t))
|
||||
j--;
|
||||
|
||||
for (k = nentries - 1; k > j; k--)
|
||||
order[k + 1] = order[k];
|
||||
for (k = nentries - 1; k > j; k--)
|
||||
order[k + 1] = order[k];
|
||||
|
||||
order[j + 1] = i;
|
||||
nentries++;
|
||||
order[j + 1] = i;
|
||||
nentries++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,8 +645,8 @@ matching_state (vector_number vector)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < t; j += 1)
|
||||
if (conflict_tos[i][j] != 0)
|
||||
return -1;
|
||||
if (conflict_tos[i][j] != 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (prev = vector - 1; prev >= 0; prev--)
|
||||
@@ -656,17 +656,17 @@ matching_state (vector_number vector)
|
||||
int match = 1;
|
||||
|
||||
/* Given how ORDER was computed, if the WIDTH or TALLY is
|
||||
different, there cannot be a matching state. */
|
||||
different, there cannot be a matching state. */
|
||||
if (width[j] != w || tally[j] != t)
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
for (k = 0; match && k < t; k++)
|
||||
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
|
||||
|| (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
|
||||
match = 0;
|
||||
if (tos[j][k] != tos[i][k] || froms[j][k] != froms[i][k]
|
||||
|| (conflict_tos[j] != NULL && conflict_tos[j][k] != 0))
|
||||
match = 0;
|
||||
|
||||
if (match)
|
||||
return j;
|
||||
return j;
|
||||
}
|
||||
|
||||
return -1;
|
||||
@@ -694,39 +694,39 @@ pack_vector (vector_number vector)
|
||||
aver (j < table_size);
|
||||
|
||||
for (k = 0; ok && k < t; k++)
|
||||
{
|
||||
loc = j + state_number_as_int (from[k]);
|
||||
if (table_size <= loc)
|
||||
table_grow (loc);
|
||||
{
|
||||
loc = j + state_number_as_int (from[k]);
|
||||
if (table_size <= loc)
|
||||
table_grow (loc);
|
||||
|
||||
if (table[loc] != 0)
|
||||
ok = false;
|
||||
}
|
||||
if (table[loc] != 0)
|
||||
ok = false;
|
||||
}
|
||||
|
||||
for (k = 0; ok && k < vector; k++)
|
||||
if (pos[k] == j)
|
||||
ok = false;
|
||||
if (pos[k] == j)
|
||||
ok = false;
|
||||
|
||||
if (ok)
|
||||
{
|
||||
for (k = 0; k < t; k++)
|
||||
{
|
||||
loc = j + from[k];
|
||||
table[loc] = to[k];
|
||||
if (nondeterministic_parser && conflict_to != NULL)
|
||||
conflict_table[loc] = conflict_to[k];
|
||||
check[loc] = from[k];
|
||||
}
|
||||
{
|
||||
for (k = 0; k < t; k++)
|
||||
{
|
||||
loc = j + from[k];
|
||||
table[loc] = to[k];
|
||||
if (nondeterministic_parser && conflict_to != NULL)
|
||||
conflict_table[loc] = conflict_to[k];
|
||||
check[loc] = from[k];
|
||||
}
|
||||
|
||||
while (table[lowzero] != 0)
|
||||
lowzero++;
|
||||
while (table[lowzero] != 0)
|
||||
lowzero++;
|
||||
|
||||
if (loc > high)
|
||||
high = loc;
|
||||
if (loc > high)
|
||||
high = loc;
|
||||
|
||||
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
|
||||
return j;
|
||||
}
|
||||
aver (BASE_MINIMUM <= j && j <= BASE_MAXIMUM);
|
||||
return j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -784,11 +784,11 @@ pack_table (void)
|
||||
base_number place;
|
||||
|
||||
if (s < 0)
|
||||
/* A new set of state actions, or a nonterminal. */
|
||||
place = pack_vector (i);
|
||||
/* A new set of state actions, or a nonterminal. */
|
||||
place = pack_vector (i);
|
||||
else
|
||||
/* Action of I were already coded for S. */
|
||||
place = base[s];
|
||||
/* Action of I were already coded for S. */
|
||||
place = base[s];
|
||||
|
||||
pos[i] = place;
|
||||
base[order[i]] = place;
|
||||
@@ -817,7 +817,7 @@ tables_generate (void)
|
||||
correlated. In particular the signedness is not taken into
|
||||
account. But it's not useless. */
|
||||
verify (sizeof nstates <= sizeof nvectors
|
||||
&& sizeof nvars <= sizeof nvectors);
|
||||
&& sizeof nvars <= sizeof nvectors);
|
||||
|
||||
nvectors = state_number_as_int (nstates) + nvars;
|
||||
|
||||
|
||||
@@ -80,7 +80,7 @@ uniqstr_assert (char const *str)
|
||||
if (!hash_lookup (uniqstrs_table, str))
|
||||
{
|
||||
error (0, 0,
|
||||
"not a uniqstr: %s", quotearg (str));
|
||||
"not a uniqstr: %s", quotearg (str));
|
||||
abort ();
|
||||
}
|
||||
}
|
||||
@@ -128,10 +128,10 @@ void
|
||||
uniqstrs_new (void)
|
||||
{
|
||||
uniqstrs_table = hash_initialize (HT_INITIAL_CAPACITY,
|
||||
NULL,
|
||||
hash_uniqstr,
|
||||
hash_compare_uniqstr,
|
||||
free);
|
||||
NULL,
|
||||
hash_uniqstr,
|
||||
hash_compare_uniqstr,
|
||||
free);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user