X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/064e42b0aca1db0ca84b06b01cac5a40f3016591..bb1c50d88b1032fc5f4c338a4038b4c5e8fe0de6:/tests/conflicts.at?ds=sidebyside diff --git a/tests/conflicts.at b/tests/conflicts.at index 8b04449c..8633d8d4 100644 --- a/tests/conflicts.at +++ b/tests/conflicts.at @@ -1,6 +1,6 @@ # Exercising Bison on conflicts. -*- Autotest -*- -# Copyright (C) 2002-2005, 2007-2012 Free Software Foundation, Inc. +# Copyright (C) 2002-2005, 2007-2013 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 @@ -18,6 +18,75 @@ AT_BANNER([[Conflicts.]]) +## ------------------------ ## +## Token declaration order. ## +## ------------------------ ## + +# This test checks that token are declared left to right when in a precedence +# statement. + +AT_SETUP([Token declaration order]) + +AT_BISON_OPTION_PUSHDEFS + +AT_DATA_GRAMMAR([[input.y]], +[[%code { + #include + ]AT_YYERROR_DECLARE[ + ]AT_YYLEX_DECLARE[ +} +%token A B C +%token D +%right E F G +%right H I +%right J +%left K +%left L M N +%nonassoc O P Q +%precedence R S T U +%precedence V W +%% +exp: A +%% +]AT_YYERROR_DEFINE[ +]AT_YYLEX_DEFINE[ +int main (void) +{ + assert (A < B); + assert (B < C); + assert (C < D); + assert (D < E); + assert (E < F); + assert (F < G); + assert (G < H); + assert (H < I); + assert (I < J); + assert (J < K); + assert (K < L); + assert (L < M); + assert (M < N); + assert (N < O); + assert (O < P); + assert (P < Q); + assert (Q < R); + assert (R < S); + assert (S < T); + assert (T < U); + assert (U < V); + assert (V < W); + return 0; +} +]]) + +AT_FULL_COMPILE([input]) + +AT_PARSER_CHECK([./input]) + +AT_BISON_OPTION_POPDEFS + +AT_CLEANUP + + ## ---------------- ## ## S/R in initial. ## ## ---------------- ## @@ -40,6 +109,12 @@ AT_BISON_CHECK([-o input.c input.y], 0, [], [[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */ [-Wother] ]]) +AT_BISON_CHECK([-fcaret -o input.c input.y], 0, [], +[[input.y:4.9: warning: rule useless in parser due to conflicts [-Wother] + e: 'e' | /* Nothing. */; + ^ +]]) + AT_CLEANUP @@ -215,30 +290,9 @@ public Object getLVal () /*-------. | main. | -`-------*/]AT_SKEL_JAVA_IF([[ - -class input -{ - public static void main (String args[]) throws IOException - { - YYParser p = new YYParser (); - p.parse (); - } -}]], [AT_SKEL_CC_IF([[ - -int -main (void) -{ - yy::parser parser; - return parser.parse (); -}]], [[ - -int -main (void) -{ - return yyparse (); -}]])])[ -]]) +`-------*/ +]AT_MAIN_DEFINE +]) AT_FULL_COMPILE([[input]]) @@ -486,13 +540,8 @@ reduce-nonassoc: %prec 'a'; %% ]AT_YYERROR_DEFINE[ ]AT_YYLEX_DEFINE(["aaa"])[ - -int -main (void) -{ - return yyparse (); -} -]]) +]AT_MAIN_DEFINE +]) AT_BISON_OPTION_POPDEFS # Show canonical LR's failure.