1 # Exercising Bison on conflicts. -*- Autotest -*-
3 # Copyright (C) 2002, 2003, 2004, 2005, 2007, 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 ## %error-verbose and consistent errors. ##
144 ## -------------------------------------- ##
146 AT_SETUP([[%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([[
165 #include <string>]], [[
168 void yyerror (char const *msg);]])[
169 ]AT_YYLEX_PROTOTYPE[;
173 ]AT_SKEL_CC_IF([[%defines]], [[%define api.pure]])])[
183 ]AT_SKEL_JAVA_IF([[%code lexer {]], [[%%]])[
187 `--------*/]AT_SKEL_JAVA_IF([[
189 public String input = "]$3[";
190 public int index = 0;
193 if (index < input.length ())
194 return input.charAt (index++);
198 public Object getLVal ()
200 return new Integer(1);
205 static char const *input = "]$3[";
212 `----------*/]AT_SKEL_JAVA_IF([[
214 public void yyerror (String msg)
216 System.err.println (msg);
221 %%]], [AT_SKEL_CC_IF([[
224 yy::parser::error (const yy::location &, std::string const &msg)
226 std::cerr << msg << std::endl;
230 yyerror (char const *msg)
232 fprintf (stderr, "%s\n", msg);
237 `-------*/]AT_SKEL_JAVA_IF([[
241 public static void main (String args[]) throws IOException
243 YYParser p = new YYParser ();
246 }]], [AT_SKEL_CC_IF([[
252 return parser.parse ();
262 AT_FULL_COMPILE([[input]])
264 m4_pushdef([AT_EXPECTING], [m4_if($5, [ab], [[, expecting 'a' or 'b']],
265 $5, [a], [[, expecting 'a']],
266 $5, [b], [[, expecting 'b']])])
268 AT_SKEL_JAVA_IF([AT_JAVA_PARSER_CHECK([[input]], [[0]]],
269 [AT_PARSER_CHECK([[./input]], [[1]]]),
271 [[syntax error, unexpected ]$4[]AT_EXPECTING[
274 m4_popdef([AT_EXPECTING])
275 m4_popdef([AT_YYLEX_PROTOTYPE])
276 AT_BISON_OPTION_POPDEFS
280 m4_pushdef([AT_PREVIOUS_STATE_GRAMMAR],
283 start: consistent-error-on-a-a 'a' ;
285 consistent-error-on-a-a:
286 'a' default-reduction
287 | 'a' default-reduction 'a'
291 default-reduction: /*empty*/ ;
294 // Provide another context in which all rules are useful so that this
295 // test case looks a little more realistic.
296 start: 'b' consistent-error-on-a-a 'c' ;
299 m4_pushdef([AT_PREVIOUS_STATE_INPUT], [[a]])
301 # Unfortunately, no expected tokens are reported even though 'b' can be
302 # accepted. Nevertheless, the main point of this test is to make sure
303 # that at least the unexpected token is reported. In a previous version
304 # of Bison, it wasn't reported because the error is detected in a
305 # consistent state with an error action, and that case always triggered
306 # the simple "syntax error" message.
308 # The point isn't to test IELR here, but state merging happens to
309 # complicate this example.
310 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr]],
311 [AT_PREVIOUS_STATE_GRAMMAR],
312 [AT_PREVIOUS_STATE_INPUT],
314 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
316 [AT_PREVIOUS_STATE_GRAMMAR],
317 [AT_PREVIOUS_STATE_INPUT],
319 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
321 [AT_PREVIOUS_STATE_GRAMMAR],
322 [AT_PREVIOUS_STATE_INPUT],
324 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
326 [AT_PREVIOUS_STATE_GRAMMAR],
327 [AT_PREVIOUS_STATE_INPUT],
328 [[end of input]], [[none]])
330 # Even canonical LR doesn't foresee the error for 'a'!
331 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
332 %define lr.default-reductions consistent]],
333 [AT_PREVIOUS_STATE_GRAMMAR],
334 [AT_PREVIOUS_STATE_INPUT],
336 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr
337 %define lr.default-reductions accepting]],
338 [AT_PREVIOUS_STATE_GRAMMAR],
339 [AT_PREVIOUS_STATE_INPUT],
341 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type canonical-lr]],
342 [AT_PREVIOUS_STATE_GRAMMAR],
343 [AT_PREVIOUS_STATE_INPUT],
346 m4_popdef([AT_PREVIOUS_STATE_GRAMMAR])
347 m4_popdef([AT_PREVIOUS_STATE_INPUT])
349 m4_pushdef([AT_USER_ACTION_GRAMMAR],
352 // If $$ = 0 here, then we know that the 'a' destructor is being invoked
353 // incorrectly for the 'b' set in the semantic action below. All 'a'
354 // tokens are returned by yylex, which sets $$ = 1.
357 fprintf (stderr, "Wrong destructor.\n");
360 // Rather than depend on an inconsistent state to induce reading a
361 // lookahead as in the previous grammar, just assign the lookahead in a
362 // semantic action. That lookahead isn't needed before either error
363 // action is encountered. In a previous version of Bison, this was a
364 // problem as it meant yychar was not translated into yytoken before
365 // either error action. The second error action thus invoked a
366 // destructor that it selected according to the incorrect yytoken. The
367 // first error action would have reported an incorrect unexpected token
368 // except that, due to the bug described in the previous grammar, the
369 // unexpected token was not reported at all.
370 start: error-reduce consistent-error 'a' { USE ($][3); } ;
373 'a' 'a' consistent-reduction consistent-error 'a'
374 { USE (($][1, $][2, $][5)); }
379 consistent-reduction: /*empty*/ {
380 assert (yychar == ]AT_SKEL_CC_IF([[yyempty_]], [[YYEMPTY]])[);
387 | /*empty*/ %prec 'a'
390 // Provide another context in which all rules are useful so that this
391 // test case looks a little more realistic.
392 start: 'b' consistent-error 'b' ;
394 m4_pushdef([AT_USER_ACTION_INPUT], [[aa]])
396 AT_CONSISTENT_ERRORS_CHECK([[]],
397 [AT_USER_ACTION_GRAMMAR],
398 [AT_USER_ACTION_INPUT],
400 AT_CONSISTENT_ERRORS_CHECK([[%glr-parser]],
401 [AT_USER_ACTION_GRAMMAR],
402 [AT_USER_ACTION_INPUT],
404 AT_CONSISTENT_ERRORS_CHECK([[%language "c++"]],
405 [AT_USER_ACTION_GRAMMAR],
406 [AT_USER_ACTION_INPUT],
408 # No Java test because yychar cannot be manipulated by users.
410 AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]],
411 [AT_USER_ACTION_GRAMMAR],
412 [AT_USER_ACTION_INPUT],
415 # Canonical LR doesn't foresee the error for 'a'!
416 AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions accepting]],
417 [AT_USER_ACTION_GRAMMAR],
418 [AT_USER_ACTION_INPUT],
420 AT_CONSISTENT_ERRORS_CHECK([[%define lr.type canonical-lr]],
421 [AT_USER_ACTION_GRAMMAR],
422 [AT_USER_ACTION_INPUT],
425 m4_popdef([AT_USER_ACTION_GRAMMAR])
426 m4_popdef([AT_USER_ACTION_INPUT])
428 m4_popdef([AT_CONSISTENT_ERRORS_CHECK])
434 ## ------------------------- ##
435 ## Unresolved SR Conflicts. ##
436 ## ------------------------- ##
438 AT_SETUP([Unresolved SR Conflicts])
440 AT_KEYWORDS([report])
445 exp: exp OP exp | NUM;
448 AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
449 [input.y: conflicts: 1 shift/reduce
452 # Check the contents of the report.
453 AT_CHECK([cat input.output], [],
454 [[State 5 conflicts: 1 shift/reduce
465 Terminals, with rules where they appear
473 Nonterminals, with rules where they appear
478 on left: 1 2, on right: 0 1
483 0 $accept: . exp $end
487 NUM shift, and go to state 1
496 $default reduce using rule 2 (exp)
501 0 $accept: exp . $end
504 $end shift, and go to state 3
505 OP shift, and go to state 4
510 0 $accept: exp $end .
521 NUM shift, and go to state 1
529 1 | exp OP exp . [$end, OP]
531 OP shift, and go to state 4
533 OP [reduce using rule 1 (exp)]
534 $default reduce using rule 1 (exp)
541 ## ----------------------- ##
542 ## Resolved SR Conflicts. ##
543 ## ----------------------- ##
545 AT_SETUP([Resolved SR Conflicts])
547 AT_KEYWORDS([report])
553 exp: exp OP exp | NUM;
556 AT_BISON_CHECK([-o input.c --report=all input.y])
558 # Check the contents of the report.
559 AT_CHECK([cat input.output], [],
568 Terminals, with rules where they appear
576 Nonterminals, with rules where they appear
581 on left: 1 2, on right: 0 1
586 0 $accept: . exp $end
590 NUM shift, and go to state 1
599 $default reduce using rule 2 (exp)
604 0 $accept: exp . $end
607 $end shift, and go to state 3
608 OP shift, and go to state 4
613 0 $accept: exp $end .
624 NUM shift, and go to state 1
632 1 | exp OP exp . [$end, OP]
634 $default reduce using rule 1 (exp)
636 Conflict between rule 1 and token OP resolved as reduce (%left OP).
642 ## -------------------------------- ##
643 ## Defaulted Conflicted Reduction. ##
644 ## -------------------------------- ##
646 # When there are RR conflicts, some rules are disabled. Usually it is
647 # simply displayed as:
649 # $end reduce using rule 3 (num)
650 # $end [reduce using rule 4 (id)]
652 # But when `reduce 3' is the default action, we'd produce:
654 # $end [reduce using rule 4 (id)]
655 # $default reduce using rule 3 (num)
657 # In this precise case (a reduction is masked by the default
658 # reduction), we make the `reduce 3' explicit:
660 # $end reduce using rule 3 (num)
661 # $end [reduce using rule 4 (id)]
662 # $default reduce using rule 3 (num)
664 # Maybe that's not the best display, but then, please propose something
667 AT_SETUP([Defaulted Conflicted Reduction])
668 AT_KEYWORDS([report])
678 AT_BISON_CHECK([-o input.c --report=all input.y], 0, [],
679 [[input.y: conflicts: 1 reduce/reduce
680 input.y:4.6-8: warning: rule useless in parser due to conflicts: id: '0'
683 # Check the contents of the report.
684 AT_CHECK([cat input.output], [],
685 [[Rules useless in parser due to conflicts
690 State 1 conflicts: 1 reduce/reduce
705 Terminals, with rules where they appear
712 Nonterminals, with rules where they appear
717 on left: 1 2, on right: 0
719 on left: 3, on right: 1
721 on left: 4, on right: 2
726 0 $accept: . exp $end
732 '0' shift, and go to state 1
744 $end reduce using rule 3 (num)
745 $end [reduce using rule 4 (id)]
746 $default reduce using rule 3 (num)
751 0 $accept: exp . $end
753 $end shift, and go to state 5
760 $default reduce using rule 1 (exp)
767 $default reduce using rule 2 (exp)
772 0 $accept: exp $end .
782 ## -------------------- ##
783 ## %expect not enough. ##
784 ## -------------------- ##
786 AT_SETUP([%expect not enough])
792 exp: exp OP exp | NUM;
795 AT_BISON_CHECK([-o input.c input.y], 1, [],
796 [input.y: conflicts: 1 shift/reduce
797 input.y: expected 0 shift/reduce conflicts
802 ## --------------- ##
804 ## --------------- ##
806 AT_SETUP([%expect right])
812 exp: exp OP exp | NUM;
815 AT_BISON_CHECK([-o input.c input.y])
819 ## ------------------ ##
820 ## %expect too much. ##
821 ## ------------------ ##
823 AT_SETUP([%expect too much])
829 exp: exp OP exp | NUM;
832 AT_BISON_CHECK([-o input.c input.y], 1, [],
833 [input.y: conflicts: 1 shift/reduce
834 input.y: expected 2 shift/reduce conflicts
839 ## ------------------------------- ##
840 ## %expect with reduce conflicts. ##
841 ## ------------------------------- ##
843 AT_SETUP([%expect with reduce conflicts])
848 program: a 'a' | a a;
852 AT_BISON_CHECK([-o input.c input.y], 1, [],
853 [input.y: conflicts: 1 reduce/reduce
854 input.y: expected 0 reduce/reduce conflicts
859 ## ------------------------- ##
860 ## %prec with user strings. ##
861 ## ------------------------- ##
863 AT_SETUP([%prec with user string])
872 AT_BISON_CHECK([-o input.c input.y])
876 ## -------------------------------- ##
877 ## %no-default-prec without %prec. ##
878 ## -------------------------------- ##
880 AT_SETUP([%no-default-prec without %prec])
896 AT_BISON_CHECK([-o input.c input.y], 0, [],
897 [[input.y: conflicts: 4 shift/reduce
902 ## ----------------------------- ##
903 ## %no-default-prec with %prec. ##
904 ## ----------------------------- ##
906 AT_SETUP([%no-default-prec with %prec])
922 AT_BISON_CHECK([-o input.c input.y])
926 ## --------------- ##
928 ## --------------- ##
930 AT_SETUP([%default-prec])
946 AT_BISON_CHECK([-o input.c input.y])
950 ## ---------------------------------------------- ##
951 ## Unreachable States After Conflict Resolution. ##
952 ## ---------------------------------------------- ##
954 AT_SETUP([[Unreachable States After Conflict Resolution]])
956 # If conflict resolution makes states unreachable, remove those states, report
957 # rules that are then unused, and don't report conflicts in those states. Test
958 # what happens when a nonterminal becomes useless as a result of state removal
959 # since that causes lalr.o's goto map to be rewritten.
967 start: resolved_conflict 'a' reported_conflicts 'a' ;
969 /* S/R conflict resolved as reduce, so the state with item
970 * (resolved_conflict: 'a' . unreachable1) and all it transition successors are
971 * unreachable, and the associated production is useless. */
977 /* S/R conflict that need not be reported since it is unreachable because of
978 * the previous conflict resolution. Nonterminal unreachable1 and all its
979 * productions are useless. */
985 /* Likewise for a R/R conflict and nonterminal unreachable2. */
988 /* Make sure remaining S/R and R/R conflicts are still reported correctly even
989 * when their states are renumbered due to state removal. */
998 AT_BISON_CHECK([[--report=all input.y]], 0, [],
999 [[input.y: conflicts: 1 shift/reduce, 1 reduce/reduce
1000 input.y:12.5-20: warning: rule useless in parser due to conflicts: resolved_conflict: 'a' unreachable1
1001 input.y:20.5-20: warning: rule useless in parser due to conflicts: unreachable1: 'a' unreachable2
1002 input.y:21.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */
1003 input.y:25.13: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
1004 input.y:25.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
1005 input.y:31.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a'
1006 input.y:32.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */
1009 AT_CHECK([[cat input.output]], 0,
1010 [[Rules useless in parser due to conflicts
1012 2 resolved_conflict: 'a' unreachable1
1014 4 unreachable1: 'a' unreachable2
1017 6 unreachable2: /* empty */
1020 9 reported_conflicts: 'a'
1024 State 4 conflicts: 1 shift/reduce
1025 State 5 conflicts: 1 reduce/reduce
1030 0 $accept: start $end
1032 1 start: resolved_conflict 'a' reported_conflicts 'a'
1034 2 resolved_conflict: 'a' unreachable1
1037 4 unreachable1: 'a' unreachable2
1040 6 unreachable2: /* empty */
1043 8 reported_conflicts: 'a'
1048 Terminals, with rules where they appear
1055 Nonterminals, with rules where they appear
1060 on left: 1, on right: 0
1061 resolved_conflict (6)
1062 on left: 2 3, on right: 1
1064 on left: 4 5, on right: 2
1066 on left: 6 7, on right: 4
1067 reported_conflicts (9)
1068 on left: 8 9 10, on right: 1
1073 0 $accept: . start $end
1074 1 start: . resolved_conflict 'a' reported_conflicts 'a'
1075 2 resolved_conflict: . 'a' unreachable1
1078 $default reduce using rule 3 (resolved_conflict)
1081 resolved_conflict go to state 2
1083 Conflict between rule 3 and token 'a' resolved as reduce (%left 'a').
1088 0 $accept: start . $end
1090 $end shift, and go to state 3
1095 1 start: resolved_conflict . 'a' reported_conflicts 'a'
1097 'a' shift, and go to state 4
1102 0 $accept: start $end .
1109 1 start: resolved_conflict 'a' . reported_conflicts 'a'
1110 8 reported_conflicts: . 'a'
1114 'a' shift, and go to state 5
1116 'a' [reduce using rule 10 (reported_conflicts)]
1118 reported_conflicts go to state 6
1123 8 reported_conflicts: 'a' . ['a']
1126 'a' reduce using rule 8 (reported_conflicts)
1127 'a' [reduce using rule 9 (reported_conflicts)]
1128 $default reduce using rule 8 (reported_conflicts)
1133 1 start: resolved_conflict 'a' reported_conflicts . 'a'
1135 'a' shift, and go to state 7
1140 1 start: resolved_conflict 'a' reported_conflicts 'a' .
1142 $default reduce using rule 1 (start)
1145 AT_DATA([[input-keep.y]],
1146 [[%define lr.keep-unreachable-states
1148 AT_CHECK([[cat input.y >> input-keep.y]])
1150 AT_BISON_CHECK([[input-keep.y]], 0, [],
1151 [[input-keep.y: conflicts: 2 shift/reduce, 2 reduce/reduce
1152 input-keep.y:22.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */
1153 input-keep.y:26.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */
1154 input-keep.y:32.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a'
1155 input-keep.y:33.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */
1161 ## ------------------------------------------------------------ ##
1162 ## Solved conflicts report for multiple reductions in a state. ##
1163 ## ------------------------------------------------------------ ##
1165 AT_SETUP([[Solved conflicts report for multiple reductions in a state]])
1167 # Used to lose earlier solved conflict messages even within a single S/R/R.
1169 AT_DATA([[input.y]],
1185 empty_a: %prec 'a' ;
1186 empty_b: %prec 'b' ;
1187 empty_c1: %prec 'c' ;
1188 empty_c2: %prec 'c' ;
1189 empty_c3: %prec 'd' ;
1191 AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore])
1192 AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
1195 0 $accept: . start $end
1208 13 empty_c3: . ['c']
1210 'b' shift, and go to state 1
1212 'c' reduce using rule 13 (empty_c3)
1213 $default reduce using rule 9 (empty_a)
1216 empty_a go to state 3
1217 empty_b go to state 4
1218 empty_c1 go to state 5
1219 empty_c2 go to state 6
1220 empty_c3 go to state 7
1222 Conflict between rule 9 and token 'a' resolved as reduce (%left 'a').
1223 Conflict between rule 10 and token 'b' resolved as shift (%right 'b').
1224 Conflict between rule 11 and token 'c' resolved as shift (%right 'c').
1225 Conflict between rule 12 and token 'c' resolved as shift (%right 'c').
1226 Conflict between rule 13 and token 'c' resolved as reduce ('c' < 'd').
1235 ## ------------------------------------------------------------ ##
1236 ## %nonassoc error actions for multiple reductions in a state. ##
1237 ## ------------------------------------------------------------ ##
1239 # Used to abort when trying to resolve conflicts as %nonassoc error actions for
1240 # multiple reductions in a state.
1242 # For a %nonassoc error action token, used to print the first remaining
1243 # reduction on that token without brackets.
1245 AT_SETUP([[%nonassoc error actions for multiple reductions in a state]])
1247 AT_DATA([[input.y]],
1248 [[%nonassoc 'a' 'b' 'c'
1260 empty_a: %prec 'a' ;
1261 empty_b: %prec 'b' ;
1262 empty_c1: %prec 'c' ;
1263 empty_c2: %prec 'c' ;
1264 empty_c3: %prec 'c' ;
1267 AT_BISON_CHECK([[--report=all -o input.c input.y]], 0, [], [ignore])
1268 AT_CHECK([[cat input.output | sed -n '/^state 0$/,/^state 1$/p']], 0,
1271 0 $accept: . start $end
1283 12 empty_c2: . ['c']
1284 13 empty_c3: . ['c']
1286 'a' error (nonassociative)
1287 'b' error (nonassociative)
1288 'c' error (nonassociative)
1290 'c' [reduce using rule 12 (empty_c2)]
1291 'c' [reduce using rule 13 (empty_c3)]
1294 empty_a go to state 2
1295 empty_b go to state 3
1296 empty_c1 go to state 4
1297 empty_c2 go to state 5
1298 empty_c3 go to state 6
1300 Conflict between rule 9 and token 'a' resolved as an error (%nonassoc 'a').
1301 Conflict between rule 10 and token 'b' resolved as an error (%nonassoc 'b').
1302 Conflict between rule 11 and token 'c' resolved as an error (%nonassoc 'c').