mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
multistart: adjust computation of initial core and adjust reports
Currently the core of the initial state is limited to the single rule on $accept. * src/lr0.c (generate_states): There may now be several rules on $accept. * src/graphviz.c (conclude_red): Recognize "final" transitions by the fact that we reduce to "$accept". * src/print.c (print_reduction): Likewise. * src/print-xml.c (print_reduction): Likewise.
This commit is contained in:
@@ -101,6 +101,7 @@ no_reduce_bitset_init (state const *s, bitset *no_reduce_set)
|
|||||||
bitset_set (*no_reduce_set, s->errs->symbols[n]->content->number);
|
bitset_set (*no_reduce_set, s->errs->symbols[n]->content->number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Show the reductions from state SOURCE on rule RULENO. */
|
||||||
static void
|
static void
|
||||||
conclude_red (struct obstack *out, int source, rule_number ruleno,
|
conclude_red (struct obstack *out, int source, rule_number ruleno,
|
||||||
bool enabled, bool first, FILE *fout)
|
bool enabled, bool first, FILE *fout)
|
||||||
@@ -112,8 +113,6 @@ conclude_red (struct obstack *out, int source, rule_number ruleno,
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char const *ed = enabled ? "" : "d";
|
char const *ed = enabled ? "" : "d";
|
||||||
char const *color = enabled ? ruleno ? "3" : "1" : "5";
|
|
||||||
|
|
||||||
/* First, build the edge's head. The name of reduction nodes is "nRm",
|
/* First, build the edge's head. The name of reduction nodes is "nRm",
|
||||||
with n the source state and m the rule number. This is because we
|
with n the source state and m the rule number. This is because we
|
||||||
don't want all the reductions bearing a same rule number to point to
|
don't want all the reductions bearing a same rule number to point to
|
||||||
@@ -136,11 +135,16 @@ conclude_red (struct obstack *out, int source, rule_number ruleno,
|
|||||||
/* Build the associated diamond representation of the target rule. */
|
/* Build the associated diamond representation of the target rule. */
|
||||||
fprintf (fout, " \"%dR%d%s\" [label=\"",
|
fprintf (fout, " \"%dR%d%s\" [label=\"",
|
||||||
source, ruleno, ed);
|
source, ruleno, ed);
|
||||||
if (ruleno)
|
bool final = rules[ruleno].lhs->symbol == acceptsymbol;
|
||||||
fprintf (fout, "R%d", ruleno);
|
if (final)
|
||||||
else
|
|
||||||
fprintf (fout, "Acc");
|
fprintf (fout, "Acc");
|
||||||
|
else
|
||||||
|
fprintf (fout, "R%d", ruleno);
|
||||||
|
|
||||||
|
char const *color
|
||||||
|
= !enabled ? "5"
|
||||||
|
: final ? "1"
|
||||||
|
: "3";
|
||||||
fprintf (fout, "\", fillcolor=%s, shape=diamond, style=filled]\n",
|
fprintf (fout, "\", fillcolor=%s, shape=diamond, style=filled]\n",
|
||||||
color);
|
color);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -395,9 +395,10 @@ generate_states (void)
|
|||||||
/* Create the initial state, whose accessing symbol (by convention)
|
/* Create the initial state, whose accessing symbol (by convention)
|
||||||
is 0, aka $end. */
|
is 0, aka $end. */
|
||||||
{
|
{
|
||||||
/* The items of its core. */
|
/* The items of its core: beginning of all the rules of $accept. */
|
||||||
kernel_size[0] = 1;
|
kernel_size[0] = 0;
|
||||||
kernel_base[0][0] = 0;
|
for (rule_number r = 0; r < nrules && rules[r].lhs->symbol == acceptsymbol; ++r)
|
||||||
|
kernel_base[0][kernel_size[0]++] = rules[r].rhs - ritem;
|
||||||
state_list_append (0, kernel_size[0], kernel_base[0]);
|
state_list_append (0, kernel_size[0], kernel_base[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -216,17 +216,18 @@ static void
|
|||||||
print_reduction (FILE *out, int level, char const *lookahead,
|
print_reduction (FILE *out, int level, char const *lookahead,
|
||||||
rule *r, bool enabled)
|
rule *r, bool enabled)
|
||||||
{
|
{
|
||||||
if (r->number)
|
const bool final = r->lhs->symbol == acceptsymbol;
|
||||||
|
if (final)
|
||||||
|
xml_printf (out, level,
|
||||||
|
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
|
||||||
|
xml_escape (lookahead),
|
||||||
|
enabled ? "true" : "false");
|
||||||
|
else
|
||||||
xml_printf (out, level,
|
xml_printf (out, level,
|
||||||
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
|
"<reduction symbol=\"%s\" rule=\"%d\" enabled=\"%s\"/>",
|
||||||
xml_escape (lookahead),
|
xml_escape (lookahead),
|
||||||
r->number,
|
r->number,
|
||||||
enabled ? "true" : "false");
|
enabled ? "true" : "false");
|
||||||
else
|
|
||||||
xml_printf (out, level,
|
|
||||||
"<reduction symbol=\"%s\" rule=\"accept\" enabled=\"%s\"/>",
|
|
||||||
xml_escape (lookahead),
|
|
||||||
enabled ? "true" : "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -196,11 +196,12 @@ print_reduction (FILE *out, size_t width,
|
|||||||
fputc (' ', out);
|
fputc (' ', out);
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
fputc ('[', out);
|
fputc ('[', out);
|
||||||
if (r->number)
|
const bool final = r->lhs->symbol == acceptsymbol;
|
||||||
|
if (final)
|
||||||
|
fprintf (out, _("accept"));
|
||||||
|
else
|
||||||
fprintf (out, _("reduce using rule %d (%s)"), r->number,
|
fprintf (out, _("reduce using rule %d (%s)"), r->number,
|
||||||
r->lhs->symbol->tag);
|
r->lhs->symbol->tag);
|
||||||
else
|
|
||||||
fprintf (out, _("accept"));
|
|
||||||
if (!enabled)
|
if (!enabled)
|
||||||
fputc (']', out);
|
fputc (']', out);
|
||||||
fputc ('\n', out);
|
fputc ('\n', out);
|
||||||
|
|||||||
1149
tests/report.at
1149
tests/report.at
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user