tests: check reports with conflicts and UTF-8

This is to record the current state of the report, which escapes the
UTF-8 characters (as parse.error="verbose" does), but shouldn't (as
parse.error="detailed" does).

* tests/report.at: here.
This commit is contained in:
Akim Demaille
2020-06-11 18:55:25 +02:00
parent cef13e11f5
commit 5d5e1df1dc

View File

@@ -1138,5 +1138,515 @@ AT_CHECK([[sed -e 's/bison-xml-report version="[^"]*"/bison-xml-report version="
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP
## ------------------------ ##
## Reports with conflicts. ##
## ------------------------ ##
AT_SETUP([Reports with conflicts])
AT_KEYWORDS([report])
AT_BISON_OPTION_PUSHDEFS
AT_DATA([input.y],
[[%left "+"
%%
exp
: exp "⊕" exp
| exp "+" exp
| exp "+" exp
| "number"
| "Ñùṃéℝô"
]])
AT_BISON_CHECK([-o input.cc -rall --graph=input.gv --xml input.y], [], [],
[[input.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr]
input.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr]
input.y: warning: rerun with option '-Wcounterexamples' to generate conflict counterexamples [-Wother]
input.y:6.3-13: warning: rule useless in parser due to conflicts [-Wother]
]])
# Check the contents of the report.
AT_CHECK([cat input.output], [],
[[Rules useless in parser due to conflicts
3 exp: exp "+" exp
State 7 conflicts: 1 shift/reduce, 3 reduce/reduce
State 8 conflicts: 2 shift/reduce
Grammar
0 $accept: exp $end
1 exp: exp "\342\212\225" exp
2 | exp "+" exp
3 | exp "+" exp
4 | "number"
5 | "\303\221\303\271\341\271\203\303\251\342\204\235\303\264"
Terminals, with rules where they appear
$end (0) 0
error (256)
"+" (258) 2 3
"\342\212\225" (259) 1
"number" (260) 4
"\303\221\303\271\341\271\203\303\251\342\204\235\303\264" (261) 5
Nonterminals, with rules where they appear
$accept (7)
on left: 0
exp (8)
on left: 1 2 3 4 5
on right: 0 1 2 3
State 0
0 $accept: . exp $end
1 exp: . exp "\342\212\225" exp
2 | . exp "+" exp
3 | . exp "+" exp
4 | . "number"
5 | . "\303\221\303\271\341\271\203\303\251\342\204\235\303\264"
"number" shift, and go to state 1
"\303\221\303\271\341\271\203\303\251\342\204\235\303\264" shift, and go to state 2
exp go to state 3
State 1
4 exp: "number" .
$default reduce using rule 4 (exp)
State 2
5 exp: "\303\221\303\271\341\271\203\303\251\342\204\235\303\264" .
$default reduce using rule 5 (exp)
State 3
0 $accept: exp . $end
1 exp: exp . "\342\212\225" exp
2 | exp . "+" exp
3 | exp . "+" exp
$end shift, and go to state 4
"+" shift, and go to state 5
"\342\212\225" shift, and go to state 6
State 4
0 $accept: exp $end .
$default accept
State 5
1 exp: . exp "\342\212\225" exp
2 | . exp "+" exp
2 | exp "+" . exp
3 | . exp "+" exp
3 | exp "+" . exp
4 | . "number"
5 | . "\303\221\303\271\341\271\203\303\251\342\204\235\303\264"
"number" shift, and go to state 1
"\303\221\303\271\341\271\203\303\251\342\204\235\303\264" shift, and go to state 2
exp go to state 7
State 6
1 exp: . exp "\342\212\225" exp
1 | exp "\342\212\225" . exp
2 | . exp "+" exp
3 | . exp "+" exp
4 | . "number"
5 | . "\303\221\303\271\341\271\203\303\251\342\204\235\303\264"
"number" shift, and go to state 1
"\303\221\303\271\341\271\203\303\251\342\204\235\303\264" shift, and go to state 2
exp go to state 8
State 7
1 exp: exp . "\342\212\225" exp
2 | exp . "+" exp
2 | exp "+" exp . [$end, "+", "\342\212\225"]
3 | exp . "+" exp
3 | exp "+" exp . [$end, "+", "\342\212\225"]
"\342\212\225" shift, and go to state 6
$end reduce using rule 2 (exp)
$end [reduce using rule 3 (exp)]
"+" reduce using rule 2 (exp)
"+" [reduce using rule 3 (exp)]
"\342\212\225" [reduce using rule 2 (exp)]
"\342\212\225" [reduce using rule 3 (exp)]
$default reduce using rule 2 (exp)
Conflict between rule 2 and token "+" resolved as reduce (%left "+").
State 8
1 exp: exp . "\342\212\225" exp
1 | exp "\342\212\225" exp . [$end, "+", "\342\212\225"]
2 | exp . "+" exp
3 | exp . "+" exp
"+" shift, and go to state 5
"\342\212\225" shift, and go to state 6
"+" [reduce using rule 1 (exp)]
"\342\212\225" [reduce using rule 1 (exp)]
$default reduce using rule 1 (exp)
]])
AT_CHECK([sed -e '1s/GNU Bison .*\.$/GNU Bison VERSION./' input.gv], [],
[[// Generated by GNU Bison VERSION.
// Report bugs to <bug-bison@gnu.org>.
// Home page: <https://www.gnu.org/software/bison/>.
digraph "input.y"
{
node [fontname = courier, shape = box, colorscheme = paired6]
edge [fontname = courier]
0 [label="State 0\n\l 0 $accept: . exp $end\l 1 exp: . exp \"\\342\\212\\225\" exp\l 2 | . exp \"+\" exp\l 3 | . exp \"+\" exp\l 4 | . \"number\"\l 5 | . \"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\"\l"]
0 -> 1 [style=solid label="\"number\""]
0 -> 2 [style=solid label="\"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\""]
0 -> 3 [style=dashed label="exp"]
1 [label="State 1\n\l 4 exp: \"number\" .\l"]
1 -> "1R4" [style=solid]
"1R4" [label="R4", fillcolor=3, shape=diamond, style=filled]
2 [label="State 2\n\l 5 exp: \"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\" .\l"]
2 -> "2R5" [style=solid]
"2R5" [label="R5", fillcolor=3, shape=diamond, style=filled]
3 [label="State 3\n\l 0 $accept: exp . $end\l 1 exp: exp . \"\\342\\212\\225\" exp\l 2 | exp . \"+\" exp\l 3 | exp . \"+\" exp\l"]
3 -> 4 [style=solid label="$end"]
3 -> 5 [style=solid label="\"+\""]
3 -> 6 [style=solid label="\"\\342\\212\\225\""]
4 [label="State 4\n\l 0 $accept: exp $end .\l"]
4 -> "4R0" [style=solid]
"4R0" [label="Acc", fillcolor=1, shape=diamond, style=filled]
5 [label="State 5\n\l 1 exp: . exp \"\\342\\212\\225\" exp\l 2 | . exp \"+\" exp\l 2 | exp \"+\" . exp\l 3 | . exp \"+\" exp\l 3 | exp \"+\" . exp\l 4 | . \"number\"\l 5 | . \"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\"\l"]
5 -> 1 [style=solid label="\"number\""]
5 -> 2 [style=solid label="\"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\""]
5 -> 7 [style=dashed label="exp"]
6 [label="State 6\n\l 1 exp: . exp \"\\342\\212\\225\" exp\l 1 | exp \"\\342\\212\\225\" . exp\l 2 | . exp \"+\" exp\l 3 | . exp \"+\" exp\l 4 | . \"number\"\l 5 | . \"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\"\l"]
6 -> 1 [style=solid label="\"number\""]
6 -> 2 [style=solid label="\"\\303\\221\\303\\271\\341\\271\\203\\303\\251\\342\\204\\235\\303\\264\""]
6 -> 8 [style=dashed label="exp"]
7 [label="State 7\n\l 1 exp: exp . \"\\342\\212\\225\" exp\l 2 | exp . \"+\" exp\l 2 | exp \"+\" exp . [$end, \"+\", \"\\342\\212\\225\"]\l 3 | exp . \"+\" exp\l 3 | exp \"+\" exp . [$end, \"+\", \"\\342\\212\\225\"]\l"]
7 -> 6 [style=solid label="\"\\342\\212\\225\""]
7 -> "7R2d" [label="[\"\\342\\212\\225\"]", style=solid]
"7R2d" [label="R2", fillcolor=5, shape=diamond, style=filled]
7 -> "7R2" [style=solid]
"7R2" [label="R2", fillcolor=3, shape=diamond, style=filled]
7 -> "7R3d" [label="[$end, \"+\", \"\\342\\212\\225\"]", style=solid]
"7R3d" [label="R3", fillcolor=5, shape=diamond, style=filled]
8 [label="State 8\n\l 1 exp: exp . \"\\342\\212\\225\" exp\l 1 | exp \"\\342\\212\\225\" exp . [$end, \"+\", \"\\342\\212\\225\"]\l 2 | exp . \"+\" exp\l 3 | exp . \"+\" exp\l"]
8 -> 5 [style=solid label="\"+\""]
8 -> 6 [style=solid label="\"\\342\\212\\225\""]
8 -> "8R1d" [label="[\"+\", \"\\342\\212\\225\"]", style=solid]
"8R1d" [label="R1", fillcolor=5, shape=diamond, style=filled]
8 -> "8R1" [style=solid]
"8R1" [label="R1", fillcolor=3, shape=diamond, style=filled]
}
]])
AT_CHECK([[sed -e 's/bison-xml-report version="[^"]*"/bison-xml-report version="VERSION"/g' input.xml]], [],
[[<?xml version="1.0"?>
<bison-xml-report version="VERSION" bug-report="bug-bison@gnu.org" url="https://www.gnu.org/software/bison/">
<filename>input.y</filename>
<grammar>
<rules>
<rule number="0" usefulness="useful">
<lhs>$accept</lhs>
<rhs>
<symbol>exp</symbol>
<symbol>$end</symbol>
</rhs>
</rule>
<rule number="1" usefulness="useful">
<lhs>exp</lhs>
<rhs>
<symbol>exp</symbol>
<symbol>&quot;\342\212\225&quot;</symbol>
<symbol>exp</symbol>
</rhs>
</rule>
<rule number="2" usefulness="useful">
<lhs>exp</lhs>
<rhs>
<symbol>exp</symbol>
<symbol>&quot;+&quot;</symbol>
<symbol>exp</symbol>
</rhs>
</rule>
<rule number="3" usefulness="useless-in-parser">
<lhs>exp</lhs>
<rhs>
<symbol>exp</symbol>
<symbol>&quot;+&quot;</symbol>
<symbol>exp</symbol>
</rhs>
</rule>
<rule number="4" usefulness="useful">
<lhs>exp</lhs>
<rhs>
<symbol>&quot;number&quot;</symbol>
</rhs>
</rule>
<rule number="5" usefulness="useful">
<lhs>exp</lhs>
<rhs>
<symbol>&quot;\303\221\303\271\341\271\203\303\251\342\204\235\303\264&quot;</symbol>
</rhs>
</rule>
</rules>
<terminals>
<terminal symbol-number="0" token-number="0" name="$end" usefulness="useful"/>
<terminal symbol-number="1" token-number="256" name="error" usefulness="useful"/>
<terminal symbol-number="3" token-number="258" name="&quot;+&quot;" usefulness="useful" prec="1" assoc="left"/>
<terminal symbol-number="4" token-number="259" name="&quot;\342\212\225&quot;" usefulness="useful"/>
<terminal symbol-number="5" token-number="260" name="&quot;number&quot;" usefulness="useful"/>
<terminal symbol-number="6" token-number="261" name="&quot;\303\221\303\271\341\271\203\303\251\342\204\235\303\264&quot;" usefulness="useful"/>
</terminals>
<nonterminals>
<nonterminal symbol-number="7" name="$accept" usefulness="useful"/>
<nonterminal symbol-number="8" name="exp" usefulness="useful"/>
</nonterminals>
</grammar>
<automaton>
<state number="0">
<itemset>
<item rule-number="0" point="0"/>
<item rule-number="1" point="0"/>
<item rule-number="2" point="0"/>
<item rule-number="3" point="0"/>
<item rule-number="4" point="0"/>
<item rule-number="5" point="0"/>
</itemset>
<actions>
<transitions>
<transition type="shift" symbol="&quot;number&quot;" state="1"/>
<transition type="shift" symbol="&quot;\303\221\303\271\341\271\203\303\251\342\204\235\303\264&quot;" state="2"/>
<transition type="goto" symbol="exp" state="3"/>
</transitions>
<errors/>
<reductions/>
</actions>
<solved-conflicts/>
</state>
<state number="1">
<itemset>
<item rule-number="4" point="1"/>
</itemset>
<actions>
<transitions/>
<errors/>
<reductions>
<reduction symbol="$default" rule="4" enabled="true"/>
</reductions>
</actions>
<solved-conflicts/>
</state>
<state number="2">
<itemset>
<item rule-number="5" point="1"/>
</itemset>
<actions>
<transitions/>
<errors/>
<reductions>
<reduction symbol="$default" rule="5" enabled="true"/>
</reductions>
</actions>
<solved-conflicts/>
</state>
<state number="3">
<itemset>
<item rule-number="0" point="1"/>
<item rule-number="1" point="1"/>
<item rule-number="2" point="1"/>
<item rule-number="3" point="1"/>
</itemset>
<actions>
<transitions>
<transition type="shift" symbol="$end" state="4"/>
<transition type="shift" symbol="&quot;+&quot;" state="5"/>
<transition type="shift" symbol="&quot;\342\212\225&quot;" state="6"/>
</transitions>
<errors/>
<reductions/>
</actions>
<solved-conflicts/>
</state>
<state number="4">
<itemset>
<item rule-number="0" point="2"/>
</itemset>
<actions>
<transitions/>
<errors/>
<reductions>
<reduction symbol="$default" rule="accept" enabled="true"/>
</reductions>
</actions>
<solved-conflicts/>
</state>
<state number="5">
<itemset>
<item rule-number="1" point="0"/>
<item rule-number="2" point="0"/>
<item rule-number="2" point="2"/>
<item rule-number="3" point="0"/>
<item rule-number="3" point="2"/>
<item rule-number="4" point="0"/>
<item rule-number="5" point="0"/>
</itemset>
<actions>
<transitions>
<transition type="shift" symbol="&quot;number&quot;" state="1"/>
<transition type="shift" symbol="&quot;\303\221\303\271\341\271\203\303\251\342\204\235\303\264&quot;" state="2"/>
<transition type="goto" symbol="exp" state="7"/>
</transitions>
<errors/>
<reductions/>
</actions>
<solved-conflicts/>
</state>
<state number="6">
<itemset>
<item rule-number="1" point="0"/>
<item rule-number="1" point="2"/>
<item rule-number="2" point="0"/>
<item rule-number="3" point="0"/>
<item rule-number="4" point="0"/>
<item rule-number="5" point="0"/>
</itemset>
<actions>
<transitions>
<transition type="shift" symbol="&quot;number&quot;" state="1"/>
<transition type="shift" symbol="&quot;\303\221\303\271\341\271\203\303\251\342\204\235\303\264&quot;" state="2"/>
<transition type="goto" symbol="exp" state="8"/>
</transitions>
<errors/>
<reductions/>
</actions>
<solved-conflicts/>
</state>
<state number="7">
<itemset>
<item rule-number="1" point="1"/>
<item rule-number="2" point="1"/>
<item rule-number="2" point="3">
<lookaheads>
<symbol>$end</symbol>
<symbol>&quot;+&quot;</symbol>
<symbol>&quot;\342\212\225&quot;</symbol>
</lookaheads>
</item>
<item rule-number="3" point="1"/>
<item rule-number="3" point="3">
<lookaheads>
<symbol>$end</symbol>
<symbol>&quot;+&quot;</symbol>
<symbol>&quot;\342\212\225&quot;</symbol>
</lookaheads>
</item>
</itemset>
<actions>
<transitions>
<transition type="shift" symbol="&quot;\342\212\225&quot;" state="6"/>
</transitions>
<errors/>
<reductions>
<reduction symbol="$end" rule="2" enabled="true"/>
<reduction symbol="$end" rule="3" enabled="false"/>
<reduction symbol="&quot;+&quot;" rule="2" enabled="true"/>
<reduction symbol="&quot;+&quot;" rule="3" enabled="false"/>
<reduction symbol="&quot;\342\212\225&quot;" rule="2" enabled="false"/>
<reduction symbol="&quot;\342\212\225&quot;" rule="3" enabled="false"/>
<reduction symbol="$default" rule="2" enabled="true"/>
</reductions>
</actions>
<solved-conflicts>
<resolution rule="2" symbol="&quot;+&quot;" type="reduce">%left &quot;+&quot;</resolution>
</solved-conflicts>
</state>
<state number="8">
<itemset>
<item rule-number="1" point="1"/>
<item rule-number="1" point="3">
<lookaheads>
<symbol>$end</symbol>
<symbol>&quot;+&quot;</symbol>
<symbol>&quot;\342\212\225&quot;</symbol>
</lookaheads>
</item>
<item rule-number="2" point="1"/>
<item rule-number="3" point="1"/>
</itemset>
<actions>
<transitions>
<transition type="shift" symbol="&quot;+&quot;" state="5"/>
<transition type="shift" symbol="&quot;\342\212\225&quot;" state="6"/>
</transitions>
<errors/>
<reductions>
<reduction symbol="&quot;+&quot;" rule="1" enabled="false"/>
<reduction symbol="&quot;\342\212\225&quot;" rule="1" enabled="false"/>
<reduction symbol="$default" rule="1" enabled="true"/>
</reductions>
</actions>
<solved-conflicts/>
</state>
</automaton>
</bison-xml-report>
]])
AT_BISON_OPTION_POPDEFS
AT_CLEANUP