# Bison Reports. -*- Autotest -*- # Copyright (C) 2018-2021 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . AT_BANNER([[Test reports.]]) ## --------- ## ## Reports. ## ## --------- ## AT_SETUP([Reports]) AT_KEYWORDS([report]) AT_BISON_OPTION_PUSHDEFS AT_DATA([input.yy], [[%token END 0 "end of file" ASSIGN ":=" INCR "incr" ; %token IDENTIFIER "identifier" %type id %token NUMBER "number" %type exp %% %start unit; unit: assignments exp { driver.result = $2; }; assignments: %empty {} | assignments assignment {}; assignment: id ":=" exp { driver.variables[$id] = $exp; }; id: "identifier"; exp: "incr" exp { $$ = 1; } { $$ = 10; } exp { $$ = $2 + $3 + $4 + $5; } | "(" exp ")" { std::swap ($$, $2); } | "identifier" { $$ = driver.variables[$1]; } | "number" { std::swap ($$, $1); }; ]]) AT_SKIP_IF([[test x"$XSLTPROC" = x]]) AT_BISON_CHECK([-o input.cc -v --graph=input.gv --html --xml input.yy]) # Check the contents of the report. AT_CHECK([cat input.output], [], [[Grammar 0 $accept: unit "end of file" 1 unit: assignments exp 2 assignments: %empty 3 | assignments assignment 4 assignment: id ":=" exp 5 id: "identifier" 6 @1: %empty 7 @2: %empty 8 exp: "incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number" Terminals, with rules where they appear "end of file" (0) 0 error (256) ":=" (258) 4 "incr" (259) 8 "identifier" (260) 5 10 "number" (261) 11 "(" (262) 9 ")" (263) 9 Nonterminals, with rules where they appear $accept (9) on left: 0 unit (10) on left: 1 on right: 0 assignments (11) on left: 2 3 on right: 1 3 assignment (12) on left: 4 on right: 3 id (13) on left: 5 on right: 4 exp (14) on left: 8 9 10 11 on right: 1 4 8 9 @1 (15) on left: 6 on right: 8 @2 (16) on left: 7 on right: 8 State 0 0 $accept: . unit "end of file" $default reduce using rule 2 (assignments) unit go to state 1 assignments go to state 2 State 1 0 $accept: unit . "end of file" "end of file" shift, and go to state 3 State 2 1 unit: assignments . exp 3 assignments: assignments . assignment "incr" shift, and go to state 4 "identifier" shift, and go to state 5 "number" shift, and go to state 6 "(" shift, and go to state 7 assignment go to state 8 id go to state 9 exp go to state 10 State 3 0 $accept: unit "end of file" . $default accept State 4 8 exp: "incr" . exp @1 @2 exp "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 12 State 5 5 id: "identifier" . 10 exp: "identifier" . "end of file" reduce using rule 10 (exp) $default reduce using rule 5 (id) State 6 11 exp: "number" . $default reduce using rule 11 (exp) State 7 9 exp: "(" . exp ")" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 13 State 8 3 assignments: assignments assignment . $default reduce using rule 3 (assignments) State 9 4 assignment: id . ":=" exp ":=" shift, and go to state 14 State 10 1 unit: assignments exp . $default reduce using rule 1 (unit) State 11 10 exp: "identifier" . $default reduce using rule 10 (exp) State 12 8 exp: "incr" exp . @1 @2 exp $default reduce using rule 6 (@1) @1 go to state 15 State 13 9 exp: "(" exp . ")" ")" shift, and go to state 16 State 14 4 assignment: id ":=" . exp "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 17 State 15 8 exp: "incr" exp @1 . @2 exp $default reduce using rule 7 (@2) @2 go to state 18 State 16 9 exp: "(" exp ")" . $default reduce using rule 9 (exp) State 17 4 assignment: id ":=" exp . $default reduce using rule 4 (assignment) State 18 8 exp: "incr" exp @1 @2 . exp "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 19 State 19 8 exp: "incr" exp @1 @2 exp . $default reduce using rule 8 (exp) ]]) # Now generate verbose reports. AT_SKIP_IF([[test x"$XSLTPROC" = x]]) AT_BISON_CHECK([-o input.cc -rall --graph=input.gv --html --xml input.yy]) # Check the contents of the report. AT_CHECK([cat input.output], [], [[Grammar 0 $accept: unit "end of file" 1 unit: assignments exp 2 assignments: %empty 3 | assignments assignment 4 assignment: id ":=" exp 5 id: "identifier" 6 @1: %empty 7 @2: %empty 8 exp: "incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number" Terminals, with rules where they appear "end of file" (0) 0 error (256) ":=" (258) 4 "incr" (259) 8 "identifier" (260) 5 10 "number" (261) 11 "(" (262) 9 ")" (263) 9 Nonterminals, with rules where they appear $accept (9) on left: 0 unit (10) on left: 1 on right: 0 assignments (11) on left: 2 3 on right: 1 3 assignment (12) on left: 4 on right: 3 id (13) on left: 5 on right: 4 exp (14) on left: 8 9 10 11 on right: 1 4 8 9 @1 (15) on left: 6 on right: 8 @2 (16) on left: 7 on right: 8 State 0 0 $accept: . unit "end of file" 1 unit: . assignments exp 2 assignments: %empty . 3 | . assignments assignment $default reduce using rule 2 (assignments) unit go to state 1 assignments go to state 2 State 1 0 $accept: unit . "end of file" "end of file" shift, and go to state 3 State 2 1 unit: assignments . exp 3 assignments: assignments . assignment 4 assignment: . id ":=" exp 5 id: . "identifier" 8 exp: . "incr" exp @1 @2 exp 9 | . "(" exp ")" 10 | . "identifier" 11 | . "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 5 "number" shift, and go to state 6 "(" shift, and go to state 7 assignment go to state 8 id go to state 9 exp go to state 10 State 3 0 $accept: unit "end of file" . $default accept State 4 8 exp: . "incr" exp @1 @2 exp 8 | "incr" . exp @1 @2 exp 9 | . "(" exp ")" 10 | . "identifier" 11 | . "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 12 State 5 5 id: "identifier" . [":="] 10 exp: "identifier" . ["end of file"] "end of file" reduce using rule 10 (exp) $default reduce using rule 5 (id) State 6 11 exp: "number" . $default reduce using rule 11 (exp) State 7 8 exp: . "incr" exp @1 @2 exp 9 | . "(" exp ")" 9 | "(" . exp ")" 10 | . "identifier" 11 | . "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 13 State 8 3 assignments: assignments assignment . $default reduce using rule 3 (assignments) State 9 4 assignment: id . ":=" exp ":=" shift, and go to state 14 State 10 1 unit: assignments exp . $default reduce using rule 1 (unit) State 11 10 exp: "identifier" . $default reduce using rule 10 (exp) State 12 6 @1: %empty . 8 exp: "incr" exp . @1 @2 exp $default reduce using rule 6 (@1) @1 go to state 15 State 13 9 exp: "(" exp . ")" ")" shift, and go to state 16 State 14 4 assignment: id ":=" . exp 8 exp: . "incr" exp @1 @2 exp 9 | . "(" exp ")" 10 | . "identifier" 11 | . "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 17 State 15 7 @2: %empty . 8 exp: "incr" exp @1 . @2 exp $default reduce using rule 7 (@2) @2 go to state 18 State 16 9 exp: "(" exp ")" . $default reduce using rule 9 (exp) State 17 4 assignment: id ":=" exp . $default reduce using rule 4 (assignment) State 18 8 exp: . "incr" exp @1 @2 exp 8 | "incr" exp @1 @2 . exp 9 | . "(" exp ")" 10 | . "identifier" 11 | . "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 19 State 19 8 exp: "incr" exp @1 @2 exp . $default reduce using rule 8 (exp) ]]) AT_CHECK([cat input.gv], [], [[// Generated by GNU Bison ]AT_PACKAGE_VERSION[. // Report bugs to . // Home page: . digraph "input.yy" { node [fontname = courier, shape = box, colorscheme = paired6] edge [fontname = courier] 0 [label="State 0\n\l 0 $accept: • unit \"end of file\"\l 1 unit: • assignments exp\l 2 assignments: • %empty\l 3 | • assignments assignment\l"] 0 -> 1 [style=dashed label="unit"] 0 -> 2 [style=dashed label="assignments"] 0 -> "0R2" [style=solid] "0R2" [label="R2", fillcolor=3, shape=diamond, style=filled] 1 [label="State 1\n\l 0 $accept: unit • \"end of file\"\l"] 1 -> 3 [style=solid label="\"end of file\""] 2 [label="State 2\n\l 1 unit: assignments • exp\l 3 assignments: assignments • assignment\l 4 assignment: • id \":=\" exp\l 5 id: • \"identifier\"\l 8 exp: • \"incr\" exp @1 @2 exp\l 9 | • \"(\" exp \")\"\l 10 | • \"identifier\"\l 11 | • \"number\"\l"] 2 -> 4 [style=solid label="\"incr\""] 2 -> 5 [style=solid label="\"identifier\""] 2 -> 6 [style=solid label="\"number\""] 2 -> 7 [style=solid label="\"(\""] 2 -> 8 [style=dashed label="assignment"] 2 -> 9 [style=dashed label="id"] 2 -> 10 [style=dashed label="exp"] 3 [label="State 3\n\l 0 $accept: unit \"end of file\" •\l"] 3 -> "3R0" [style=solid] "3R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] 4 [label="State 4\n\l 8 exp: • \"incr\" exp @1 @2 exp\l 8 | \"incr\" • exp @1 @2 exp\l 9 | • \"(\" exp \")\"\l 10 | • \"identifier\"\l 11 | • \"number\"\l"] 4 -> 4 [style=solid label="\"incr\""] 4 -> 11 [style=solid label="\"identifier\""] 4 -> 6 [style=solid label="\"number\""] 4 -> 7 [style=solid label="\"(\""] 4 -> 12 [style=dashed label="exp"] 5 [label="State 5\n\l 5 id: \"identifier\" • [\":=\"]\l 10 exp: \"identifier\" • [\"end of file\"]\l"] 5 -> "5R5" [style=solid] "5R5" [label="R5", fillcolor=3, shape=diamond, style=filled] 5 -> "5R10" [label="[\"end of file\"]", style=solid] "5R10" [label="R10", fillcolor=3, shape=diamond, style=filled] 6 [label="State 6\n\l 11 exp: \"number\" •\l"] 6 -> "6R11" [style=solid] "6R11" [label="R11", fillcolor=3, shape=diamond, style=filled] 7 [label="State 7\n\l 8 exp: • \"incr\" exp @1 @2 exp\l 9 | • \"(\" exp \")\"\l 9 | \"(\" • exp \")\"\l 10 | • \"identifier\"\l 11 | • \"number\"\l"] 7 -> 4 [style=solid label="\"incr\""] 7 -> 11 [style=solid label="\"identifier\""] 7 -> 6 [style=solid label="\"number\""] 7 -> 7 [style=solid label="\"(\""] 7 -> 13 [style=dashed label="exp"] 8 [label="State 8\n\l 3 assignments: assignments assignment •\l"] 8 -> "8R3" [style=solid] "8R3" [label="R3", fillcolor=3, shape=diamond, style=filled] 9 [label="State 9\n\l 4 assignment: id • \":=\" exp\l"] 9 -> 14 [style=solid label="\":=\""] 10 [label="State 10\n\l 1 unit: assignments exp •\l"] 10 -> "10R1" [style=solid] "10R1" [label="R1", fillcolor=3, shape=diamond, style=filled] 11 [label="State 11\n\l 10 exp: \"identifier\" •\l"] 11 -> "11R10" [style=solid] "11R10" [label="R10", fillcolor=3, shape=diamond, style=filled] 12 [label="State 12\n\l 6 @1: • %empty\l 8 exp: \"incr\" exp • @1 @2 exp\l"] 12 -> 15 [style=dashed label="@1"] 12 -> "12R6" [style=solid] "12R6" [label="R6", fillcolor=3, shape=diamond, style=filled] 13 [label="State 13\n\l 9 exp: \"(\" exp • \")\"\l"] 13 -> 16 [style=solid label="\")\""] 14 [label="State 14\n\l 4 assignment: id \":=\" • exp\l 8 exp: • \"incr\" exp @1 @2 exp\l 9 | • \"(\" exp \")\"\l 10 | • \"identifier\"\l 11 | • \"number\"\l"] 14 -> 4 [style=solid label="\"incr\""] 14 -> 11 [style=solid label="\"identifier\""] 14 -> 6 [style=solid label="\"number\""] 14 -> 7 [style=solid label="\"(\""] 14 -> 17 [style=dashed label="exp"] 15 [label="State 15\n\l 7 @2: • %empty\l 8 exp: \"incr\" exp @1 • @2 exp\l"] 15 -> 18 [style=dashed label="@2"] 15 -> "15R7" [style=solid] "15R7" [label="R7", fillcolor=3, shape=diamond, style=filled] 16 [label="State 16\n\l 9 exp: \"(\" exp \")\" •\l"] 16 -> "16R9" [style=solid] "16R9" [label="R9", fillcolor=3, shape=diamond, style=filled] 17 [label="State 17\n\l 4 assignment: id \":=\" exp •\l"] 17 -> "17R4" [style=solid] "17R4" [label="R4", fillcolor=3, shape=diamond, style=filled] 18 [label="State 18\n\l 8 exp: • \"incr\" exp @1 @2 exp\l 8 | \"incr\" exp @1 @2 • exp\l 9 | • \"(\" exp \")\"\l 10 | • \"identifier\"\l 11 | • \"number\"\l"] 18 -> 4 [style=solid label="\"incr\""] 18 -> 11 [style=solid label="\"identifier\""] 18 -> 6 [style=solid label="\"number\""] 18 -> 7 [style=solid label="\"(\""] 18 -> 19 [style=dashed label="exp"] 19 [label="State 19\n\l 8 exp: \"incr\" exp @1 @2 exp •\l"] 19 -> "19R8" [style=solid] "19R8" [label="R8", fillcolor=3, shape=diamond, style=filled] } ]]) AT_CHECK([[cat input.xml]], [], [[ input.yy $accept unit "end of file" unit assignments exp assignments assignments assignments assignment assignment id ":=" exp id "identifier" @1 @2 exp "incr" exp @1 @2 exp exp "(" exp ")" exp "identifier" exp "number" ":=" "end of file" ]]) # Check HTML output. AT_CHECK([[cat input.html]], [], [[ input.yy - GNU Bison XML Automaton Report

GNU Bison XML Automaton Report

input grammar: input.yy

Table of Contents

Reductions

Nonterminals useless in grammar

Terminals unused in grammar

Rules useless in grammar

Conflicts

Grammar

0 $acceptunit "end of file" 1 unitassignments exp 2 assignments → %empty 3 | assignments assignment 4 assignmentid ":=" exp 5 id"identifier" 6 @1 → %empty 7 @2 → %empty 8 exp"incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number"

Terminals, with rules where they appear

  • "end of file" (0) 0
  • error (256)
  • ":=" (258) 4
  • "incr" (259) 8
  • "identifier" <std::string> (260) 5 10
  • "number" <int> (261) 11
  • "(" (262) 9
  • ")" (263) 9

Nonterminals, with rules where they appear

  • $accept (9)
    • on left: 0
  • unit (10)
    • on left: 1
    • on right: 0
  • assignments (11)
    • on left: 2 3
    • on right: 1 3
  • assignment (12)
    • on left: 4
    • on right: 3
  • id <std::string> (13)
    • on left: 5
    • on right: 4
  • exp <int> (14)
  • @1 <int> (15)
    • on left: 6
    • on right: 8
  • @2 <int> (16)
    • on left: 7
    • on right: 8

Automaton

State 0

0 $accept unit "end of file" 1 unit assignments exp 2 assignments %empty 3 | assignments assignment $default reduce using rule 2 (assignments) unit go to state 1 assignments go to state 2

State 1

0 $acceptunit "end of file" "end of file" shift, and go to state 3

State 2

1 unitassignments exp 3 assignmentsassignments assignment 4 assignment id ":=" exp 5 id "identifier" 8 exp "incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 5 "number" shift, and go to state 6 "(" shift, and go to state 7 assignment go to state 8 id go to state 9 exp go to state 10

State 3

0 $acceptunit "end of file" $default accept

State 4

8 exp "incr" exp @1 @2 exp 8 | "incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 12

State 5

5 id"identifier" [":="] 10 exp"identifier" ["end of file"] "end of file" reduce using rule 10 (exp) $default reduce using rule 5 (id)

State 6

11 exp"number" $default reduce using rule 11 (exp)

State 7

8 exp "incr" exp @1 @2 exp 9 | "(" exp ")" 9 | "(" exp ")" 10 | "identifier" 11 | "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 13

State 8

3 assignmentsassignments assignment $default reduce using rule 3 (assignments)

State 9

4 assignmentid ":=" exp ":=" shift, and go to state 14

State 10

1 unitassignments exp $default reduce using rule 1 (unit)

State 11

10 exp"identifier" $default reduce using rule 10 (exp)

State 12

6 @1 %empty 8 exp"incr" exp @1 @2 exp $default reduce using rule 6 (@1) @1 go to state 15

State 13

9 exp"(" exp ")" ")" shift, and go to state 16

State 14

4 assignmentid ":=" exp 8 exp "incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 17

State 15

7 @2 %empty 8 exp"incr" exp @1 @2 exp $default reduce using rule 7 (@2) @2 go to state 18

State 16

9 exp"(" exp ")" $default reduce using rule 9 (exp)

State 17

4 assignmentid ":=" exp $default reduce using rule 4 (assignment)

State 18

8 exp "incr" exp @1 @2 exp 8 | "incr" exp @1 @2 exp 9 | "(" exp ")" 10 | "identifier" 11 | "number" "incr" shift, and go to state 4 "identifier" shift, and go to state 11 "number" shift, and go to state 6 "(" shift, and go to state 7 exp go to state 19

State 19

8 exp"incr" exp @1 @2 exp $default reduce using rule 8 (exp)

]]) AT_BISON_OPTION_POPDEFS AT_CLEANUP ## -------------------- ## ## Multistart reports. ## ## -------------------- ## AT_SETUP([Multistart reports]) AT_KEYWORDS([multistart report]) AT_BISON_OPTION_PUSHDEFS AT_DATA([input.yy], [[%token END 0 "end of file" ASSIGN ":=" INCR "incr" ; %token IDENTIFIER "identifier" %type id %token NUMBER "number" %type exp %% %start unit assignments exp; unit: assignments exp { driver.result = $2; }; assignments: %empty {} | assignments assignment {}; assignment: id ":=" exp { driver.variables[$id] = $exp; }; id: "identifier"; exp: "incr" exp { $$ = 1; } { $$ = 10; } exp { $$ = $2 + $3 + $4 + $5; } | "(" exp ")" { std::swap ($$, $2); } | "identifier" { $$ = driver.variables[$1]; } | "number" { std::swap ($$, $1); }; ]]) AT_BISON_CHECK([-o input.cc -rall --graph=input.gv --xml input.yy]) # Check the contents of the report. AT_CHECK([cat input.output], [], [[Grammar 0 $accept: YY_PARSE_unit unit "end of file" 1 | YY_PARSE_assignments assignments "end of file" 2 | YY_PARSE_exp exp "end of file" 3 unit: assignments exp 4 assignments: %empty 5 | assignments assignment 6 assignment: id ":=" exp 7 id: "identifier" 8 @1: %empty 9 @2: %empty 10 exp: "incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number" Terminals, with rules where they appear "end of file" (0) 0 1 2 error (256) ":=" (258) 6 "incr" (259) 10 "identifier" (260) 7 12 "number" (261) 13 YY_PARSE_unit (262) 0 YY_PARSE_assignments (263) 1 YY_PARSE_exp (264) 2 "(" (265) 11 ")" (266) 11 Nonterminals, with rules where they appear $accept (12) on left: 0 1 2 unit (13) on left: 3 on right: 0 assignments (14) on left: 4 5 on right: 1 3 5 assignment (15) on left: 6 on right: 5 id (16) on left: 7 on right: 6 exp (17) on left: 10 11 12 13 on right: 2 3 6 10 11 @1 (18) on left: 8 on right: 10 @2 (19) on left: 9 on right: 10 State 0 0 $accept: . YY_PARSE_unit unit "end of file" 1 | . YY_PARSE_assignments assignments "end of file" 2 | . YY_PARSE_exp exp "end of file" YY_PARSE_unit shift, and go to state 1 YY_PARSE_assignments shift, and go to state 2 YY_PARSE_exp shift, and go to state 3 State 1 0 $accept: YY_PARSE_unit . unit "end of file" 3 unit: . assignments exp 4 assignments: %empty . 5 | . assignments assignment $default reduce using rule 4 (assignments) unit go to state 4 assignments go to state 5 State 2 1 $accept: YY_PARSE_assignments . assignments "end of file" 4 assignments: %empty . 5 | . assignments assignment $default reduce using rule 4 (assignments) assignments go to state 6 State 3 2 $accept: YY_PARSE_exp . exp "end of file" 10 exp: . "incr" exp @1 @2 exp 11 | . "(" exp ")" 12 | . "identifier" 13 | . "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 11 State 4 0 $accept: YY_PARSE_unit unit . "end of file" "end of file" shift, and go to state 12 State 5 3 unit: assignments . exp 5 assignments: assignments . assignment 6 assignment: . id ":=" exp 7 id: . "identifier" 10 exp: . "incr" exp @1 @2 exp 11 | . "(" exp ")" 12 | . "identifier" 13 | . "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 13 "number" shift, and go to state 9 "(" shift, and go to state 10 assignment go to state 14 id go to state 15 exp go to state 16 State 6 1 $accept: YY_PARSE_assignments assignments . "end of file" 5 assignments: assignments . assignment 6 assignment: . id ":=" exp 7 id: . "identifier" "end of file" shift, and go to state 17 "identifier" shift, and go to state 18 assignment go to state 14 id go to state 15 State 7 10 exp: . "incr" exp @1 @2 exp 10 | "incr" . exp @1 @2 exp 11 | . "(" exp ")" 12 | . "identifier" 13 | . "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 19 State 8 12 exp: "identifier" . $default reduce using rule 12 (exp) State 9 13 exp: "number" . $default reduce using rule 13 (exp) State 10 10 exp: . "incr" exp @1 @2 exp 11 | . "(" exp ")" 11 | "(" . exp ")" 12 | . "identifier" 13 | . "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 20 State 11 2 $accept: YY_PARSE_exp exp . "end of file" "end of file" shift, and go to state 21 State 12 0 $accept: YY_PARSE_unit unit "end of file" . $default accept State 13 7 id: "identifier" . [":="] 12 exp: "identifier" . ["end of file"] "end of file" reduce using rule 12 (exp) $default reduce using rule 7 (id) State 14 5 assignments: assignments assignment . $default reduce using rule 5 (assignments) State 15 6 assignment: id . ":=" exp ":=" shift, and go to state 22 State 16 3 unit: assignments exp . $default reduce using rule 3 (unit) State 17 1 $accept: YY_PARSE_assignments assignments "end of file" . $default accept State 18 7 id: "identifier" . $default reduce using rule 7 (id) State 19 8 @1: %empty . 10 exp: "incr" exp . @1 @2 exp $default reduce using rule 8 (@1) @1 go to state 23 State 20 11 exp: "(" exp . ")" ")" shift, and go to state 24 State 21 2 $accept: YY_PARSE_exp exp "end of file" . $default accept State 22 6 assignment: id ":=" . exp 10 exp: . "incr" exp @1 @2 exp 11 | . "(" exp ")" 12 | . "identifier" 13 | . "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 25 State 23 9 @2: %empty . 10 exp: "incr" exp @1 . @2 exp $default reduce using rule 9 (@2) @2 go to state 26 State 24 11 exp: "(" exp ")" . $default reduce using rule 11 (exp) State 25 6 assignment: id ":=" exp . $default reduce using rule 6 (assignment) State 26 10 exp: . "incr" exp @1 @2 exp 10 | "incr" exp @1 @2 . exp 11 | . "(" exp ")" 12 | . "identifier" 13 | . "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 27 State 27 10 exp: "incr" exp @1 @2 exp . $default reduce using rule 10 (exp) ]]) AT_CHECK([cat input.gv], [], [[// Generated by GNU Bison ]AT_PACKAGE_VERSION[. // Report bugs to . // Home page: . digraph "input.yy" { node [fontname = courier, shape = box, colorscheme = paired6] edge [fontname = courier] 0 [label="State 0\n\l 0 $accept: • YY_PARSE_unit unit \"end of file\"\l 1 | • YY_PARSE_assignments assignments \"end of file\"\l 2 | • YY_PARSE_exp exp \"end of file\"\l"] 0 -> 1 [style=solid label="YY_PARSE_unit"] 0 -> 2 [style=solid label="YY_PARSE_assignments"] 0 -> 3 [style=solid label="YY_PARSE_exp"] 1 [label="State 1\n\l 0 $accept: YY_PARSE_unit • unit \"end of file\"\l 3 unit: • assignments exp\l 4 assignments: • %empty\l 5 | • assignments assignment\l"] 1 -> 4 [style=dashed label="unit"] 1 -> 5 [style=dashed label="assignments"] 1 -> "1R4" [style=solid] "1R4" [label="R4", fillcolor=3, shape=diamond, style=filled] 2 [label="State 2\n\l 1 $accept: YY_PARSE_assignments • assignments \"end of file\"\l 4 assignments: • %empty\l 5 | • assignments assignment\l"] 2 -> 6 [style=dashed label="assignments"] 2 -> "2R4" [style=solid] "2R4" [label="R4", fillcolor=3, shape=diamond, style=filled] 3 [label="State 3\n\l 2 $accept: YY_PARSE_exp • exp \"end of file\"\l 10 exp: • \"incr\" exp @1 @2 exp\l 11 | • \"(\" exp \")\"\l 12 | • \"identifier\"\l 13 | • \"number\"\l"] 3 -> 7 [style=solid label="\"incr\""] 3 -> 8 [style=solid label="\"identifier\""] 3 -> 9 [style=solid label="\"number\""] 3 -> 10 [style=solid label="\"(\""] 3 -> 11 [style=dashed label="exp"] 4 [label="State 4\n\l 0 $accept: YY_PARSE_unit unit • \"end of file\"\l"] 4 -> 12 [style=solid label="\"end of file\""] 5 [label="State 5\n\l 3 unit: assignments • exp\l 5 assignments: assignments • assignment\l 6 assignment: • id \":=\" exp\l 7 id: • \"identifier\"\l 10 exp: • \"incr\" exp @1 @2 exp\l 11 | • \"(\" exp \")\"\l 12 | • \"identifier\"\l 13 | • \"number\"\l"] 5 -> 7 [style=solid label="\"incr\""] 5 -> 13 [style=solid label="\"identifier\""] 5 -> 9 [style=solid label="\"number\""] 5 -> 10 [style=solid label="\"(\""] 5 -> 14 [style=dashed label="assignment"] 5 -> 15 [style=dashed label="id"] 5 -> 16 [style=dashed label="exp"] 6 [label="State 6\n\l 1 $accept: YY_PARSE_assignments assignments • \"end of file\"\l 5 assignments: assignments • assignment\l 6 assignment: • id \":=\" exp\l 7 id: • \"identifier\"\l"] 6 -> 17 [style=solid label="\"end of file\""] 6 -> 18 [style=solid label="\"identifier\""] 6 -> 14 [style=dashed label="assignment"] 6 -> 15 [style=dashed label="id"] 7 [label="State 7\n\l 10 exp: • \"incr\" exp @1 @2 exp\l 10 | \"incr\" • exp @1 @2 exp\l 11 | • \"(\" exp \")\"\l 12 | • \"identifier\"\l 13 | • \"number\"\l"] 7 -> 7 [style=solid label="\"incr\""] 7 -> 8 [style=solid label="\"identifier\""] 7 -> 9 [style=solid label="\"number\""] 7 -> 10 [style=solid label="\"(\""] 7 -> 19 [style=dashed label="exp"] 8 [label="State 8\n\l 12 exp: \"identifier\" •\l"] 8 -> "8R12" [style=solid] "8R12" [label="R12", fillcolor=3, shape=diamond, style=filled] 9 [label="State 9\n\l 13 exp: \"number\" •\l"] 9 -> "9R13" [style=solid] "9R13" [label="R13", fillcolor=3, shape=diamond, style=filled] 10 [label="State 10\n\l 10 exp: • \"incr\" exp @1 @2 exp\l 11 | • \"(\" exp \")\"\l 11 | \"(\" • exp \")\"\l 12 | • \"identifier\"\l 13 | • \"number\"\l"] 10 -> 7 [style=solid label="\"incr\""] 10 -> 8 [style=solid label="\"identifier\""] 10 -> 9 [style=solid label="\"number\""] 10 -> 10 [style=solid label="\"(\""] 10 -> 20 [style=dashed label="exp"] 11 [label="State 11\n\l 2 $accept: YY_PARSE_exp exp • \"end of file\"\l"] 11 -> 21 [style=solid label="\"end of file\""] 12 [label="State 12\n\l 0 $accept: YY_PARSE_unit unit \"end of file\" •\l"] 12 -> "12R0" [style=solid] "12R0" [label="Acc", fillcolor=1, shape=diamond, style=filled] 13 [label="State 13\n\l 7 id: \"identifier\" • [\":=\"]\l 12 exp: \"identifier\" • [\"end of file\"]\l"] 13 -> "13R7" [style=solid] "13R7" [label="R7", fillcolor=3, shape=diamond, style=filled] 13 -> "13R12" [label="[\"end of file\"]", style=solid] "13R12" [label="R12", fillcolor=3, shape=diamond, style=filled] 14 [label="State 14\n\l 5 assignments: assignments assignment •\l"] 14 -> "14R5" [style=solid] "14R5" [label="R5", fillcolor=3, shape=diamond, style=filled] 15 [label="State 15\n\l 6 assignment: id • \":=\" exp\l"] 15 -> 22 [style=solid label="\":=\""] 16 [label="State 16\n\l 3 unit: assignments exp •\l"] 16 -> "16R3" [style=solid] "16R3" [label="R3", fillcolor=3, shape=diamond, style=filled] 17 [label="State 17\n\l 1 $accept: YY_PARSE_assignments assignments \"end of file\" •\l"] 17 -> "17R1" [style=solid] "17R1" [label="Acc", fillcolor=1, shape=diamond, style=filled] 18 [label="State 18\n\l 7 id: \"identifier\" •\l"] 18 -> "18R7" [style=solid] "18R7" [label="R7", fillcolor=3, shape=diamond, style=filled] 19 [label="State 19\n\l 8 @1: • %empty\l 10 exp: \"incr\" exp • @1 @2 exp\l"] 19 -> 23 [style=dashed label="@1"] 19 -> "19R8" [style=solid] "19R8" [label="R8", fillcolor=3, shape=diamond, style=filled] 20 [label="State 20\n\l 11 exp: \"(\" exp • \")\"\l"] 20 -> 24 [style=solid label="\")\""] 21 [label="State 21\n\l 2 $accept: YY_PARSE_exp exp \"end of file\" •\l"] 21 -> "21R2" [style=solid] "21R2" [label="Acc", fillcolor=1, shape=diamond, style=filled] 22 [label="State 22\n\l 6 assignment: id \":=\" • exp\l 10 exp: • \"incr\" exp @1 @2 exp\l 11 | • \"(\" exp \")\"\l 12 | • \"identifier\"\l 13 | • \"number\"\l"] 22 -> 7 [style=solid label="\"incr\""] 22 -> 8 [style=solid label="\"identifier\""] 22 -> 9 [style=solid label="\"number\""] 22 -> 10 [style=solid label="\"(\""] 22 -> 25 [style=dashed label="exp"] 23 [label="State 23\n\l 9 @2: • %empty\l 10 exp: \"incr\" exp @1 • @2 exp\l"] 23 -> 26 [style=dashed label="@2"] 23 -> "23R9" [style=solid] "23R9" [label="R9", fillcolor=3, shape=diamond, style=filled] 24 [label="State 24\n\l 11 exp: \"(\" exp \")\" •\l"] 24 -> "24R11" [style=solid] "24R11" [label="R11", fillcolor=3, shape=diamond, style=filled] 25 [label="State 25\n\l 6 assignment: id \":=\" exp •\l"] 25 -> "25R6" [style=solid] "25R6" [label="R6", fillcolor=3, shape=diamond, style=filled] 26 [label="State 26\n\l 10 exp: • \"incr\" exp @1 @2 exp\l 10 | \"incr\" exp @1 @2 • exp\l 11 | • \"(\" exp \")\"\l 12 | • \"identifier\"\l 13 | • \"number\"\l"] 26 -> 7 [style=solid label="\"incr\""] 26 -> 8 [style=solid label="\"identifier\""] 26 -> 9 [style=solid label="\"number\""] 26 -> 10 [style=solid label="\"(\""] 26 -> 27 [style=dashed label="exp"] 27 [label="State 27\n\l 10 exp: \"incr\" exp @1 @2 exp •\l"] 27 -> "27R10" [style=solid] "27R10" [label="R10", fillcolor=3, shape=diamond, style=filled] } ]]) AT_CHECK([[cat input.xml]], [], [[ input.yy $accept YY_PARSE_unit unit "end of file" $accept YY_PARSE_assignments assignments "end of file" $accept YY_PARSE_exp exp "end of file" unit assignments exp assignments assignments assignments assignment assignment id ":=" exp id "identifier" @1 @2 exp "incr" exp @1 @2 exp exp "(" exp ")" exp "identifier" exp "number" ":=" "end of file" ]]) if test x"$XSLTPROC" != x""; then AT_CHECK([[$XSLTPROC \ `]]AT_SET_ENV[[ bison --print-datadir`/xslt/xml2xhtml.xsl \ input.xml >input.html]]) AT_CHECK([cat input.html], [], [[ input.yy - GNU Bison XML Automaton Report

GNU Bison XML Automaton Report

input grammar: input.yy

Table of Contents

Reductions

Nonterminals useless in grammar

Terminals unused in grammar

Rules useless in grammar

Conflicts

Grammar

0 $acceptYY_PARSE_unit unit "end of file" 1 | YY_PARSE_assignments assignments "end of file" 2 | YY_PARSE_exp exp "end of file" 3 unitassignments exp 4 assignments → %empty 5 | assignments assignment 6 assignmentid ":=" exp 7 id"identifier" 8 @1 → %empty 9 @2 → %empty 10 exp"incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number"

Terminals, with rules where they appear

  • "end of file" (0) 0 1 2
  • error (256)
  • ":=" (258) 6
  • "incr" (259) 10
  • "identifier" <std::string> (260) 7 12
  • "number" <int> (261) 13
  • YY_PARSE_unit (262) 0
  • YY_PARSE_assignments (263) 1
  • YY_PARSE_exp (264) 2
  • "(" (265) 11
  • ")" (266) 11

Nonterminals, with rules where they appear

  • $accept (12)
    • on left: 0 1 2
  • unit (13)
    • on left: 3
    • on right: 0
  • assignments (14)
    • on left: 4 5
    • on right: 1 3 5
  • assignment (15)
    • on left: 6
    • on right: 5
  • id <std::string> (16)
    • on left: 7
    • on right: 6
  • exp <int> (17)
  • @1 <int> (18)
    • on left: 8
    • on right: 10
  • @2 <int> (19)
    • on left: 9
    • on right: 10

Automaton

State 0

0 $accept YY_PARSE_unit unit "end of file" 1 | YY_PARSE_assignments assignments "end of file" 2 | YY_PARSE_exp exp "end of file" YY_PARSE_unit shift, and go to state 1 YY_PARSE_assignments shift, and go to state 2 YY_PARSE_exp shift, and go to state 3

State 1

0 $acceptYY_PARSE_unit unit "end of file" 3 unit assignments exp 4 assignments %empty 5 | assignments assignment $default reduce using rule 4 (assignments) unit go to state 4 assignments go to state 5

State 2

1 $acceptYY_PARSE_assignments assignments "end of file" 4 assignments %empty 5 | assignments assignment $default reduce using rule 4 (assignments) assignments go to state 6

State 3

2 $acceptYY_PARSE_exp exp "end of file" 10 exp "incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 11

State 4

0 $acceptYY_PARSE_unit unit "end of file" "end of file" shift, and go to state 12

State 5

3 unitassignments exp 5 assignmentsassignments assignment 6 assignment id ":=" exp 7 id "identifier" 10 exp "incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 13 "number" shift, and go to state 9 "(" shift, and go to state 10 assignment go to state 14 id go to state 15 exp go to state 16

State 6

1 $acceptYY_PARSE_assignments assignments "end of file" 5 assignmentsassignments assignment 6 assignment id ":=" exp 7 id "identifier" "end of file" shift, and go to state 17 "identifier" shift, and go to state 18 assignment go to state 14 id go to state 15

State 7

10 exp "incr" exp @1 @2 exp 10 | "incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 19

State 8

12 exp"identifier" $default reduce using rule 12 (exp)

State 9

13 exp"number" $default reduce using rule 13 (exp)

State 10

10 exp "incr" exp @1 @2 exp 11 | "(" exp ")" 11 | "(" exp ")" 12 | "identifier" 13 | "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 20

State 11

2 $acceptYY_PARSE_exp exp "end of file" "end of file" shift, and go to state 21

State 12

0 $acceptYY_PARSE_unit unit "end of file" $default accept

State 13

7 id"identifier" [":="] 12 exp"identifier" ["end of file"] "end of file" reduce using rule 12 (exp) $default reduce using rule 7 (id)

State 14

5 assignmentsassignments assignment $default reduce using rule 5 (assignments)

State 15

6 assignmentid ":=" exp ":=" shift, and go to state 22

State 16

3 unitassignments exp $default reduce using rule 3 (unit)

State 17

1 $acceptYY_PARSE_assignments assignments "end of file" $default accept

State 18

7 id"identifier" $default reduce using rule 7 (id)

State 19

8 @1 %empty 10 exp"incr" exp @1 @2 exp $default reduce using rule 8 (@1) @1 go to state 23

State 20

11 exp"(" exp ")" ")" shift, and go to state 24

State 21

2 $acceptYY_PARSE_exp exp "end of file" $default accept

State 22

6 assignmentid ":=" exp 10 exp "incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 25

State 23

9 @2 %empty 10 exp"incr" exp @1 @2 exp $default reduce using rule 9 (@2) @2 go to state 26

State 24

11 exp"(" exp ")" $default reduce using rule 11 (exp)

State 25

6 assignmentid ":=" exp $default reduce using rule 6 (assignment)

State 26

10 exp "incr" exp @1 @2 exp 10 | "incr" exp @1 @2 exp 11 | "(" exp ")" 12 | "identifier" 13 | "number" "incr" shift, and go to state 7 "identifier" shift, and go to state 8 "number" shift, and go to state 9 "(" shift, and go to state 10 exp go to state 27

State 27

10 exp"incr" exp @1 @2 exp $default reduce using rule 10 (exp)

]]) fi AT_BISON_OPTION_POPDEFS AT_CLEANUP ## ------------------------ ## ## Reports with conflicts. ## ## ------------------------ ## AT_SETUP([Reports with conflicts]) AT_KEYWORDS([cex report]) # We need UTF-8 support for correct screen-width computation of UTF-8 # characters. Skip the test if not available. locale=`locale -a | $EGREP '^en_US\.(UTF-8|utf8)$' | sed 1q` AT_SKIP_IF([[test x = x"$locale"]]) AT_SKIP_IF([[test x"$XSLTPROC" = x]]) AT_BISON_OPTION_PUSHDEFS AT_DATA([input.y], [[%left "+" %% exp : exp "⊕" exp | exp "+" exp | exp "+" exp | "number" | "Ñùṃéℝô" ]]) AT_CHECK([LC_ALL="$locale" bison -fno-caret -o input.cc -rall -Wcex --graph=input.gv --html --xml input.y], [], [], [[input.y: warning: 3 shift/reduce conflicts [-Wconflicts-sr] input.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr] input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples] Example: exp "+" exp • "⊕" exp Shift derivation exp ↳ 2: exp "+" exp ↳ 1: exp • "⊕" exp Reduce derivation exp ↳ 1: exp "⊕" exp ↳ 2: exp "+" exp • input.y: warning: reduce/reduce conflict on tokens $end, "+", "⊕" [-Wcounterexamples] Example: exp "+" exp • First reduce derivation exp ↳ 2: exp "+" exp • Second reduce derivation exp ↳ 3: exp "+" exp • input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples] Example: exp "+" exp • "⊕" exp Shift derivation exp ↳ 2: exp "+" exp ↳ 1: exp • "⊕" exp Reduce derivation exp ↳ 1: exp "⊕" exp ↳ 3: exp "+" exp • input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples] Example: exp "⊕" exp • "⊕" exp Shift derivation exp ↳ 1: exp "⊕" exp ↳ 1: exp • "⊕" exp Reduce derivation exp ↳ 1: exp "⊕" exp ↳ 1: exp "⊕" exp • input.y: warning: shift/reduce conflict on token "+" [-Wcounterexamples] Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ 1: exp "⊕" exp ↳ 2: exp • "+" exp Reduce derivation exp ↳ 2: exp "+" exp ↳ 1: exp "⊕" exp • input.y: warning: shift/reduce conflict on token "+" [-Wcounterexamples] Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ 1: exp "⊕" exp ↳ 3: exp • "+" exp Reduce derivation exp ↳ 2: exp "+" exp ↳ 1: exp "⊕" exp • input.y:6.3-13: warning: rule useless in parser due to conflicts [-Wother] ]]) # Check the contents of the report. # FIXME: Avoid trailing white spaces. AT_CHECK([sed -e 's/ *$//' 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 "⊕" exp 2 | exp "+" exp 3 | exp "+" exp 4 | "number" 5 | "Ñùṃéℝô" Terminals, with rules where they appear $end (0) 0 error (256) "+" (258) 2 3 "⊕" (259) 1 "number" (260) 4 "Ñùṃéℝô" (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 "⊕" exp 2 | • exp "+" exp 3 | • exp "+" exp 4 | • "number" 5 | • "Ñùṃéℝô" "number" shift, and go to state 1 "Ñùṃéℝô" 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: "Ñùṃéℝô" • $default reduce using rule 5 (exp) State 3 0 $accept: exp • $end 1 exp: exp • "⊕" exp 2 | exp • "+" exp 3 | exp • "+" exp $end shift, and go to state 4 "+" shift, and go to state 5 "⊕" shift, and go to state 6 State 4 0 $accept: exp $end • $default accept State 5 1 exp: • exp "⊕" exp 2 | • exp "+" exp 2 | exp "+" • exp 3 | • exp "+" exp 3 | exp "+" • exp 4 | • "number" 5 | • "Ñùṃéℝô" "number" shift, and go to state 1 "Ñùṃéℝô" shift, and go to state 2 exp go to state 7 State 6 1 exp: • exp "⊕" exp 1 | exp "⊕" • exp 2 | • exp "+" exp 3 | • exp "+" exp 4 | • "number" 5 | • "Ñùṃéℝô" "number" shift, and go to state 1 "Ñùṃéℝô" shift, and go to state 2 exp go to state 8 State 7 1 exp: exp • "⊕" exp 2 | exp • "+" exp 2 | exp "+" exp • [$end, "+", "⊕"] 3 | exp • "+" exp 3 | exp "+" exp • [$end, "+", "⊕"] "⊕" 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)] "⊕" [reduce using rule 2 (exp)] "⊕" [reduce using rule 3 (exp)] $default reduce using rule 2 (exp) Conflict between rule 2 and token "+" resolved as reduce (%left "+"). shift/reduce conflict on token "⊕": 2 exp: exp "+" exp • 1 exp: exp • "⊕" exp Example: exp "+" exp • "⊕" exp Shift derivation exp ↳ 2: exp "+" exp ↳ 1: exp • "⊕" exp Reduce derivation exp ↳ 1: exp "⊕" exp ↳ 2: exp "+" exp • reduce/reduce conflict on tokens $end, "+", "⊕": 2 exp: exp "+" exp • 3 exp: exp "+" exp • Example: exp "+" exp • First reduce derivation exp ↳ 2: exp "+" exp • Second reduce derivation exp ↳ 3: exp "+" exp • shift/reduce conflict on token "⊕": 3 exp: exp "+" exp • 1 exp: exp • "⊕" exp Example: exp "+" exp • "⊕" exp Shift derivation exp ↳ 2: exp "+" exp ↳ 1: exp • "⊕" exp Reduce derivation exp ↳ 1: exp "⊕" exp ↳ 3: exp "+" exp • State 8 1 exp: exp • "⊕" exp 1 | exp "⊕" exp • [$end, "+", "⊕"] 2 | exp • "+" exp 3 | exp • "+" exp "+" shift, and go to state 5 "⊕" shift, and go to state 6 "+" [reduce using rule 1 (exp)] "⊕" [reduce using rule 1 (exp)] $default reduce using rule 1 (exp) shift/reduce conflict on token "⊕": 1 exp: exp "⊕" exp • 1 exp: exp • "⊕" exp Example: exp "⊕" exp • "⊕" exp Shift derivation exp ↳ 1: exp "⊕" exp ↳ 1: exp • "⊕" exp Reduce derivation exp ↳ 1: exp "⊕" exp ↳ 1: exp "⊕" exp • shift/reduce conflict on token "+": 1 exp: exp "⊕" exp • 2 exp: exp • "+" exp Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ 1: exp "⊕" exp ↳ 2: exp • "+" exp Reduce derivation exp ↳ 2: exp "+" exp ↳ 1: exp "⊕" exp • shift/reduce conflict on token "+": 1 exp: exp "⊕" exp • 3 exp: exp • "+" exp Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ 1: exp "⊕" exp ↳ 3: exp • "+" exp Reduce derivation exp ↳ 2: exp "+" exp ↳ 1: exp "⊕" exp • ]]) AT_CHECK([cat input.gv], [], [[// Generated by GNU Bison ]AT_PACKAGE_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 \"⊕\" exp\l 2 | • exp \"+\" exp\l 3 | • exp \"+\" exp\l 4 | • \"number\"\l 5 | • \"Ñùṃéℝô\"\l"] 0 -> 1 [style=solid label="\"number\""] 0 -> 2 [style=solid label="\"Ñùṃéℝô\""] 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: \"Ñùṃéℝô\" •\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 • \"⊕\" 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="\"⊕\""] 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 \"⊕\" exp\l 2 | • exp \"+\" exp\l 2 | exp \"+\" • exp\l 3 | • exp \"+\" exp\l 3 | exp \"+\" • exp\l 4 | • \"number\"\l 5 | • \"Ñùṃéℝô\"\l"] 5 -> 1 [style=solid label="\"number\""] 5 -> 2 [style=solid label="\"Ñùṃéℝô\""] 5 -> 7 [style=dashed label="exp"] 6 [label="State 6\n\l 1 exp: • exp \"⊕\" exp\l 1 | exp \"⊕\" • exp\l 2 | • exp \"+\" exp\l 3 | • exp \"+\" exp\l 4 | • \"number\"\l 5 | • \"Ñùṃéℝô\"\l"] 6 -> 1 [style=solid label="\"number\""] 6 -> 2 [style=solid label="\"Ñùṃéℝô\""] 6 -> 8 [style=dashed label="exp"] 7 [label="State 7\n\l 1 exp: exp • \"⊕\" exp\l 2 | exp • \"+\" exp\l 2 | exp \"+\" exp • [$end, \"+\", \"⊕\"]\l 3 | exp • \"+\" exp\l 3 | exp \"+\" exp • [$end, \"+\", \"⊕\"]\l"] 7 -> 6 [style=solid label="\"⊕\""] 7 -> "7R2d" [label="[\"⊕\"]", 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, \"+\", \"⊕\"]", style=solid] "7R3d" [label="R3", fillcolor=5, shape=diamond, style=filled] 8 [label="State 8\n\l 1 exp: exp • \"⊕\" exp\l 1 | exp \"⊕\" exp • [$end, \"+\", \"⊕\"]\l 2 | exp • \"+\" exp\l 3 | exp • \"+\" exp\l"] 8 -> 5 [style=solid label="\"+\""] 8 -> 6 [style=solid label="\"⊕\""] 8 -> "8R1d" [label="[\"+\", \"⊕\"]", 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([[cat input.xml]], [], [[ input.y $accept exp $end exp exp "⊕" exp exp exp "+" exp exp exp "+" exp exp "number" exp "Ñùṃéℝô" $end "+" "⊕" $end "+" "⊕" %left "+" $end "+" "⊕" ]]) AT_CHECK([[cat input.html]], [], [[ input.y - GNU Bison XML Automaton Report

GNU Bison XML Automaton Report

input grammar: input.y

Table of Contents

Reductions

Nonterminals useless in grammar

Terminals unused in grammar

Rules useless in grammar

Rules useless in parser due to conflicts

3 expexp "+" exp

Conflicts

State 7 conflicts: 1 shift/reduce, 3 reduce/reduce State 8 conflicts: 2 shift/reduce

Grammar

0 $acceptexp $end 1 expexp "⊕" exp 2 | exp "+" exp 3 | exp "+" exp 4 | "number" 5 | "Ñùṃéℝô"

Terminals, with rules where they appear

  • $end (0) 0
  • error (256)
  • "+" (258) 2 3
  • "⊕" (259) 1
  • "number" (260) 4
  • "Ñùṃéℝô" (261) 5

Nonterminals, with rules where they appear

  • $accept (7)
    • on left: 0
  • exp (8)

Automaton

State 0

0 $accept exp $end 1 exp exp "⊕" exp 2 | exp "+" exp 3 | exp "+" exp 4 | "number" 5 | "Ñùṃéℝô" "number" shift, and go to state 1 "Ñùṃéℝô" 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"Ñùṃéℝô" $default reduce using rule 5 (exp)

State 3

0 $acceptexp $end 1 expexp "⊕" exp 2 | exp "+" exp 3 | exp "+" exp $end shift, and go to state 4 "+" shift, and go to state 5 "⊕" shift, and go to state 6

State 4

0 $acceptexp $end $default accept

State 5

1 exp exp "⊕" exp 2 | exp "+" exp 2 | exp "+" exp 3 | exp "+" exp 3 | exp "+" exp 4 | "number" 5 | "Ñùṃéℝô" "number" shift, and go to state 1 "Ñùṃéℝô" shift, and go to state 2 exp go to state 7

State 6

1 exp exp "⊕" exp 1 | exp "⊕" exp 2 | exp "+" exp 3 | exp "+" exp 4 | "number" 5 | "Ñùṃéℝô" "number" shift, and go to state 1 "Ñùṃéℝô" shift, and go to state 2 exp go to state 8

State 7

1 expexp "⊕" exp 2 | exp "+" exp 2 | exp "+" exp [$end, "+", "⊕"] 3 | exp "+" exp 3 | exp "+" exp [$end, "+", "⊕"] "⊕" 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)] "⊕" [reduce using rule 2 (exp)] "⊕" [reduce using rule 3 (exp)] $default reduce using rule 2 (exp) Conflict between rule 2 and token "+" resolved as reduce (%left "+").

State 8

1 expexp "⊕" exp 1 | exp "⊕" exp [$end, "+", "⊕"] 2 | exp "+" exp 3 | exp "+" exp "+" shift, and go to state 5 "⊕" shift, and go to state 6 "+" [reduce using rule 1 (exp)] "⊕" [reduce using rule 1 (exp)] $default reduce using rule 1 (exp)

]]) AT_BISON_OPTION_POPDEFS AT_CLEANUP