1 # Exercising Bison on conflicts. -*- Autotest -*-
3 # Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free
4 # Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 AT_BANNER([[Conflicts.]])
22 ## ---------------- ##
24 ## ---------------- ##
26 # I once hacked Bison in such a way that it lost its reductions on the
27 # initial state (because it was confusing it with the last state). It
28 # took me a while to strip down my failures to this simple case. So
29 # make sure it finds the s/r conflict below.
31 AT_SETUP([S/R in initial])
37 e: 'e' | /* Nothing. */;
40 AT_BISON_CHECK([-o input.c input.y], 0, [],
41 [[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */
47 ## ------------------- ##
48 ## %nonassoc and eof. ##
49 ## ------------------- ##
51 AT_SETUP([%nonassoc and eof])
53 AT_DATA_GRAMMAR([input.y],
60 #define YYERROR_VERBOSE 1
62 yyerror (const char *msg)
64 fprintf (stderr, "%s\n", msg);
67 /* The current argument. */
68 static const char *input;
74 if (! (toknum <= strlen (input)))
76 return input[toknum++];
90 main (int argc, const char *argv[])
92 input = argc <= 1 ? "" : argv[1];
97 # Specify the output files to avoid problems on different file systems.
98 AT_BISON_CHECK([-o input.c input.y])
101 AT_PARSER_CHECK([./input '0<0'])
102 AT_PARSER_CHECK([./input '0<0<0'], [1], [],
103 [syntax error, unexpected '<'
106 AT_PARSER_CHECK([./input '0>0'])
107 AT_PARSER_CHECK([./input '0>0>0'], [1], [],
108 [syntax error, unexpected '>'
111 AT_PARSER_CHECK([./input '0<0>0'], [1], [],
112 [syntax error, unexpected '>'
115 # We must disable default reductions in inconsistent states in order to
116 # have an explicit list of all expected tokens. (However, unless we use
117 # canonical LR, lookahead sets are merged for different left contexts,
118 # so it is still possible to have extra incorrect tokens in the expected
119 # list. That just doesn't happen to be a problem for this test case.)
121 AT_BISON_CHECK([-Dlr.default-reductions=consistent -o input.c input.y])
124 AT_PARSER_CHECK([./input '0<0'])
125 AT_PARSER_CHECK([./input '0<0<0'], [1], [],
126 [syntax error, unexpected '<', expecting $end
129 AT_PARSER_CHECK([./input '0>0'])
130 AT_PARSER_CHECK([./input '0>0>0'], [1], [],
131 [syntax error, unexpected '>', expecting $end
134 AT_PARSER_CHECK([./input '0<0>0'], [1], [],
135 [syntax error, unexpected '>', expecting $end
142 ## ------------------------------------------- ##
143 ## parse.error=verbose and consistent errors. ##
144 ## ------------------------------------------- ##
146 AT_SETUP([[parse.error=verbose and consistent errors]])
148 m4_pushdef([AT_CONSISTENT_ERRORS_CHECK], [
150 AT_BISON_OPTION_PUSHDEFS([$1])
152 m4_pushdef([AT_YYLEX_PROTOTYPE],
153 [AT_SKEL_CC_IF([[int yylex (yy::parser::semantic_type *lvalp)]],
154 [[int yylex (YYSTYPE *lvalp)]])])
156 AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y],
160 import java.io.IOException;
163 %code {]AT_SKEL_CC_IF([[
164 #include <string>]], [[
167 void yyerror (char const *msg);]])[
168 ]AT_YYLEX_PROTOTYPE[;
172 ]AT_SKEL_CC_IF([[%defines]], [[%define api.pure]])])[
176 %define parse.error verbose
182 ]AT_SKEL_JAVA_IF([[%code lexer {]], [[%%]])[
186 `--------*/]AT_SKEL_JAVA_IF([[
188 public String input = "]$3[";
189 public int index = 0;
192 if (index < input.length ())
193 return input.charAt (index++);
197 public Object getLVal ()
199 return new Integer(1);
204 static char const *input = "]$3[";
211 `----------*/]AT_SKEL_JAVA_IF([[
213 public void yyerror (String msg)
215 System.err.println (msg);
220 %%]], [AT_SKEL_CC_IF([[
223 yy::parser::error (std::string const &msg)
225 std::cerr << msg << std::endl;
229 yyerror (char const *msg)
231 fprintf (stderr, "%s\n", msg);
236 `-------*/]AT_SKEL_JAVA_IF([[
240 public static void main (String args[]) throws IOException
242 YYParser p = new YYParser ();
245 }]], [AT_SKEL_CC_IF([[
251 return parser.parse ();
261 AT_FULL_COMPILE([[input]])
263 m4_pushdef([AT_EXPECTING], [m4_if($5, [ab], [[, expecting 'a' or 'b']],
264 $5, [a], [[, expecting 'a']],
265 $5, [b], [[, expecting 'b']])])
267 AT_SKEL_JAVA_IF([AT_JAVA_PARSER_CHECK([[input]], [[0]]],
268 [AT_PARSER_CHECK([[./input]], [[1]]]),
270 [[syntax error, unexpected ]$4[]AT_EXPECTING[
273 m4_popdef([AT_EXPECTING])
274 m4_popdef([AT_YYLEX_PROTOTYPE])
275 AT_BISON_OPTION_POPDEFS
279 m4_pushdef([AT_PREVIOUS_STATE_GRAMMAR],
282 start: consistent-error-on-a-a 'a' ;
284 consistent-error-on-a-a:
285 'a' default-reduction
286 | 'a' default-reduction 'a'
290 default-reduction: /*empty*/ ;
293 // Provide another context in which all rules are useful so that this
294 // test case looks a little more realistic.
295 start: 'b' consistent-error-on-a-a 'c' ;
298 m4_pushdef([AT_PREVIOUS_STATE_INPUT], [[a]])
300 # Unfortunately, no expected tokens are reported even though 'b' can be
301 # accepted. Nevertheless, the main point of this test is to make sure
302 # that at least the unexpected token is reported. In a previous version
303 # of Bison, it wasn't reported because the error is detected in a
304 # consistent state with an error action, and that case always triggered
305 # the simple "syntax error" message.
307 # The point isn't to test IELR here, but state merging happens to
308 # complicate this example.
309 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr]],
310 [AT_PREVIOUS_STATE_GRAMMAR],
311 [AT_PREVIOUS_STATE_INPUT],
313 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
315 [AT_PREVIOUS_STATE_GRAMMAR],
316 [AT_PREVIOUS_STATE_INPUT],
318 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
320 [AT_PREVIOUS_STATE_GRAMMAR],
321 [AT_PREVIOUS_STATE_INPUT],
323 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
325 [AT_PREVIOUS_STATE_GRAMMAR],
326 [AT_PREVIOUS_STATE_INPUT],
327 [[end of input]], [[none]])
329 # Even canonical LR doesn't foresee the error for 'a'!
330 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
331 %define lr.default-reductions consistent]],
332 [AT_PREVIOUS_STATE_GRAMMAR],
333 [AT_PREVIOUS_STATE_INPUT],
335 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
336 %define lr.default-reductions accepting]],
337 [AT_PREVIOUS_STATE_GRAMMAR],
338 [AT_PREVIOUS_STATE_INPUT],
340 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type canonical-lr]],
341 [AT_PREVIOUS_STATE_GRAMMAR],
342 [AT_PREVIOUS_STATE_INPUT],
345 m4_popdef([AT_PREVIOUS_STATE_GRAMMAR])
346 m4_popdef([AT_PREVIOUS_STATE_INPUT])
348 m4_pushdef([AT_USER_ACTION_GRAMMAR],
351 // If $$ = 0 here, then we know that the 'a' destructor is being invoked
352 // incorrectly for the 'b' set in the semantic action below. All 'a'
353 // tokens are returned by yylex, which sets $$ = 1.
356 fprintf (stderr, "Wrong destructor.\n");
359 // Rather than depend on an inconsistent state to induce reading a
360 // lookahead as in the previous grammar, just assign the lookahead in a
361 // semantic action. That lookahead isn't needed before either error
362 // action is encountered. In a previous version of Bison, this was a
363 // problem as it meant yychar was not translated into yytoken before
364 // either error action. The second error action thus invoked a
365 // destructor that it selected according to the incorrect yytoken. The
366 // first error action would have reported an incorrect unexpected token
367 // except that, due to the bug described in the previous grammar, the
368 // unexpected token was not reported at all.
369 start: error-reduce consistent-error 'a' { USE ($][3); } ;
372 'a' 'a' consistent-reduction consistent-error 'a'
373 { USE (($][1, $][2, $][5)); }
378 consistent-reduction: /*empty*/ {
379 assert (yychar == YYEMPTY);
386 | /*empty*/ %prec 'a'
389 // Provide another context in which all rules are useful so that this
390 // test case looks a little more realistic.
391 start: 'b' consistent-error 'b' ;
393 m4_pushdef([AT_USER_ACTION_INPUT], [[aa]])
395 AT_CONSISTENT_ERRORS_CHECK([[]],
396 [AT_USER_ACTION_GRAMMAR],
397 [AT_USER_ACTION_INPUT],
399 AT_CONSISTENT_ERRORS_CHECK([[%glr-parser]],
400 [AT_USER_ACTION_GRAMMAR],
401 [AT_USER_ACTION_INPUT],
403 # No C++ or Java test because yychar cannot be manipulated by users.
405 AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]],
406 [AT_USER_ACTION_GRAMMAR],
407 [AT_USER_ACTION_INPUT],
410 # Canonical LR doesn't foresee the error for 'a'!
411 AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions accepting]],
412 [AT_USER_ACTION_GRAMMAR],
413 [AT_USER_ACTION_INPUT],
415 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type canonical-lr]],
416 [AT_USER_ACTION_GRAMMAR],
417 [AT_USER_ACTION_INPUT],
420 m4_popdef([AT_USER_ACTION_GRAMMAR])
421 m4_popdef([AT_USER_ACTION_INPUT])
423 m4_popdef([AT_CONSISTENT_ERRORS_CHECK])
429 ## ------------------------- ##
430 ## Unresolved SR Conflicts. ##
431 ## ------------------------- ##
433 AT_SETUP([Unresolved SR Conflicts])
435 AT_KEYWORDS([report])
440 exp: exp OP exp | NUM;
443 AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
444 [input.y: conflicts: 1 shift/reduce
447 # Check the contents of the report.
448 AT_CHECK([cat input.output], [],
449 [[State 5 conflicts: 1 shift/reduce
460 Terminals, with rules where they appear
468 Nonterminals, with rules where they appear
473 on left: 1 2, on right: 0 1
478 0 $accept: . exp $end
482 NUM shift, and go to state 1
491 $default reduce using rule 2 (exp)
496 0 $accept: exp . $end
499 $end shift, and go to state 3
500 OP shift, and go to state 4
505 0 $accept: exp $end .
516 NUM shift, and go to state 1
524 1 | exp OP exp . [$end, OP]
526 OP shift, and go to state 4
528 OP [reduce using rule 1 (exp)]
529 $default reduce using rule 1 (exp)
536 ## ----------------------- ##
537 ## Resolved SR Conflicts. ##
538 ## ----------------------- ##
540 AT_SETUP([Resolved SR Conflicts])
542 AT_KEYWORDS([report])
548 exp: exp OP exp | NUM;
551 AT_BISON_CHECK([-o input.c --report=all input.y])
553 # Check the contents of the report.
554 AT_CHECK([cat input.output], [],
563 Terminals, with rules where they appear
571 Nonterminals, with rules where they appear
576 on left: 1 2, on right: 0 1
581 0 $accept: . exp $end
585 NUM shift, and go to state 1
594 $default reduce using rule 2 (exp)
599 0 $accept: exp . $end
602 $end shift, and go to state 3
603 OP shift, and go to state 4
608 0 $accept: exp $end .
619 NUM shift, and go to state 1
627 1 | exp OP exp . [$end, OP]
629 $default reduce using rule 1 (exp)
631 Conflict between rule 1 and token OP resolved as reduce (%left OP).
637 ## ---------------------- ##
638 ## %precedence suffices. ##
639 ## ---------------------- ##
641 AT_SETUP([%precedence suffices])
648 "if" cond "then" stmt
649 | "if" cond "then" stmt "else" stmt
658 AT_BISON_CHECK([-o input.c input.y])
663 ## ------------------------------ ##
664 ## %precedence does not suffice. ##
665 ## ------------------------------ ##
667 AT_SETUP([%precedence does not suffice])
674 "if" cond "then" stmt
675 | "if" cond "then" stmt "else" stmt
685 AT_BISON_CHECK([-o input.c input.y], 0, [],
686 [[input.y: conflicts: 1 shift/reduce
687 input.y:12.3-18: warning: rule useless in parser due to conflicts: cond: cond "then" cond
693 ## -------------------------------- ##
694 ## Defaulted Conflicted Reduction. ##
695 ## -------------------------------- ##
697 # When there are RR conflicts, some rules are disabled. Usually it is
698 # simply displayed as:
700 # $end reduce using rule 3 (num)
701 # $end [reduce using rule 4 (id)]
703 # But when `reduce 3' is the default action, we'd produce:
705 # $end [reduce using rule 4 (id)]
706 # $default reduce using rule 3 (num)
708 # In this precise case (a reduction is masked by the default
709 # reduction), we make the `reduce 3' explicit:
711 # $end reduce using rule 3 (num)
712 # $end [reduce using rule 4 (id)]
713 # $default reduce using rule 3 (num)
715 # Maybe that's not the best display, but then, please propose something
718 AT_SETUP([Defaulted Conflicted Reduction])
719 AT_KEYWORDS([report])
729 AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
730 [[input.y: conflicts: 1 reduce/reduce
731 input.y:4.6-8: warning: rule useless in parser due to conflicts: id: '0'
734 # Check the contents of the report.
735 AT_CHECK([cat input.output], [],
736 [[Rules useless in parser due to conflicts
741 State 1 conflicts: 1 reduce/reduce
756 Terminals, with rules where they appear
763 Nonterminals, with rules where they appear
768 on left: 1 2, on right: 0
770 on left: 3, on right: 1
772 on left: 4, on right: 2
777 0 $accept: . exp $end
783 '0' shift, and go to state 1
795 $end reduce using rule 3 (num)
796 $end [reduce using rule 4 (id)]
797 $default reduce using rule 3 (num)
802 0 $accept: exp . $end
804 $end shift, and go to state 5
811 $default reduce using rule 1 (exp)
818 $default reduce using rule 2 (exp)
823 0 $accept: exp $end .
833 ## -------------------- ##
834 ## %expect not enough. ##
835 ## -------------------- ##
837 AT_SETUP([%expect not enough])
843 exp: exp OP exp | NUM;
846 AT_BISON_CHECK([-o input.c input.y], 1, [],
847 [input.y: conflicts: 1 shift/reduce
848 input.y: expected 0 shift/reduce conflicts
853 ## --------------- ##
855 ## --------------- ##
857 AT_SETUP([%expect right])
863 exp: exp OP exp | NUM;
866 AT_BISON_CHECK([-o input.c input.y])
870 ## ------------------ ##
871 ## %expect too much. ##
872 ## ------------------ ##
874 AT_SETUP([%expect too much])
880 exp: exp OP exp | NUM;
883 AT_BISON_CHECK([-o input.c input.y], 1, [],
884 [input.y: conflicts: 1 shift/reduce
885 input.y: expected 2 shift/reduce conflicts
890 ## ------------------------------- ##
891 ## %expect with reduce conflicts. ##
892 ## ------------------------------- ##
894 AT_SETUP([%expect with reduce conflicts])
899 program: a 'a' | a a;
903 AT_BISON_CHECK([-o input.c input.y], 1, [],
904 [input.y: conflicts: 1 reduce/reduce
905 input.y: expected 0 reduce/reduce conflicts
910 ## ------------------------- ##
911 ## %prec with user strings. ##
912 ## ------------------------- ##
914 AT_SETUP([%prec with user string])
923 AT_BISON_CHECK([-o input.c input.y])
927 ## -------------------------------- ##
928 ## %no-default-prec without %prec. ##
929 ## -------------------------------- ##
931 AT_SETUP([%no-default-prec without %prec])
947 AT_BISON_CHECK([-o input.c input.y], 0, [],
948 [[input.y: conflicts: 4 shift/reduce
953 ## ----------------------------- ##
954 ## %no-default-prec with %prec. ##
955 ## ----------------------------- ##
957 AT_SETUP([%no-default-prec with %prec])
973 AT_BISON_CHECK([-o input.c input.y])
977 ## --------------- ##
979 ## --------------- ##
981 AT_SETUP([%default-prec])
997 AT_BISON_CHECK([-o input.c input.y])
1001 ## ---------------------------------------------- ##
1002 ## Unreachable States After Conflict Resolution. ##
1003 ## ---------------------------------------------- ##
1005 AT_SETUP([[Unreachable States After Conflict Resolution]])
1007 # If conflict resolution makes states unreachable, remove those states, report
1008 # rules that are then unused, and don't report conflicts in those states. Test
1009 # what happens when a nonterminal becomes useless as a result of state removal
1010 # since that causes lalr.o's goto map to be rewritten.
1012 AT_DATA([[input.y]],
1018 start: resolved_conflict 'a' reported_conflicts 'a' ;
1020 /* S/R conflict resolved as reduce, so the state with item
1021 * (resolved_conflict: 'a' . unreachable1) and all it transition successors are
1022 * unreachable, and the associated production is useless. */
1028 /* S/R conflict that need not be reported since it is unreachable because of
1029 * the previous conflict resolution. Nonterminal unreachable1 and all its
1030 * productions are useless. */
1036 /* Likewise for a R/R conflict and nonterminal unreachable2. */
1039 /* Make sure remaining S/R and R/R conflicts are still reported correctly even
1040 * when their states are renumbered due to state removal. */
1049 AT_BISON_CHECK([[--report=all input.y]], 0, [],
1050 [[input.y: conflicts: 1 shift/reduce, 1 reduce/reduce
1051 input.y:12.5-20: warning: rule useless in parser due to conflicts: resolved_conflict: 'a' unreachable1
1052 input.y:20.5-20: warning: rule useless in parser due to conflicts: unreachable1: 'a' unreachable2
1053 input.y:21.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */
1054 input.y:25.13: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
1055 input.y:25.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
1056 input.y:31.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a'
1057 input.y:32.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */
1060 AT_CHECK([[cat input.output]], 0,
1061 [[Rules useless in parser due to conflicts
1063 2 resolved_conflict: 'a' unreachable1
1065 4 unreachable1: 'a' unreachable2
1068 6 unreachable2: /* empty */
1071 9 reported_conflicts: 'a'
1075 State 4 conflicts: 1 shift/reduce
1076 State 5 conflicts: 1 reduce/reduce
1081 0 $accept: start $end
1083 1 start: resolved_conflict 'a' reported_conflicts 'a'
1085 2 resolved_conflict: 'a' unreachable1
1088 4 unreachable1: 'a' unreachable2
1091 6 unreachable2: /* empty */
1094 8 reported_conflicts: 'a'
1099 Terminals, with rules where they appear
1106 Nonterminals, with rules where they appear
1111 on left: 1, on right: 0
1112 resolved_conflict (6)
1113 on left: 2 3, on right: 1
1115 on left: 4 5, on right: 2
1117 on left: 6 7, on right: 4
1118 reported_conflicts (9)
1119 on left: 8 9 10, on right: 1
1124 0 $accept: . start $end
1125 1 start: . resolved_conflict 'a' reported_conflicts 'a'
1126 2 resolved_conflict: . 'a' unreachable1
1129 $default reduce using rule 3 (resolved_conflict)
1132 resolved_conflict go to state 2
1134 Conflict between rule 3 and token 'a' resolved as reduce (%left 'a').
1139 0 $accept: start . $end
1141 $end shift, and go to state 3
1146 1 start: resolved_conflict . 'a' reported_conflicts 'a'
1148 'a' shift, and go to state 4
1153 0 $accept: start $end .
1160 1 start: resolved_conflict 'a' . reported_conflicts 'a'
1161 8 reported_conflicts: . 'a'
1165 'a' shift, and go to state 5
1167 'a' [reduce using rule 10 (reported_conflicts)]
1169 reported_conflicts go to state 6
1174 8 reported_conflicts: 'a' . ['a']
1177 'a' reduce using rule 8 (reported_conflicts)
1178 'a' [reduce using rule 9 (reported_conflicts)]
1179 $default reduce using rule 8 (reported_conflicts)
1184 1 start: resolved_conflict 'a' reported_conflicts . 'a'
1186 'a' shift, and go to state 7
1191 1 start: resolved_conflict 'a' reported_conflicts 'a' .
1193 $default reduce using rule 1 (start)
1196 AT_DATA([[input-keep.y]],
1197 [[%define lr.keep-unreachable-states
1199 AT_CHECK([[cat input.y >> input-keep.y]])
1201 AT_BISON_CHECK([[input-keep.y]], 0, [],
1202 [[input-keep.y: conflicts: 2 shift/reduce, 2 reduce/reduce
1203 input-keep.y:22.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */
1204 input-keep.y:26.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
1205 input-keep.y:32.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a'
1206 input-keep.y:33.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */
1212 ## ------------------------------------------------------------ ##
1213 ## Solved conflicts report for multiple reductions in a state. ##
1214 ## ------------------------------------------------------------ ##
1216 AT_SETUP([[Solved conflicts report for multiple reductions in a state]])
1218 # Used to lose earlier solved conflict messages even within a single S/R/R.
1220 AT_DATA([[input.y]],
1236 empty_a: %prec 'a' ;
1237 empty_b: %prec 'b' ;
1238 empty_c1: %prec 'c' ;
1239 empty_c2: %prec 'c' ;
1240 empty_c3: %prec 'd' ;
1242 AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore])
1243 AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
1246 0 $accept: . start $end
1259 13 empty_c3: . ['c']
1261 'b' shift, and go to state 1
1263 'c' reduce using rule 13 (empty_c3)
1264 $default reduce using rule 9 (empty_a)
1267 empty_a go to state 3
1268 empty_b go to state 4
1269 empty_c1 go to state 5
1270 empty_c2 go to state 6
1271 empty_c3 go to state 7
1273 Conflict between rule 9 and token 'a' resolved as reduce (%left 'a').
1274 Conflict between rule 10 and token 'b' resolved as shift (%right 'b').
1275 Conflict between rule 11 and token 'c' resolved as shift (%right 'c').
1276 Conflict between rule 12 and token 'c' resolved as shift (%right 'c').
1277 Conflict between rule 13 and token 'c' resolved as reduce ('c' < 'd').
1286 ## ------------------------------------------------------------ ##
1287 ## %nonassoc error actions for multiple reductions in a state. ##
1288 ## ------------------------------------------------------------ ##
1290 # Used to abort when trying to resolve conflicts as %nonassoc error actions for
1291 # multiple reductions in a state.
1293 # For a %nonassoc error action token, used to print the first remaining
1294 # reduction on that token without brackets.
1296 AT_SETUP([[%nonassoc error actions for multiple reductions in a state]])
1298 AT_DATA([[input.y]],
1299 [[%nonassoc 'a' 'b' 'c'
1311 empty_a: %prec 'a' ;
1312 empty_b: %prec 'b' ;
1313 empty_c1: %prec 'c' ;
1314 empty_c2: %prec 'c' ;
1315 empty_c3: %prec 'c' ;
1318 AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore])
1319 AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
1322 0 $accept: . start $end
1334 12 empty_c2: . ['c']
1335 13 empty_c3: . ['c']
1337 'a' error (nonassociative)
1338 'b' error (nonassociative)
1339 'c' error (nonassociative)
1341 'c' [reduce using rule 12 (empty_c2)]
1342 'c' [reduce using rule 13 (empty_c3)]
1345 empty_a go to state 2
1346 empty_b go to state 3
1347 empty_c1 go to state 4
1348 empty_c2 go to state 5
1349 empty_c3 go to state 6
1351 Conflict between rule 9 and token 'a' resolved as an error (%nonassoc 'a').
1352 Conflict between rule 10 and token 'b' resolved as an error (%nonassoc 'b').
1353 Conflict between rule 11 and token 'c' resolved as an error (%nonassoc 'c').