mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
cex: also include in the report on --report=counterexamples
And let --report=all include the counterexamples. * src/getargs.h, src/getargs.c (report_cex): New. * src/main.c: Compute counterexamples when -rcex is specified. * src/print.c: Include the counterexamples when -rcex is specified. * tests/conflicts.at, tests/existing.at, tests/local.at: Adjust.
This commit is contained in:
3
TODO
3
TODO
@@ -32,6 +32,9 @@ could try to use the same color for the same rule.
|
||||
Show the counterexamples. This is going to be really hard and/or painful.
|
||||
Unless we play it dumb (little structure).
|
||||
|
||||
*** Doc
|
||||
-Wcounterexamples, --report=counterexamples
|
||||
|
||||
** glr.cc
|
||||
Get rid of global_tokens_and_yystype.
|
||||
|
||||
|
||||
@@ -206,23 +206,26 @@ ARGMATCH_DEFINE_GROUP (report, enum report)
|
||||
|
||||
static const argmatch_report_doc argmatch_report_docs[] =
|
||||
{
|
||||
{ "states", N_("describe the states") },
|
||||
{ "itemsets", N_("complete the core item sets with their closure") },
|
||||
{ "lookaheads", N_("explicitly associate lookahead tokens to items") },
|
||||
{ "solved", N_("describe shift/reduce conflicts solving") },
|
||||
{ "all", N_("include all the above information") },
|
||||
{ "none", N_("disable the report") },
|
||||
{ "states", N_("describe the states") },
|
||||
{ "itemsets", N_("complete the core item sets with their closure") },
|
||||
{ "lookaheads", N_("explicitly associate lookahead tokens to items") },
|
||||
{ "solved", N_("describe shift/reduce conflicts solving") },
|
||||
{ "counterexamples", N_("generate conflict counterexamples") },
|
||||
{ "all", N_("include all the above information") },
|
||||
{ "none", N_("disable the report") },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
|
||||
static const argmatch_report_arg argmatch_report_args[] =
|
||||
{
|
||||
{ "none", report_none },
|
||||
{ "states", report_states },
|
||||
{ "itemsets", report_states | report_itemsets },
|
||||
{ "lookaheads", report_states | report_lookahead_tokens },
|
||||
{ "solved", report_states | report_solved_conflicts },
|
||||
{ "all", report_all },
|
||||
{ "none", report_none },
|
||||
{ "states", report_states },
|
||||
{ "itemsets", report_states | report_itemsets },
|
||||
{ "lookaheads", report_states | report_lookahead_tokens },
|
||||
{ "solved", report_states | report_solved_conflicts },
|
||||
{ "counterexamples", report_cex },
|
||||
{ "cex", report_cex },
|
||||
{ "all", report_all },
|
||||
{ NULL, report_none },
|
||||
};
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ enum report
|
||||
report_itemsets = 1 << 1,
|
||||
report_lookahead_tokens = 1 << 2,
|
||||
report_solved_conflicts = 1 << 3,
|
||||
report_cex = 1 << 4,
|
||||
report_all = ~0
|
||||
};
|
||||
/** What appears in the *.output file. */
|
||||
|
||||
@@ -146,7 +146,8 @@ main (int argc, char *argv[])
|
||||
conflicts_update_state_numbers (old_to_new, nstates_old);
|
||||
free (old_to_new);
|
||||
}
|
||||
if (warning_is_enabled (Wcounterexamples))
|
||||
if (report_flag & report_cex
|
||||
|| warning_is_enabled (Wcounterexamples))
|
||||
counterexample_init ();
|
||||
conflicts_print ();
|
||||
timevar_pop (tv_conflicts);
|
||||
|
||||
@@ -356,7 +356,9 @@ print_state (FILE *out, const state *s)
|
||||
fputc ('\n', out);
|
||||
fputs (s->solved_conflicts, out);
|
||||
}
|
||||
if (warning_is_enabled (Wcounterexamples) && has_conflicts (s))
|
||||
if (has_conflicts (s)
|
||||
&& (report_flag & report_cex
|
||||
|| warning_is_enabled (Wcounterexamples)))
|
||||
{
|
||||
fputc ('\n', out);
|
||||
counterexample_report_state (s, out, " ");
|
||||
|
||||
@@ -860,6 +860,15 @@ State 5
|
||||
|
||||
OP [reduce using rule 1 (exp)]
|
||||
$default reduce using rule 1 (exp)
|
||||
|
||||
Shift/reduce conflict on token OP:
|
||||
1 exp: exp OP exp .
|
||||
1 exp: exp . OP exp
|
||||
Example exp OP exp • OP exp
|
||||
First derivation exp ::=[ exp ::=[ exp OP exp • ] OP exp ]
|
||||
Example exp OP exp • OP exp
|
||||
Second derivation exp ::=[ exp OP exp ::=[ exp • OP exp ] ]
|
||||
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
@@ -1195,6 +1204,15 @@ State 1
|
||||
$end [reduce using rule 4 (id)]
|
||||
$default reduce using rule 3 (num)
|
||||
|
||||
Reduce/reduce conflict on token $end:
|
||||
3 num: '0' .
|
||||
4 id: '0' .
|
||||
Example '0' •
|
||||
First derivation exp ::=[ num ::=[ '0' • ] ]
|
||||
Example '0' •
|
||||
Second derivation exp ::=[ id ::=[ '0' • ] ]
|
||||
|
||||
|
||||
|
||||
State 2
|
||||
|
||||
@@ -1734,6 +1752,15 @@ State 4
|
||||
|
||||
reported_conflicts go to state 6
|
||||
|
||||
Shift/reduce conflict on token 'a':
|
||||
10 reported_conflicts: . %empty
|
||||
8 reported_conflicts: . 'a'
|
||||
First example resolved_conflict • 'a'
|
||||
First derivation start ::=[ resolved_conflict reported_conflicts ::=[ • ] 'a' ]
|
||||
Second example resolved_conflict • 'a' 'a'
|
||||
Second derivation start ::=[ resolved_conflict reported_conflicts ::=[ • 'a' ] 'a' ]
|
||||
|
||||
|
||||
|
||||
State 5
|
||||
|
||||
@@ -1744,6 +1771,15 @@ State 5
|
||||
'a' [reduce using rule 9 (reported_conflicts)]
|
||||
$default reduce using rule 8 (reported_conflicts)
|
||||
|
||||
Reduce/reduce conflict on token 'a':
|
||||
8 reported_conflicts: 'a' .
|
||||
9 reported_conflicts: 'a' .
|
||||
Example 'a' •
|
||||
First derivation reported_conflicts ::=[ 'a' • ]
|
||||
Example 'a' •
|
||||
Second derivation reported_conflicts ::=[ 'a' • ]
|
||||
|
||||
|
||||
|
||||
State 6
|
||||
|
||||
@@ -1920,6 +1956,15 @@ AT_CHECK([[cat input.output | sed -n '/^State 0$/,/^State 1$/p']], 0,
|
||||
Conflict between rule 10 and token 'b' resolved as an error (%nonassoc 'b').
|
||||
Conflict between rule 11 and token 'c' resolved as an error (%nonassoc 'c').
|
||||
|
||||
Reduce/reduce conflict on token 'c':
|
||||
12 empty_c2: . %empty
|
||||
13 empty_c3: . %empty
|
||||
Example • 'c'
|
||||
First derivation start ::=[ empty_c2 ::=[ • ] 'c' ]
|
||||
Example • 'c'
|
||||
Second derivation start ::=[ empty_c3 ::=[ • ] 'c' ]
|
||||
|
||||
|
||||
|
||||
State 1
|
||||
]])
|
||||
|
||||
@@ -36,7 +36,7 @@ dnl support is rapidly evolving, let's keep that information to be careful.
|
||||
dnl However, we don't do diffs for canonical LR(1) because the diff is huge.
|
||||
m4_pushdef([AT_LALR1_DIFF_CHECK],
|
||||
[AT_CHECK([[sed 's/^%define lr.type .*$//' input.y > input-lalr.y]])
|
||||
AT_BISON_CHECK([[--report=all input-lalr.y]], [[0]], [ignore], [ignore])
|
||||
AT_BISON_CHECK([[--report=all,no-cex input-lalr.y]], [[0]], [ignore], [ignore])
|
||||
AT_DIFF_U_CHECK([[input-lalr.output input.output]], [$1])])
|
||||
|
||||
AT_TEST_TABLES_AND_PARSE([$2[: LALR(1)]], [[LALR]], [[last-state]],
|
||||
|
||||
@@ -1594,7 +1594,7 @@ yylex (void)
|
||||
|
||||
m4_if(m4_index(m4_quote($3), [no-xml]), -1,
|
||||
[AT_BISON_CHECK],
|
||||
[AT_BISON_CHECK_NO_XML])([[-Wall --report=all --defines -o input.c input.y]],
|
||||
[AT_BISON_CHECK_NO_XML])([[-Wall --report=all,no-cex --defines -o input.c input.y]],
|
||||
[0], [], m4_dquote($7))
|
||||
|
||||
m4_if(m4_index(m4_quote($3), [last-state]), -1,
|
||||
|
||||
Reference in New Issue
Block a user