From 5d5e1df1dcb3ea64f1599bc339dcb8b48add68df Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 11 Jun 2020 18:55:25 +0200 Subject: [PATCH] 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. --- tests/report.at | 510 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 510 insertions(+) diff --git a/tests/report.at b/tests/report.at index 8d5ceafc..9ba6f664 100644 --- a/tests/report.at +++ b/tests/report.at @@ -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 . +// Home page: . + +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]], [], +[[ + + + + input.y + + + + + $accept + + exp + $end + + + + exp + + exp + "\342\212\225" + exp + + + + exp + + exp + "+" + exp + + + + exp + + exp + "+" + exp + + + + exp + + "number" + + + + exp + + "\303\221\303\271\341\271\203\303\251\342\204\235\303\264" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $end + "+" + "\342\212\225" + + + + + + $end + "+" + "\342\212\225" + + + + + + + + + + + + + + + + + + + + %left "+" + + + + + + + + + $end + "+" + "\342\212\225" + + + + + + + + + + + + + + + + + + + + + +]]) + + AT_BISON_OPTION_POPDEFS AT_CLEANUP