cex: indent the diagnostics to highlight the structure

Instead of

    Shift/reduce conflict on token D:
    Example              A a • D
    First derivation     s ::=[ A a a ::=[ b ::=[ c ::=[ • ] ] ] d ::=[ D ] ]
    Example              A a • D
    Second derivation    s ::=[ A a d ::=[ • D ] ]

display

    Shift/reduce conflict on token D:
      Example              A a • D
      First derivation     s ::=[ A a a ::=[ b ::=[ c ::=[ • ] ] ] d ::=[ D ] ]
      Example              A a • D
      Second derivation    s ::=[ A a d ::=[ • D ] ]

* src/counterexample.c (print_counterexample): Indent.
* tests/counterexample.at: Adjust.
This commit is contained in:
Akim Demaille
2020-06-13 19:18:12 +02:00
parent 22f62414f9
commit 35c0fe6789
2 changed files with 104 additions and 104 deletions

View File

@@ -102,14 +102,14 @@ free_counterexample (counterexample *cex)
static void static void
print_counterexample (counterexample *cex, FILE *out) print_counterexample (counterexample *cex, FILE *out)
{ {
fprintf (out, "%-20s ", cex->unifying ? _("Example") : _("First example")); fprintf (out, " %-20s ", cex->unifying ? _("Example") : _("First example"));
derivation_print_leaves (cex->d1, out); derivation_print_leaves (cex->d1, out);
fprintf (out, "%-20s ", _("First derivation")); fprintf (out, " %-20s ", _("First derivation"));
derivation_print (cex->d1, out); derivation_print (cex->d1, out);
fprintf (out, "%-20s ", cex->unifying ? _("Example") : _("Second example")); fprintf (out, " %-20s ", cex->unifying ? _("Example") : _("Second example"));
derivation_print_leaves (cex->d2, out); derivation_print_leaves (cex->d2, out);
fprintf (out, "%-20s ", _("Second derivation")); fprintf (out, " %-20s ", _("Second derivation"));
derivation_print (cex->d2, out); derivation_print (cex->d2, out);
fputc ('\n', out); fputc ('\n', out);

View File

@@ -46,10 +46,10 @@ y: A | A B;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token B: Shift/reduce conflict on token B:
Example A • B C Example A • B C
First derivation s ::=[ a ::=[ A • ] x ::=[ B C ] ] First derivation s ::=[ a ::=[ A • ] x ::=[ B C ] ]
Example A • B C Example A • B C
Second derivation s ::=[ y ::=[ A • B ] c ::=[ C ] ] Second derivation s ::=[ y ::=[ A • B ] c ::=[ C ] ]
input.y:4.4: warning: rule useless in parser due to conflicts [-Wother] input.y:4.4: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -76,10 +76,10 @@ bc: B bc C | B C;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token B: Shift/reduce conflict on token B:
Example A • B C Example A • B C
First derivation s ::=[ a ::=[ A • ] bc ::=[ B C ] ] First derivation s ::=[ a ::=[ A • ] bc ::=[ B C ] ]
Example A • B C Example A • B C
Second derivation s ::=[ ac ::=[ A ac ::=[ b ::=[ • B ] ] C ] ] Second derivation s ::=[ ac ::=[ A ac ::=[ b ::=[ • B ] ] C ] ]
input.y:6.4: warning: rule useless in parser due to conflicts [-Wother] input.y:6.4: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -107,16 +107,16 @@ xby: B | X xby Y;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] [[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
Shift/reduce conflict on token B: Shift/reduce conflict on token B:
Example A • B y Example A • B y
First derivation s ::=[ ax ::=[ A x ::=[ • ] ] by ::=[ B y ] ] First derivation s ::=[ ax ::=[ A x ::=[ • ] ] by ::=[ B y ] ]
Example A • B Example A • B
Second derivation s ::=[ A xby ::=[ • B ] ] Second derivation s ::=[ A xby ::=[ • B ] ]
Shift/reduce conflict on token B: Shift/reduce conflict on token B:
First example A X • B y $end First example A X • B y $end
First derivation $accept ::=[ s ::=[ ax ::=[ A x ::=[ X x ::=[ • ] ] ] by ::=[ B y ] ] $end ] First derivation $accept ::=[ s ::=[ ax ::=[ A x ::=[ X x ::=[ • ] ] ] by ::=[ B y ] ] $end ]
Second example A X • B Y $end Second example A X • B Y $end
Second derivation $accept ::=[ s ::=[ A xby ::=[ X xby ::=[ • B ] Y ] ] $end ] Second derivation $accept ::=[ s ::=[ A xby ::=[ X xby ::=[ • B ] Y ] ] $end ]
input.y:5.4-9: warning: rule useless in parser due to conflicts [-Wother] input.y:5.4-9: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -144,10 +144,10 @@ bc: B C;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token C: Shift/reduce conflict on token C:
First example B • C D $end First example B • C D $end
First derivation $accept ::=[ g ::=[ x ::=[ b ::=[ B • ] cd ::=[ C D ] ] ] $end ] First derivation $accept ::=[ g ::=[ x ::=[ b ::=[ B • ] cd ::=[ C D ] ] ] $end ]
Second example B • C $end Second example B • C $end
Second derivation $accept ::=[ g ::=[ x ::=[ bc ::=[ B • C ] ] ] $end ] Second derivation $accept ::=[ g ::=[ x ::=[ bc ::=[ B • C ] ] ] $end ]
input.y:6.4: warning: rule useless in parser due to conflicts [-Wother] input.y:6.4: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -173,10 +173,10 @@ y: A A B;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token A: Shift/reduce conflict on token A:
First example A • A $end First example A • A $end
First derivation $accept ::=[ s ::=[ s ::=[ t ::=[ x ::=[ A • ] ] ] t ::=[ x ::=[ A ] ] ] $end ] First derivation $accept ::=[ s ::=[ s ::=[ t ::=[ x ::=[ A • ] ] ] t ::=[ x ::=[ A ] ] ] $end ]
Second example A • A B $end Second example A • A B $end
Second derivation $accept ::=[ s ::=[ t ::=[ y ::=[ A • A B ] ] ] $end ] Second derivation $accept ::=[ s ::=[ t ::=[ y ::=[ A • A B ] ] ] $end ]
]]) ]])
@@ -206,16 +206,16 @@ y: Y;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] [[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr]
Shift/reduce conflict on token A: Shift/reduce conflict on token A:
Example b • A X X Y Example b • A X X Y
First derivation a ::=[ r ::=[ b • ] t ::=[ A x ::=[ X ] xy ::=[ X Y ] ] ] First derivation a ::=[ r ::=[ b • ] t ::=[ A x ::=[ X ] xy ::=[ X Y ] ] ]
Example b • A X X Y Example b • A X X Y
Second derivation a ::=[ s ::=[ b • xx ::=[ A X X ] y ::=[ Y ] ] ] Second derivation a ::=[ s ::=[ b • xx ::=[ A X X ] y ::=[ Y ] ] ]
Shift/reduce conflict on token X: Shift/reduce conflict on token X:
First example X • X xy First example X • X xy
First derivation a ::=[ x ::=[ X • ] t ::=[ X xy ] ] First derivation a ::=[ x ::=[ X • ] t ::=[ X xy ] ]
Second example A X • X Second example A X • X
Second derivation a ::=[ t ::=[ A xx ::=[ X • X ] ] ] Second derivation a ::=[ t ::=[ A xx ::=[ X • X ] ] ]
input.y:4.4: warning: rule useless in parser due to conflicts [-Wother] input.y:4.4: warning: rule useless in parser due to conflicts [-Wother]
input.y:8.4: warning: rule useless in parser due to conflicts [-Wother] input.y:8.4: warning: rule useless in parser due to conflicts [-Wother]
@@ -240,10 +240,10 @@ b : A | b;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] [[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]
Reduce/reduce conflict on token $end: Reduce/reduce conflict on token $end:
Example A b • Example A b •
First derivation a ::=[ A b • ] First derivation a ::=[ A b • ]
Example A b • Example A b •
Second derivation a ::=[ A b ::=[ b • ] ] Second derivation a ::=[ A b ::=[ b • ] ]
input.y:4.9: warning: rule useless in parser due to conflicts [-Wother] input.y:4.9: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -268,10 +268,10 @@ b: D;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] [[input.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr]
Reduce/reduce conflict on tokens A, C: Reduce/reduce conflict on tokens A, C:
First example D • A $end First example D • A $end
First derivation $accept ::=[ s ::=[ a ::=[ D • ] A ] $end ] First derivation $accept ::=[ s ::=[ a ::=[ D • ] A ] $end ]
Second example B D • A $end Second example B D • A $end
Second derivation $accept ::=[ s ::=[ B b ::=[ D • ] A ] $end ] Second derivation $accept ::=[ s ::=[ B b ::=[ D • ] A ] $end ]
input.y:5.4: warning: rule useless in parser due to conflicts [-Wother] input.y:5.4: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -297,10 +297,10 @@ AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token J: Shift/reduce conflict on token J:
time limit exceeded: XXX time limit exceeded: XXX
First example H i • J $end First example H i • J $end
First derivation $accept ::=[ s ::=[ a ::=[ H i • ] J ] $end ] First derivation $accept ::=[ s ::=[ a ::=[ H i • ] J ] $end ]
Second example H i • J K $end Second example H i • J K $end
Second derivation $accept ::=[ a ::=[ H i ::=[ i • J K ] ] $end ] Second derivation $accept ::=[ a ::=[ H i ::=[ i • J K ] ] $end ]
input.y:4.4-6: warning: rule useless in parser due to conflicts [-Wother] input.y:4.4-6: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -329,10 +329,10 @@ b: A B C | A B D;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token B: Shift/reduce conflict on token B:
Example N A • B C Example N A • B C
First derivation s ::=[ n ::=[ N a ::=[ A • ] B ] C ] First derivation s ::=[ n ::=[ N a ::=[ A • ] B ] C ]
Example N A • B C Example N A • B C
Second derivation s ::=[ n ::=[ N b ::=[ A • B C ] ] ] Second derivation s ::=[ n ::=[ N b ::=[ A • B C ] ] ]
input.y:5.4: warning: rule useless in parser due to conflicts [-Wother] input.y:5.4: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -362,16 +362,16 @@ C : A c A;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 4 reduce/reduce conflicts [-Wconflicts-rr] [[input.y: warning: 4 reduce/reduce conflicts [-Wconflicts-rr]
Reduce/reduce conflict on tokens b, c: Reduce/reduce conflict on tokens b, c:
Example B • b A A c A Example B • b A A c A
First derivation S ::=[ B ::=[ A ::=[ B • ] b A ] C ::=[ A c A ] ] First derivation S ::=[ B ::=[ A ::=[ B • ] b A ] C ::=[ A c A ] ]
Example B • b A c A Example B • b A c A
Second derivation S ::=[ B C ::=[ A ::=[ B ::=[ A ::=[ • ] b A ] ] c A ] ] Second derivation S ::=[ B C ::=[ A ::=[ B ::=[ A ::=[ • ] b A ] ] c A ] ]
Reduce/reduce conflict on tokens b, c: Reduce/reduce conflict on tokens b, c:
Example C • c A A b A Example C • c A A b A
First derivation S ::=[ C ::=[ A ::=[ C • ] c A ] B ::=[ A b A ] ] First derivation S ::=[ C ::=[ A ::=[ C • ] c A ] B ::=[ A b A ] ]
Example C • c A b A Example C • c A b A
Second derivation S ::=[ C B ::=[ A ::=[ C ::=[ A ::=[ • ] c A ] ] b A ] ] Second derivation S ::=[ C B ::=[ A ::=[ C ::=[ A ::=[ • ] c A ] ] b A ] ]
]]) ]])
@@ -397,55 +397,55 @@ AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
input.y: warning: 6 reduce/reduce conflicts [-Wconflicts-rr] input.y: warning: 6 reduce/reduce conflicts [-Wconflicts-rr]
Reduce/reduce conflict on token A: Reduce/reduce conflict on token A:
First example • c A A $end First example • c A A $end
First derivation $accept ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] $end ] First derivation $accept ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] $end ]
Second example • c A A $end Second example • c A A $end
Second derivation $accept ::=[ a ::=[ c ::=[ • ] d ::=[ c A A ] ] $end ] Second derivation $accept ::=[ a ::=[ c ::=[ • ] d ::=[ c A A ] ] $end ]
Reduce/reduce conflict on token A: Reduce/reduce conflict on token A:
time limit exceeded: XXX time limit exceeded: XXX
First example b • c A A $end First example b • c A A $end
First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] $end ] First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] $end ]
Second example b • A $end Second example b • A $end
Second derivation $accept ::=[ a ::=[ b d ::=[ c ::=[ • ] A ] ] $end ] Second derivation $accept ::=[ a ::=[ b d ::=[ c ::=[ • ] A ] ] $end ]
Reduce/reduce conflict on token A: Reduce/reduce conflict on token A:
time limit exceeded: XXX time limit exceeded: XXX
First example c • c A A $end First example c • c A A $end
First derivation $accept ::=[ a ::=[ c d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] $end ] First derivation $accept ::=[ a ::=[ c d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] $end ]
Second example c • A $end Second example c • A $end
Second derivation $accept ::=[ a ::=[ c d ::=[ c ::=[ • ] A ] ] $end ] Second derivation $accept ::=[ a ::=[ c d ::=[ c ::=[ • ] A ] ] $end ]
Shift/reduce conflict on token A: Shift/reduce conflict on token A:
time limit exceeded: XXX time limit exceeded: XXX
First example b c • c A A $end First example b c • c A A $end
First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] ] ] $end ] First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] ] ] $end ]
Second example b c • A Second example b c • A
Second derivation a ::=[ b d ::=[ c • A ] ] Second derivation a ::=[ b d ::=[ c • A ] ]
Reduce/reduce conflict on token A: Reduce/reduce conflict on token A:
First example b c • c A A $end First example b c • c A A $end
First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] ] ] $end ] First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ a ::=[ b ::=[ • ] d ::=[ c A A ] ] ] ] ] ] $end ]
Second example b c • A $end Second example b c • A $end
Second derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ c ::=[ • ] A ] ] ] ] $end ] Second derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ c ::=[ • ] A ] ] ] ] $end ]
Shift/reduce conflict on token A: Shift/reduce conflict on token A:
First example b c • A $end First example b c • A $end
First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ c ::=[ • ] A ] ] ] ] $end ] First derivation $accept ::=[ a ::=[ b d ::=[ a ::=[ c d ::=[ c ::=[ • ] A ] ] ] ] $end ]
Second example b c • A Second example b c • A
Second derivation a ::=[ b d ::=[ c • A ] ] Second derivation a ::=[ b d ::=[ c • A ] ]
Reduce/reduce conflict on token $end: Reduce/reduce conflict on token $end:
Example b d • Example b d •
First derivation a ::=[ b d • ] First derivation a ::=[ b d • ]
Example b d • Example b d •
Second derivation a ::=[ b d ::=[ d • ] ] Second derivation a ::=[ b d ::=[ d • ] ]
Reduce/reduce conflict on token $end: Reduce/reduce conflict on token $end:
Example c d • Example c d •
First derivation a ::=[ c d • ] First derivation a ::=[ c d • ]
Example c d • Example c d •
Second derivation a ::=[ c d ::=[ d • ] ] Second derivation a ::=[ c d ::=[ d • ] ]
input.y:5.4: warning: rule useless in parser due to conflicts [-Wother] input.y:5.4: warning: rule useless in parser due to conflicts [-Wother]
input.y:6.15: warning: rule useless in parser due to conflicts [-Wother] input.y:6.15: warning: rule useless in parser due to conflicts [-Wother]
@@ -474,10 +474,10 @@ i: %empty | i J;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token J: Shift/reduce conflict on token J:
Example H i J • J J Example H i J • J J
First derivation s ::=[ a ::=[ H i ::=[ i J • ] J J ] ] First derivation s ::=[ a ::=[ H i ::=[ i J • ] J J ] ]
Example H i J • J J Example H i J • J J
Second derivation s ::=[ a ::=[ H i J • J ] J ] Second derivation s ::=[ a ::=[ H i J • J ] J ]
input.y:5.13-15: warning: rule useless in parser due to conflicts [-Wother] input.y:5.13-15: warning: rule useless in parser due to conflicts [-Wother]
]]) ]])
@@ -507,10 +507,10 @@ d: D;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token D: Shift/reduce conflict on token D:
Example A a • D Example A a • D
First derivation s ::=[ A a a ::=[ b ::=[ c ::=[ • ] ] ] d ::=[ D ] ] First derivation s ::=[ A a a ::=[ b ::=[ c ::=[ • ] ] ] d ::=[ D ] ]
Example A a • D Example A a • D
Second derivation s ::=[ A a d ::=[ • D ] ] Second derivation s ::=[ A a d ::=[ • D ] ]
]]) ]])
@@ -538,10 +538,10 @@ d: D;
AT_BISON_CHECK_CEX([input.y], [], [], AT_BISON_CHECK_CEX([input.y], [], [],
[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] [[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr]
Shift/reduce conflict on token D: Shift/reduce conflict on token D:
First example A a • D E $end First example A a • D E $end
First derivation $accept ::=[ s ::=[ A a a ::=[ b ::=[ c ::=[ • ] ] ] d ::=[ D ] E ] $end ] First derivation $accept ::=[ s ::=[ A a a ::=[ b ::=[ c ::=[ • ] ] ] d ::=[ D ] E ] $end ]
Second example A a • D $end Second example A a • D $end
Second derivation $accept ::=[ s ::=[ A a d ::=[ • D ] ] $end ] Second derivation $accept ::=[ s ::=[ A a d ::=[ • D ] ] $end ]
]]) ]])