# Exercising Bison on conflicts. -*- Autotest -*-
-# Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2003, 2004, 2005, 2007, 2008, 2009 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
AT_COMPILE([input])
AT_PARSER_CHECK([./input '0<0'])
-# FIXME: This is an actual bug, but a new one, in the sense that
-# no one has ever spotted it! The messages are *wrong*: there should
-# be nothing there, it should be expected eof.
AT_PARSER_CHECK([./input '0<0<0'], [1], [],
- [syntax error, unexpected '<', expecting '<' or '>'
+ [syntax error, unexpected '<'
])
AT_PARSER_CHECK([./input '0>0'])
AT_PARSER_CHECK([./input '0>0>0'], [1], [],
- [syntax error, unexpected '>', expecting '<' or '>'
+ [syntax error, unexpected '>'
])
AT_PARSER_CHECK([./input '0<0>0'], [1], [],
- [syntax error, unexpected '>', expecting '<' or '>'
+ [syntax error, unexpected '>'
+])
+
+# We must disable default reductions in inconsistent states in order to
+# have an explicit list of all expected tokens. (However, unless we use
+# canonical LR, lookahead sets are merged for different left contexts,
+# so it is still possible to have extra incorrect tokens in the expected
+# list. That just doesn't happen to be a problem for this test case.)
+
+AT_BISON_CHECK([-Dlr.default-reductions=consistent -o input.c input.y])
+AT_COMPILE([input])
+
+AT_PARSER_CHECK([./input '0<0'])
+AT_PARSER_CHECK([./input '0<0<0'], [1], [],
+ [syntax error, unexpected '<', expecting $end
+])
+
+AT_PARSER_CHECK([./input '0>0'])
+AT_PARSER_CHECK([./input '0>0>0'], [1], [],
+ [syntax error, unexpected '>', expecting $end
+])
+
+AT_PARSER_CHECK([./input '0<0>0'], [1], [],
+ [syntax error, unexpected '>', expecting $end
])
AT_CLEANUP
AT_CLEANUP
-## ------------------------------ ##
-## %expect with reduce conflicts ##
-## ------------------------------ ##
+## ------------------------------- ##
+## %expect with reduce conflicts. ##
+## ------------------------------- ##
AT_SETUP([%expect with reduce conflicts])
AT_CLEANUP
-## ------------------------------- ##
-## %no-default-prec without %prec ##
-## ------------------------------- ##
+## ------------------------- ##
+## %prec with user strings. ##
+## ------------------------- ##
+
+AT_SETUP([%prec with user string])
+
+AT_DATA([[input.y]],
+[[%%
+exp:
+ "foo" %prec "foo"
+;
+]])
+
+AT_BISON_CHECK([-o input.c input.y])
+AT_CLEANUP
+
+
+## -------------------------------- ##
+## %no-default-prec without %prec. ##
+## -------------------------------- ##
AT_SETUP([%no-default-prec without %prec])
AT_CLEANUP
-## ---------------------------- ##
-## %no-default-prec with %prec ##
-## ---------------------------- ##
+## ----------------------------- ##
+## %no-default-prec with %prec. ##
+## ----------------------------- ##
AT_SETUP([%no-default-prec with %prec])
AT_CLEANUP
-## ---------------- ##
-## %default-prec ##
-## ---------------- ##
+## --------------- ##
+## %default-prec. ##
+## --------------- ##
AT_SETUP([%default-prec])
]])
AT_DATA([[input-keep.y]],
-[[%define lr.keep_unreachable_states
+[[%define lr.keep-unreachable-states
]])
AT_CHECK([[cat input.y >> input-keep.y]])