input grammar: input.yy
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"
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
0 $accept → unit • "end of file" "end of file" shift, and go to state 3
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
0 $accept → unit "end of file" • $default accept
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
5 id → "identifier" • [":="] 10 exp → "identifier" • ["end of file"] "end of file" reduce using rule 10 (exp) $default reduce using rule 5 (id)
11 exp → "number" • $default reduce using rule 11 (exp)
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
3 assignments → assignments assignment • $default reduce using rule 3 (assignments)
4 assignment → id • ":=" exp ":=" shift, and go to state 14
1 unit → assignments exp • $default reduce using rule 1 (unit)
10 exp → "identifier" • $default reduce using rule 10 (exp)
6 @1 → • %empty 8 exp → "incr" exp • @1 @2 exp $default reduce using rule 6 (@1) @1 go to state 15
9 exp → "(" exp • ")" ")" shift, and go to state 16
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
7 @2 → • %empty 8 exp → "incr" exp @1 • @2 exp $default reduce using rule 7 (@2) @2 go to state 18
9 exp → "(" exp ")" • $default reduce using rule 9 (exp)
4 assignment → id ":=" exp • $default reduce using rule 4 (assignment)
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
8 exp → "incr" exp @1 @2 exp • $default reduce using rule 8 (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_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 --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 ↳ exp "+" exp ↳ exp • "⊕" exp Reduce derivation exp ↳ exp "⊕" exp ↳ exp "+" exp • input.y: warning: reduce/reduce conflict on tokens $end, "+", "⊕" [-Wcounterexamples] Example: exp "+" exp • First reduce derivation exp ↳ exp "+" exp • Second reduce derivation exp ↳ exp "+" exp • input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples] Example: exp "+" exp • "⊕" exp Shift derivation exp ↳ exp "+" exp ↳ exp • "⊕" exp Reduce derivation exp ↳ exp "⊕" exp ↳ exp "+" exp • input.y: warning: shift/reduce conflict on token "⊕" [-Wcounterexamples] Example: exp "⊕" exp • "⊕" exp Shift derivation exp ↳ exp "⊕" exp ↳ exp • "⊕" exp Reduce derivation exp ↳ exp "⊕" exp ↳ exp "⊕" exp • input.y: warning: shift/reduce conflict on token "+" [-Wcounterexamples] Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ exp "⊕" exp ↳ exp • "+" exp Reduce derivation exp ↳ exp "+" exp ↳ exp "⊕" exp • input.y: warning: shift/reduce conflict on token "+" [-Wcounterexamples] Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ exp "⊕" exp ↳ exp • "+" exp Reduce derivation exp ↳ exp "+" exp ↳ 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 ↳ exp "+" exp ↳ exp • "⊕" exp Reduce derivation exp ↳ exp "⊕" exp ↳ exp "+" exp • reduce/reduce conflict on tokens $end, "+", "⊕": 2 exp: exp "+" exp • 3 exp: exp "+" exp • Example: exp "+" exp • First reduce derivation exp ↳ exp "+" exp • Second reduce derivation exp ↳ exp "+" exp • shift/reduce conflict on token "⊕": 3 exp: exp "+" exp • 1 exp: exp • "⊕" exp Example: exp "+" exp • "⊕" exp Shift derivation exp ↳ exp "+" exp ↳ exp • "⊕" exp Reduce derivation exp ↳ exp "⊕" exp ↳ 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 ↳ exp "⊕" exp ↳ exp • "⊕" exp Reduce derivation exp ↳ exp "⊕" exp ↳ exp "⊕" exp • shift/reduce conflict on token "+": 1 exp: exp "⊕" exp • 2 exp: exp • "+" exp Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ exp "⊕" exp ↳ exp • "+" exp Reduce derivation exp ↳ exp "+" exp ↳ exp "⊕" exp • shift/reduce conflict on token "+": 1 exp: exp "⊕" exp • 3 exp: exp • "+" exp Example: exp "⊕" exp • "+" exp Shift derivation exp ↳ exp "⊕" exp ↳ exp • "+" exp Reduce derivation exp ↳ exp "+" exp ↳ exp "⊕" exp • ]]) AT_CHECK([sed -e '1s/GNU Bison .*\.$/GNU Bison VERSION./' input.gv], [], [[// Generated by GNU Bison VERSION. // Report bugs toinput grammar: input.y
3 exp → exp "+" exp
State 7 conflicts: 1 shift/reduce, 3 reduce/reduce State 8 conflicts: 2 shift/reduce
0 $accept → exp $end 1 exp → exp "⊕" exp 2 | exp "+" exp 3 | exp "+" exp 4 | "number" 5 | "Ñùṃéℝô"
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
4 exp → "number" • $default reduce using rule 4 (exp)
5 exp → "Ñùṃéℝô" • $default reduce using rule 5 (exp)
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
0 $accept → exp $end • $default accept
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
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
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 "+").
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)
]]) fi AT_BISON_OPTION_POPDEFS AT_CLEANUP