diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/.gitignore | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 107 | ||||
-rw-r--r-- | tests/actions.at | 220 | ||||
-rw-r--r-- | tests/atlocal.in | 12 | ||||
-rw-r--r-- | tests/bison.in | 7 | ||||
-rw-r--r-- | tests/c++.at | 368 | ||||
-rw-r--r-- | tests/calc.at | 103 | ||||
-rw-r--r-- | tests/conflicts.at | 260 | ||||
-rw-r--r-- | tests/existing.at | 1974 | ||||
-rw-r--r-- | tests/glr-regression.at | 74 | ||||
-rw-r--r-- | tests/headers.at | 11 | ||||
-rw-r--r-- | tests/input.at | 507 | ||||
-rw-r--r-- | tests/java.at | 190 | ||||
-rw-r--r-- | tests/local.at | 143 | ||||
-rw-r--r-- | tests/local.mk | 125 | ||||
-rw-r--r-- | tests/named-refs.at | 16 | ||||
-rw-r--r-- | tests/output.at | 132 | ||||
-rw-r--r-- | tests/reduce.at | 118 | ||||
-rw-r--r-- | tests/regression.at | 109 | ||||
-rw-r--r-- | tests/sets.at | 20 | ||||
-rw-r--r-- | tests/skeletons.at | 6 | ||||
-rw-r--r-- | tests/testsuite.at | 2 |
22 files changed, 2643 insertions, 1864 deletions
diff --git a/tests/.gitignore b/tests/.gitignore index 0d5d32c6..70ae9c31 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -7,9 +7,6 @@ /calc /calc.[chy] /calc.tab.* -/Makefile -/Makefile.in -/Makefile.in /package.m4 /testsuite /testsuite.dir diff --git a/tests/Makefile.am b/tests/Makefile.am deleted file mode 100644 index b6848d77..00000000 --- a/tests/Makefile.am +++ /dev/null @@ -1,107 +0,0 @@ -## Process this file with automake to create Makefile.in. - -## Makefile for Bison testsuite. - -## Copyright (C) 2000-2012 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 -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -EXTRA_DIST = $(TESTSUITE_AT) testsuite package.m4 - -DISTCLEANFILES = atconfig $(check_SCRIPTS) -MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE) - -## ------------ ## -## package.m4. ## -## ------------ ## - -$(srcdir)/package.m4: $(top_srcdir)/configure - $(AM_V_GEN) { \ - echo '# Signature of the current package.'; \ - echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \ - echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \ - echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \ - echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \ - echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \ - } >$@.tmp - $(AM_V_at) mv $@.tmp $@ - -## ------------ ## -## Test suite. ## -## ------------ ## - -TESTSUITE_AT = \ - local.at \ - testsuite.at \ - input.at named-refs.at \ - output.at skeletons.at sets.at reduce.at \ - synclines.at headers.at actions.at conflicts.at \ - calc.at \ - torture.at existing.at regression.at \ - c++.at \ - java.at \ - cxx-type.at glr-regression.at \ - push.at - -TESTSUITE = $(srcdir)/testsuite - -AUTOTEST = $(AUTOM4TE) --language=autotest -$(TESTSUITE): $(srcdir)/package.m4 $(TESTSUITE_AT) - $(AM_V_GEN) $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp - $(AM_V_at) mv $@.tmp $@ - -atconfig: $(top_builddir)/config.status - cd $(top_builddir) && ./config.status tests/$@ - -clean-local: - test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean - -check-local: atconfig atlocal $(TESTSUITE) - $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS) - -check_SCRIPTS = bison - -# Run the test suite on the *installed* tree. -installcheck-local: atconfig atlocal $(TESTSUITE) - $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS) - -# Be real mean with it. -.PHONY: maintainer-check-g++ -maintainer-check-g++: atconfig atlocal $(TESTSUITE) - $(TESTSUITE) $(TESTSUITEFLAGS) --compile-c-with-cxx - -.PHONY: maintainer-check-posix -maintainer-check-posix: atconfig atlocal $(TESTSUITE) - $(TESTSUITE) $(TESTSUITEFLAGS) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112 - -.PHONY: maintainer-check-valgrind -maintainer-check-valgrind: atconfig atlocal $(TESTSUITE) - test -z '$(VALGRIND)' || \ - $(TESTSUITE) $(TESTSUITEFLAGS) \ - PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \ - VALGRIND_OPTS='--leak-check=full --show-reachable=yes' - -.PHONY: maintainer-check -maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++ - -.PHONY: maintainer-push-check -maintainer-push-check: - BISON_USE_PUSH_FOR_PULL=1 $(MAKE) $(AM_MAKEFLAGS) maintainer-check - -.PHONY: maintainer-xml-check -maintainer-xml-check: - BISON_TEST_XML=1 $(MAKE) $(AM_MAKEFLAGS) maintainer-check - -.PHONY: maintainer-release-check -maintainer-release-check: maintainer-check maintainer-push-check maintainer-xml-check diff --git a/tests/actions.at b/tests/actions.at index 1ec8ef9a..4b0019b8 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1,4 +1,4 @@ -# Executing Actions. -*- Autotest -*- +e# Executing Actions. -*- Autotest -*- # Copyright (C) 2001-2012 Free Software Foundation, Inc. @@ -30,7 +30,7 @@ AT_SETUP([Mid-rule actions]) AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([[input.y]], -[[%error-verbose +[[%define parse.error verbose %debug %{ ]AT_YYERROR_DECLARE[ @@ -80,7 +80,7 @@ AT_SETUP([Exotic Dollars]) AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([[input.y]], -[[%error-verbose +[[%define parse.error verbose %debug %{ ]AT_YYERROR_DECLARE[ @@ -136,7 +136,7 @@ AT_PARSER_CHECK([./input], 0, AT_DATA_GRAMMAR([[input.y]], [[ %{ -#include <stdio.h> +# include <stdio.h> ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ typedef struct { int val; } stype; @@ -264,7 +264,7 @@ input: V(input, $$, @$, ": /* Nothing */\n"); } | line input /* Right recursive to load the stack so that popping at - END can be exercised. */ + END can be exercised. */ { $$ = 2; V(input, $$, @$, ": "); @@ -561,7 +561,7 @@ m4_define([AT_CHECK_PRINTER_AND_DESTRUCTOR], $3 _AT_CHECK_PRINTER_AND_DESTRUCTOR($[1], $[2], $[3], $[4], -[%error-verbose +[%define parse.error verbose %debug %verbose %locations @@ -592,7 +592,7 @@ AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union]) AT_SETUP([Default tagless %printer and %destructor]) AT_BISON_OPTION_PUSHDEFS([%locations]) AT_DATA_GRAMMAR([[input.y]], -[[%error-verbose +[[%define parse.error verbose %debug %locations %initial-action { @@ -646,7 +646,10 @@ main (void) } ]]) -AT_BISON_CHECK([-o input.c input.y]) +AT_BISON_CHECK([-o input.c input.y], [], [], +[[input.y:27.3-5: warning: useless %destructor for type <*> [-Wother] +input.y:27.3-5: warning: useless %printer for type <*> [-Wother] +]]) AT_COMPILE([input]) AT_PARSER_CHECK([./input], 1, [[<> destructor for 'd' @ 4. @@ -694,7 +697,7 @@ AT_CLEANUP AT_SETUP([Default tagged and per-type %printer and %destructor]) AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([[input.y]], -[[%error-verbose +[[%define parse.error verbose %debug %{ @@ -758,7 +761,10 @@ main (void) } ]]) -AT_BISON_CHECK([-o input.c input.y]) +AT_BISON_CHECK([-o input.c input.y], [], [], +[[input.y:22.3-4: warning: useless %destructor for type <> [-Wother] +input.y:22.3-4: warning: useless %printer for type <> [-Wother] +]]) AT_COMPILE([input]) AT_PARSER_CHECK([./input], 1, [[<*>/<field2>/e destructor. @@ -817,16 +823,16 @@ AT_CLEANUP AT_SETUP([Default %printer and %destructor for user-defined end token]) -# _AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(TYPED) -# ------------------------------------------------------------- -m4_define([_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN], +# AT_TEST(TYPED) +# -------------- +m4_pushdef([AT_TEST], [m4_if($1, 0, [m4_pushdef([kind], []) m4_pushdef([not_kind], [*])], [m4_pushdef([kind], [*]) m4_pushdef([not_kind], [])]) AT_BISON_OPTION_PUSHDEFS([%locations]) AT_DATA_GRAMMAR([[input]]$1[[.y]], -[[%error-verbose +[[%define parse.error verbose %debug %locations %initial-action { @@ -891,8 +897,17 @@ main (void) ]]) AT_BISON_OPTION_POPDEFS -AT_BISON_CHECK([-o input$1.c input$1.y]) +AT_BISON_CHECK([-o input$1.c input$1.y], [], [], +[m4_if([$1], [0], +[[input0.y:27.3-5: warning: useless %destructor for type <*> [-Wother] +input0.y:27.3-5: warning: useless %printer for type <*> [-Wother] +]], +[[input1.y:27.3-4: warning: useless %destructor for type <> [-Wother] +input1.y:27.3-4: warning: useless %printer for type <> [-Wother] +]])]) + AT_COMPILE([input$1]) + AT_PARSER_CHECK([./input$1], 0, [[<]]kind[[> for 'E' @ 1. <]]kind[[> for 'S' @ 1. @@ -915,8 +930,10 @@ m4_popdef([kind]) m4_popdef([not_kind]) ]) -_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(0) -_AT_CHECK_DEFAULT_PRINTER_AND_DESTRUCTOR_FOR_END_TOKEN(1) +AT_TEST(0) +AT_TEST(1) + +m4_popdef([AT_TEST]) AT_CLEANUP @@ -976,7 +993,10 @@ main (void) ]]) AT_BISON_OPTION_POPDEFS -AT_BISON_CHECK([-o input.c input.y]) +AT_BISON_CHECK([-o input.c input.y], [], [], +[[input.y:21.6-8: warning: useless %destructor for type <*> [-Wother] +input.y:21.6-8: warning: useless %printer for type <*> [-Wother] +]]) AT_COMPILE([input]) AT_PARSER_CHECK([./input], [1], [], [[Starting parse @@ -1075,7 +1095,10 @@ main (void) ]]) AT_BISON_OPTION_POPDEFS -AT_BISON_CHECK([-o input.c input.y]) +AT_BISON_CHECK([-o input.c input.y], [], [], +[[input.y:22.3-4: warning: useless %destructor for type <> [-Wother] +input.y:22.3-4: warning: useless %printer for type <> [-Wother] +]]) AT_COMPILE([input]) AT_CLEANUP @@ -1132,8 +1155,10 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([-o input.c input.y], 0,, -[[input.y:33.3-23: warning: unset value: $$ -input.y:30.3-35.37: warning: unused value: $3 +[[input.y:24.70-72: warning: useless %destructor for type <*> [-Wother] +input.y:24.70-72: warning: useless %printer for type <*> [-Wother] +input.y:33.3-23: warning: unset value: $$ [-Wother] +input.y:30.3-35.37: warning: unused value: $3 [-Wother] ]]) AT_COMPILE([input]) @@ -1234,10 +1259,11 @@ AT_CHECK_ACTION_LOCATIONS([[%printer]]) ## Qualified $$ in actions. ## ## ------------------------- ## -# Check that we can used qualified $$ (v.g., $<type>$) not only in -# rule actions, but also where $$ is valid: %printer and %destructor. +# Check that we can use qualified $$ (v.g., $<type>$) not only in rule +# actions, but also where $$ is valid: %destructor/%printer and +# %initial-action. # -# FIXME: Not actually checking %desctructor, but it's the same code as +# FIXME: Not actually checking %destructor, but it's the same code as # %printer... # # To do that, use a semantic value that has two fields (sem_type), @@ -1248,12 +1274,10 @@ AT_CHECK_ACTION_LOCATIONS([[%printer]]) m4_pushdef([AT_TEST], [AT_SETUP([[Qualified $$ in actions: $1]]) -AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1"]) +AT_BISON_OPTION_PUSHDEFS([%skeleton "$1"]) AT_DATA_GRAMMAR([[input.y]], [[%skeleton "$1" -%defines // FIXME: Mandated by lalr1.cc in Bison 2.6. -%locations // FIXME: Mandated by lalr1.cc in Bison 2.6. %debug %code requires { @@ -1295,17 +1319,6 @@ AT_DATA_GRAMMAR([[input.y]], %printer { report (yyo, $<ival>$, $$ ); } <fval>; %printer { report (yyo, $<ival>$, $<fval>$); } <>; -]AT_SKEL_CC_IF([[ -/* The lalr1.cc skeleton, for backward compatibility, defines - a constructor for position that initializes the filename. The - glr.cc skeleton does not (and in fact cannot: location/position - are stored in a union, from which objects with constructors are - excluded in C++). */ -%initial-action { - @$.initialize (); -} -]])[ - %initial-action { $<ival>$ = 42; @@ -1340,10 +1353,7 @@ AT_FULL_COMPILE([[input]]) AT_PARSER_CHECK([./input], 0, [], [stderr]) # Don't be too picky on the traces, GLR is not exactly the same. Keep # only the lines from the printer. -# -# Don't care about locations. FIXME: remove their removal when Bison -# supports C++ without locations. -AT_CHECK([[sed -ne 's/([-0-9.]*: /(/;/ival:/p' stderr]], 0, +AT_CHECK([[sed -ne '/ival:/p' stderr]], 0, [[Reading a token: Next token is token UNTYPED (ival: 10, fval: 0.1) Shifting token UNTYPED (ival: 10, fval: 0.1) Reading a token: Next token is token INT (ival: 20, fval: 0.2) @@ -1381,37 +1391,37 @@ AT_DATA([input.y], start: test2 test1 test0 testc; test2 -: 'a' { semi; /* TEST:N:2 */ } -| 'b' { if (0) {no_semi} /* TEST:N:2 */ } -| 'c' { if (0) {semi;} /* TEST:N:2 */ } -| 'd' { semi; no_semi /* TEST:Y:2 */ } -| 'e' { semi(); no_semi() /* TEST:Y:2 */ } -| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ } -| 'g' { semi++; no_semi++ /* TEST:Y:2 */ } -| 'h' { {no_semi} no_semi /* TEST:Y:2 */ } -| 'i' { {semi;} no_semi /* TEST:Y:2 */ } +: 'a' { semi; /* TEST:N:2 */ } +| 'b' { if (0) {no_semi} /* TEST:N:2 */ } +| 'c' { if (0) {semi;} /* TEST:N:2 */ } +| 'd' { semi; no_semi /* TEST:Y:2 */ } +| 'e' { semi(); no_semi() /* TEST:Y:2 */ } +| 'f' { semi[]; no_semi[] /* TEST:Y:2 */ } +| 'g' { semi++; no_semi++ /* TEST:Y:2 */ } +| 'h' { {no_semi} no_semi /* TEST:Y:2 */ } +| 'i' { {semi;} no_semi /* TEST:Y:2 */ } ; test1 - : 'a' { semi; // TEST:N:1 ; -} | 'b' { if (0) {no_semi} // TEST:N:1 ; -} | 'c' { if (0) {semi;} // TEST:N:1 ; -} | 'd' { semi; no_semi // TEST:Y:1 ; -} | 'e' { semi(); no_semi() // TEST:Y:1 ; -} | 'f' { semi[]; no_semi[] // TEST:Y:1 ; -} | 'g' { semi++; no_semi++ // TEST:Y:1 ; -} | 'h' { {no_semi} no_semi // TEST:Y:1 ; -} | 'i' { {semi;} no_semi // TEST:Y:1 ; + : 'a' { semi; // TEST:N:1 ; +} | 'b' { if (0) {no_semi} // TEST:N:1 ; +} | 'c' { if (0) {semi;} // TEST:N:1 ; +} | 'd' { semi; no_semi // TEST:Y:1 ; +} | 'e' { semi(); no_semi() // TEST:Y:1 ; +} | 'f' { semi[]; no_semi[] // TEST:Y:1 ; +} | 'g' { semi++; no_semi++ // TEST:Y:1 ; +} | 'h' { {no_semi} no_semi // TEST:Y:1 ; +} | 'i' { {semi;} no_semi // TEST:Y:1 ; } ; test0 - : 'a' { semi; // TEST:N:1 {} -} | 'b' { if (0) {no_semi} // TEST:N:1 {} -} | 'c' { if (0) {semi;} // TEST:N:1 {} -} | 'd' { semi; no_semi // TEST:Y:1 {} -} | 'e' { semi(); no_semi() // TEST:Y:1 {} -} | 'f' { semi[]; no_semi[] // TEST:Y:1 {} -} | 'g' { semi++; no_semi++ // TEST:Y:1 {} -} | 'h' { {no_semi} no_semi // TEST:Y:1 {} -} | 'i' { {semi;} no_semi // TEST:Y:1 {} + : 'a' { semi; // TEST:N:1 {} +} | 'b' { if (0) {no_semi} // TEST:N:1 {} +} | 'c' { if (0) {semi;} // TEST:N:1 {} +} | 'd' { semi; no_semi // TEST:Y:1 {} +} | 'e' { semi(); no_semi() // TEST:Y:1 {} +} | 'f' { semi[]; no_semi[] // TEST:Y:1 {} +} | 'g' { semi++; no_semi++ // TEST:Y:1 {} +} | 'h' { {no_semi} no_semi // TEST:Y:1 {} +} | 'i' { {semi;} no_semi // TEST:Y:1 {} } ; testc @@ -1428,42 +1438,42 @@ string;"} AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o input.c input.y]], [0], [], -[[input.y:8.48: warning: a ';' might be needed at the end of action code -input.y:8.48: warning: future versions of Bison will not add the ';' -input.y:9.48: warning: a ';' might be needed at the end of action code -input.y:9.48: warning: future versions of Bison will not add the ';' -input.y:10.48: warning: a ';' might be needed at the end of action code -input.y:10.48: warning: future versions of Bison will not add the ';' -input.y:11.48: warning: a ';' might be needed at the end of action code -input.y:11.48: warning: future versions of Bison will not add the ';' -input.y:12.48: warning: a ';' might be needed at the end of action code -input.y:12.48: warning: future versions of Bison will not add the ';' -input.y:13.48: warning: a ';' might be needed at the end of action code -input.y:13.48: warning: future versions of Bison will not add the ';' -input.y:20.1: warning: a ';' might be needed at the end of action code -input.y:20.1: warning: future versions of Bison will not add the ';' -input.y:21.1: warning: a ';' might be needed at the end of action code -input.y:21.1: warning: future versions of Bison will not add the ';' -input.y:22.1: warning: a ';' might be needed at the end of action code -input.y:22.1: warning: future versions of Bison will not add the ';' -input.y:23.1: warning: a ';' might be needed at the end of action code -input.y:23.1: warning: future versions of Bison will not add the ';' -input.y:24.1: warning: a ';' might be needed at the end of action code -input.y:24.1: warning: future versions of Bison will not add the ';' -input.y:25.1: warning: a ';' might be needed at the end of action code -input.y:25.1: warning: future versions of Bison will not add the ';' -input.y:31.1: warning: a ';' might be needed at the end of action code -input.y:31.1: warning: future versions of Bison will not add the ';' -input.y:32.1: warning: a ';' might be needed at the end of action code -input.y:32.1: warning: future versions of Bison will not add the ';' -input.y:33.1: warning: a ';' might be needed at the end of action code -input.y:33.1: warning: future versions of Bison will not add the ';' -input.y:34.1: warning: a ';' might be needed at the end of action code -input.y:34.1: warning: future versions of Bison will not add the ';' -input.y:35.1: warning: a ';' might be needed at the end of action code -input.y:35.1: warning: future versions of Bison will not add the ';' -input.y:36.1: warning: a ';' might be needed at the end of action code -input.y:36.1: warning: future versions of Bison will not add the ';' +[[input.y:8.48: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:8.48: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:9.48: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:9.48: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:10.48: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:10.48: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:11.48: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:11.48: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:12.48: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:12.48: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:13.48: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:13.48: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:20.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:20.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:21.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:21.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:22.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:22.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:23.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:23.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:24.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:24.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:25.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:25.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:31.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:31.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:32.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:32.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:33.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:33.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:34.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:34.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:35.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:35.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] +input.y:36.1: warning: a ';' might be needed at the end of action code [-Wdeprecated] +input.y:36.1: warning: future versions of Bison will not add the ';' [-Wdeprecated] ]]) AT_MATCHES_CHECK([input.c], [[/\* TEST:N:2 \*/ \}$]], [[3]]) diff --git a/tests/atlocal.in b/tests/atlocal.in index 2f682592..e350d137 100644 --- a/tests/atlocal.in +++ b/tests/atlocal.in @@ -1,4 +1,4 @@ -# @configure_input@ -*- shell-script -*- +# @configure_input@ -*- shell-script -*- # Configurable variable values for Bison test suite. # Copyright (C) 2000-2012 Free Software Foundation, Inc. @@ -62,8 +62,9 @@ CONF_JAVAC='@CONF_JAVAC@' # Empty if no Java VM was found CONF_JAVA='@CONF_JAVA@' -# We need egrep. +# We need egrep and perl. : ${EGREP='@EGREP@'} +: ${PERL='@PERL@'} # Use simple quotes (lib/quote.c). LC_CTYPE=C @@ -78,4 +79,9 @@ LIBS="$abs_top_builddir/lib/libbison.a @LIBS@ @INTLLIBS@" # Empty if no xsltproc was found : ${XSLTPROC='@XSLTPROC@'} -: ${PERL='@PERL@'} + +# Handle --compile-c-with-cxx here, once CXX and CXXFLAGS are known. +if "$at_arg_compile_c_with_cxx"; then + CC=$CXX + CFLAGS=$CXXFLAGS +fi diff --git a/tests/bison.in b/tests/bison.in index f21b2bcd..b8e0e057 100644 --- a/tests/bison.in +++ b/tests/bison.in @@ -34,14 +34,15 @@ status=$? for i do case $i in - */parse-gram.y) + */src/parse-gram.y) if $PERL --version >/dev/null; then # We are called by ylwrap which still uses y.tab.*, and # post-processes the synclines on y.tab.c itself. Don't let it # do it. Besides, it leaves "parse-gram.y" as the source, # dropping the src/ part. - $PERL -pi -e 's{"y\.tab\.}{"parse-gram.}g;' \ - -e 's{".*/(parse-gram\.y)"}{"$1"}g;' \ + $PERL -pi -e 's{"y\.tab\.}{"src/parse-gram.}g;' \ + -e 's{".*/(parse-gram\.y)"}{"src/$1"}g;' \ + -e 's{GRAM_Y_TAB_H}{GRAM_SRC_PARSE_GRAM_H}g;' \ y.tab.[ch] fi ;; diff --git a/tests/c++.at b/tests/c++.at index dba7a758..d5e75962 100644 --- a/tests/c++.at +++ b/tests/c++.at @@ -1,7 +1,6 @@ # Checking the C++ Features. -*- Autotest -*- -# Copyright (C) 2004-2005, 2007, 2009-2012 Free Software Foundation, -# Inc. +# Copyright (C) 2004-2005, 2007-2012 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 @@ -19,6 +18,193 @@ AT_BANNER([[C++ Features.]]) +## ---------- ## +## Variants. ## +## ---------- ## + +# AT_CHECK_VARIANTS([DIRECTIVES]) +# ------------------------------- +# Check the support of variants in C++, with the additional DIRECTIVES. +m4_define([AT_CHECK_VARIANTS], +[AT_SETUP([Variants $1]) + +# Store strings and integers in a list of strings. +AT_DATA_GRAMMAR([list.yy], +[[%debug +%skeleton "lalr1.cc" +%defines +%define variant +%locations +]m4_bpatsubst([$1], [\\n], [ +])[ + +%code requires // code for the .hh file +{ +#include <list> +#include <string> +typedef std::list<std::string> strings_type; +} + +%code // code for the .cc file +{ +#include <iostream> +#include <sstream> + + static +#if defined USE_LEX_SYMBOL + yy::parser::symbol_type yylex (); +#else + yy::parser::token_type yylex (yy::parser::semantic_type* yylval, + yy::parser::location_type* yylloc); +#endif + + // Printing a list of strings (for %printer). + // Koening look up will look into std, since that's an std::list. + namespace std + { + std::ostream& + operator<<(std::ostream& o, const strings_type& s) + { + o << '('; + for (strings_type::const_iterator i = s.begin (); i != s.end (); ++i) + { + if (i != s.begin ()) + o << ", "; + o << *i; + } + return o << ')'; + } + } + + // Conversion to string. + template <typename T> + inline + std::string + string_cast (const T& t) + { + std::ostringstream o; + o << t; + return o.str (); + } +} + +%token <::std::string> TEXT; +%token <int> NUMBER; +%token END_OF_FILE 0; + +%type <::std::string> item; +// Using the template type to exercize its parsing. +// Starting with :: to ensure we don't output "<::" which starts by the +// digraph for the left square bracket. +%type <::std::list<std::string>> list result; + +%printer { yyo << $][$; } + <int> <::std::string> <::std::list<std::string>>; +%% + +result: + list { std::cout << $][1 << std::endl; } +; + +list: + /* nothing */ { /* Generates an empty string list */ } +| list item { std::swap ($][$,$][1); $$.push_back ($][2); } +| list error { std::swap ($][$,$][1); } +; + +item: + TEXT { std::swap ($][$,$][1); } +| NUMBER { if ($][1 == 3) YYERROR; else $][$ = string_cast ($][1); } +; +%% + +#define STAGE_MAX 5 +static +#if defined USE_LEX_SYMBOL +yy::parser::symbol_type yylex () +#else +yy::parser::token_type yylex (yy::parser::semantic_type* yylval, + yy::parser::location_type* yylloc) +#endif +{ +#ifndef USE_LEX_SYMBOL + typedef yy::parser::token token; +#endif + typedef yy::parser::location_type location_type; + static int stage = -1; + ++stage; + if (stage == STAGE_MAX) + { +#if defined USE_LEX_SYMBOL + return yy::parser::make_END_OF_FILE (location_type ()); +#else + *yylloc = location_type (); + return token::END_OF_FILE; +#endif + } + else if (stage % 2) + { +#if defined USE_LEX_SYMBOL + return yy::parser::make_NUMBER (stage, location_type ()); +#else +# if defined ONE_STAGE_BUILD + yylval->build (stage); +# else + yylval->build<int>() = stage; +# endif + *yylloc = location_type (); + return token::NUMBER; +#endif + } + else + { +#if defined USE_LEX_SYMBOL + return yy::parser::make_TEXT (string_cast (stage), location_type ()); +#else +# if defined ONE_STAGE_BUILD + yylval->build (string_cast (stage)); +# else + yylval->build<std::string>() = string_cast (stage); +# endif + *yylloc = location_type (); + return token::TEXT; +#endif + } + abort (); +} + +void +yy::parser::error (const yy::parser::location_type&, + const std::string& message) +{ + std::cerr << message << std::endl; +} + +int +main () +{ + yy::parser p; + p.set_debug_level (!!getenv ("YYDEBUG")); + return p.parse (); +} +]]) + +AT_BISON_CHECK([-o list.cc list.yy]) +AT_COMPILE_CXX([list]) +AT_CHECK([./list], 0, + [(0, 1, 2, 4) +]) + +AT_CLEANUP +]) + +AT_CHECK_VARIANTS([]) +AT_CHECK_VARIANTS([%define parse.assert]) +AT_CHECK_VARIANTS([[%define parse.assert %code {\n#define ONE_STAGE_BUILD\n}]]) +AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n}]]) +AT_CHECK_VARIANTS([[%define parse.assert %define lex_symbol %code {\n#define USE_LEX_SYMBOL\n} %define api.token.prefix "TOK_"]]) + + ## ----------------------- ## ## Doxygen Documentation. ## ## ----------------------- ## @@ -27,7 +213,7 @@ m4_define([AT_CHECK_DOXYGEN], [m4_case([$1], [Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])], [Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])], - [m4_fatal([invalid argument: $1])]) + [m4_fatal([invalid argument: $1])]) AT_SETUP([Doxygen $1 Documentation]) AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"]) @@ -101,6 +287,7 @@ m4_popdef([AT_DOXYGEN_PRIVATE]) AT_CHECK_DOXYGEN([Public]) AT_CHECK_DOXYGEN([Private]) + ## ------------ ## ## Namespaces. ## ## ------------ ## @@ -116,13 +303,14 @@ m4_define([AT_CHECK_NAMESPACE], AT_DATA_GRAMMAR([[input.y]], [[%language "C++" %defines -%define namespace "]$1[" +%define api.namespace "]$1[" %union { int i; } %define global_tokens_and_yystype +%locations %code { // YYSTYPE contains a namespace reference. - int yylex (YYSTYPE *lval) { + int yylex (YYSTYPE *lval, const ]$1[::parser::location_type*) { lval->i = 3; return 0; } @@ -142,7 +330,7 @@ void } int -main (void) +main () { ]$1[::parser p; return p.parse (); @@ -179,7 +367,168 @@ AT_CHECK_NAMESPACE([[foo: :bar]], [[-]]) # contains single occurrences of `:'. AT_CHECK_NAMESPACE([[foo[3]::bar::baz]], [[-]]) AT_CHECK_NAMESPACE([[foo::bar,baz]], [[-]]) -AT_CHECK_NAMESPACE([[foo::bar::(baz]], [[-]]) +AT_CHECK_NAMESPACE([[foo::bar::(baz /* Pacify Emacs ) */]], [[-]]) +AT_CLEANUP + + +## -------------------------------------- ## +## Syntax error discarding no lookahead. ## +## -------------------------------------- ## + +# After a syntax error, lalr1.cc used to not check whether there +# actually is a lookahead before discarding the lookahead. As a result, +# it mistakenly invoked the destructor for the previous lookahead. + +AT_SETUP([[Syntax error discarding no lookahead]]) + +AT_DATA_GRAMMAR([[input.yy]], +[[%skeleton "lalr1.cc" + +%code { + #include <string> + int yylex (yy::parser::semantic_type *); + #define USE(Args) +} + +%defines +%define parse.error verbose + +%nonassoc 'a' ; + +%destructor { + std::cerr << "Discarding 'a'." << std::endl; +} 'a' + +%% + +start: error-reduce consistent-error 'a' { USE ($3); }; + +error-reduce: + 'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); } +| 'a' error { std::cerr << "Reducing 'a'." << std::endl; USE ($1); } +; + +consistent-error: + 'a' +| /*empty*/ %prec 'a' +; + +// Provide another context in which all rules are useful so that this +// test case looks a little more realistic. +start: 'b' consistent-error ; + +%% + +int +yylex (yy::parser::semantic_type *) +{ + static char const *input = "aa"; + return *input++; +} + +void +yy::parser::error (const std::string &m) +{ + std::cerr << m << std::endl; +} + +int +main () +{ + yy::parser parser; + return parser.parse (); +} +]]) +AT_BISON_CHECK([[-o input.cc input.yy]]) +AT_COMPILE_CXX([[input]]) +# This used to print "Discarding 'a'." again at the end. +AT_PARSER_CHECK([[./input]], [[1]], [[]], +[[syntax error +Discarding 'a'. +Reducing 'a'. +]]) + +AT_CLEANUP + + +## --------------------------- ## +## Syntax error as exception. ## +## --------------------------- ## + +AT_SETUP([[Syntax error as exception]]) + +AT_DATA_GRAMMAR([[input.yy]], +[[%skeleton "lalr1.cc" + +%code +{ + #include <cstdlib> + int yylex (yy::parser::semantic_type *); +} + +%defines +%define variant +%define parse.error verbose +%define parse.trace +%% + +start: + thing +| start thing +; + +thing: + error { std::cerr << "caught error" << std::endl; } +| item +; + +item: + 'a' +| 's' + { + throw yy::parser::syntax_error ("invalid expression"); + } + +%% + +int +yylex (yy::parser::semantic_type *) +{ + // 's': syntax error, 'l': lexical error. + static char const *input = "asal"; + switch (int res = *input++) + { + case 'l': + throw yy::parser::syntax_error ("invalid character"); + default: + return res; + } +} + +void +yy::parser::error (const std::string &m) +{ + std::cerr << "error: " << m << std::endl; +} + +int +main () +{ + yy::parser parser; + parser.set_debug_level (!!getenv ("YYDEBUG")); + return parser.parse (); +} +]]) +AT_BISON_CHECK([[-o input.cc input.yy]]) +AT_COMPILE_CXX([[input]]) + +AT_PARSER_CHECK([[./input]], [[0]], [[]], +[[error: invalid expression +caught error +error: invalid character +caught error +]]) + AT_CLEANUP @@ -298,7 +647,7 @@ list: item: 'a' { $$ = $1; } -| 'e' { YYUSE ($$); YYUSE($1); error (location_type(), "syntax error"); } +| 'e' { YYUSE ($$); YYUSE($1); error ("syntax error"); } // Not just 'E', otherwise we reduce when 'E' is the lookahead, and // then the stack is emptied, defeating the point of the test. | 'E' 'a' { YYUSE($1); $$ = $2; } @@ -335,9 +684,8 @@ yylex (yy::parser::semantic_type *lvalp) /* A C++ error reporting function. */ void -yy::parser::error (const location_type& l, const std::string& m) +yy::parser::error (const std::string& m) { - YYUSE (l); throw std::runtime_error (m); } diff --git a/tests/calc.at b/tests/calc.at index 647d6589..bdc80284 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -205,12 +205,12 @@ read_signed_integer (]AT_YYLEX_FORMALS[) { unget_char (]AT_YYLEX_PRE_ARGS[ c); ]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[); - return NUM; + return ]AT_TOKEN_PREFIX[NUM; } /* Return end-of-file. */ if (c == EOF) - return CALC_EOF; + return ]AT_TOKEN_PREFIX[CALC_EOF; /* Return single chars. */ return c; @@ -288,7 +288,7 @@ static int power (int base, int exponent); ]AT_YYLEX_DECLARE_EXTERN[ } -]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [[ +]AT_SKEL_CC_IF([AT_LOCATION_IF([AT_LOCATION_TYPE_IF([], [ /* The lalr1.cc skeleton, for backward compatibility, defines a constructor for position that initializes the filename. The glr.cc skeleton does not (and in fact cannot: location/position @@ -297,18 +297,18 @@ static int power (int base, int exponent); %initial-action { @$.initialize (); } -]])])[ +])])])[ /* Bison Declarations */ %token CALC_EOF 0 "end of input" %token <ival> NUM "number" %type <ival> exp -%nonassoc '=' /* comparison */ +%nonassoc '=' /* comparison */ %left '-' '+' %left '*' '/' -%left NEG /* negation--unary minus */ -%right '^' /* exponentiation */ +%precedence NEG /* negation--unary minus */ +%right '^' /* exponentiation */ /* Grammar follows */ %% @@ -448,7 +448,7 @@ AT_PARSER_CHECK([./calc input], 0, [], [stderr]) # If BISON-OPTIONS contains `%location', then make sure the ERROR-LOCATION # is correctly output on stderr. # -# If BISON-OPTIONS contains `%error-verbose', then make sure the +# If BISON-OPTIONS contains `%define parse.error verbose', then make sure the # IF-YYERROR-VERBOSE message is properly output after `syntax error, ' # on STDERR. # @@ -490,7 +490,7 @@ AT_YYERROR_SEES_LOC_IF([], [[sed 's/^[-0-9.]*: //' expout >at-expout mv at-expout expout]]) # 4. If error-verbose is not used, strip the`, unexpected....' part. -m4_bmatch([$1], [%error-verbose], [], +m4_bmatch([$1], [%define parse.error verbose], [], [[sed 's/syntax error, .*$/syntax error/' expout >at-expout mv at-expout expout]]) # 5. Check @@ -508,8 +508,10 @@ m4_define([AT_CHECK_SPACES], print "$.: {$_}\n" if (# No starting/ending empty lines. (eof || $. == 1) && /^\s*$/ - # No trailing space. FIXME: not ready for "maint". - # || /\s$/ + # No trailing space. + || /\s$/ + # No tabs. + || /\t/ )' $1 ])dnl ]) @@ -635,26 +637,26 @@ AT_CHECK_CALC_LALR() AT_CHECK_CALC_LALR([%defines]) AT_CHECK_CALC_LALR([%locations]) -AT_CHECK_CALC_LALR([%name-prefix="calc"]) dnl test deprecated `=' +AT_CHECK_CALC_LALR([%name-prefix "calc"]) AT_CHECK_CALC_LALR([%verbose]) AT_CHECK_CALC_LALR([%yacc]) -AT_CHECK_CALC_LALR([%error-verbose]) +AT_CHECK_CALC_LALR([%define parse.error verbose]) AT_CHECK_CALC_LALR([%define api.pure %locations]) AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %locations]) -AT_CHECK_CALC_LALR([%error-verbose %locations]) +AT_CHECK_CALC_LALR([%define parse.error verbose %locations]) -AT_CHECK_CALC_LALR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%error-verbose %locations %defines %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define parse.error verbose %locations %defines %name-prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc]) AT_CHECK_CALC_LALR([%debug]) -AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR([%define api.push-pull both %define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) # ----------------------- # @@ -679,21 +681,21 @@ AT_CHECK_CALC_GLR([%name-prefix "calc"]) AT_CHECK_CALC_GLR([%define api.prefix "calc"]) AT_CHECK_CALC_GLR([%verbose]) AT_CHECK_CALC_GLR([%yacc]) -AT_CHECK_CALC_GLR([%error-verbose]) +AT_CHECK_CALC_GLR([%define parse.error verbose]) AT_CHECK_CALC_GLR([%define api.pure %locations]) -AT_CHECK_CALC_GLR([%error-verbose %locations]) +AT_CHECK_CALC_GLR([%define parse.error verbose %locations]) -AT_CHECK_CALC_GLR([%error-verbose %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR([%define parse.error verbose %locations %defines %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR([%debug]) -AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR([%error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR([%define parse.error verbose %debug %locations %defines %define api.prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc]) -AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) +AT_CHECK_CALC_GLR([%define api.pure %define parse.error verbose %debug %locations %defines %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) # ----------------------------- # @@ -703,25 +705,30 @@ AT_CHECK_CALC_GLR([%define api.pure %error-verbose %debug %locations %defines %d AT_BANNER([[Simple LALR(1) C++ Calculator.]]) # First let's try using %skeleton -AT_CHECK_CALC([%skeleton "lalr1.cc" %defines %locations]) +AT_CHECK_CALC([%skeleton "lalr1.cc" %defines]) # AT_CHECK_CALC_LALR1_CC([BISON-OPTIONS]) # --------------------------------------- # Start a testing chunk which compiles `calc' grammar with # the C++ skeleton, and performs several tests over the parser. m4_define([AT_CHECK_CALC_LALR1_CC], -[AT_CHECK_CALC([%language "C++" %defines %locations] $@)]) +[AT_CHECK_CALC([%language "C++"] $@)]) AT_CHECK_CALC_LALR1_CC([]) -AT_CHECK_CALC_LALR1_CC([%define api.location.type Span]) -AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%error-verbose %define api.prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%locations]) +AT_CHECK_CALC_LALR1_CC([%locations %define api.location.type Span]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %define parse.error verbose %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%locations %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc]) + +AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) + +AT_CHECK_CALC_LALR1_CC([%pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) +AT_CHECK_CALC_LALR1_CC([%defines %locations %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) @@ -732,24 +739,26 @@ AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %define api.prefix "c AT_BANNER([[Simple GLR C++ Calculator.]]) # Again, we try also using %skeleton. -AT_CHECK_CALC([%skeleton "glr.cc" %defines %locations]) +AT_CHECK_CALC([%skeleton "glr.cc"]) # AT_CHECK_CALC_GLR_CC([BISON-OPTIONS]) # ------------------------------------- # Start a testing chunk which compiles `calc' grammar with # the GLR C++ skeleton, and performs several tests over the parser. m4_define([AT_CHECK_CALC_GLR_CC], -[AT_CHECK_CALC([%language "C++" %glr-parser %defines %locations] $@)]) +[AT_CHECK_CALC([%language "C++" %glr-parser] $@)]) AT_CHECK_CALC_GLR_CC([]) -AT_CHECK_CALC_GLR_CC([%define api.location.type Span]) -AT_CHECK_CALC_GLR_CC([%error-verbose %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR_CC([%error-verbose %define api.prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%locations]) +AT_CHECK_CALC_GLR_CC([%locations %define api.location.type Span]) +AT_CHECK_CALC_GLR_CC([%defines %define parse.error verbose %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%define parse.error verbose %define api.prefix "calc" %verbose %yacc]) AT_CHECK_CALC_GLR_CC([%debug]) -AT_CHECK_CALC_GLR_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) -AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc]) +AT_CHECK_CALC_GLR_CC([%pure-parser %define parse.error verbose %debug %name-prefix "calc" %define api.token.prefix "TOK_" %verbose %yacc]) -AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) -AT_CHECK_CALC_GLR_CC([%pure-parser %error-verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) +AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) +AT_CHECK_CALC_GLR_CC([%locations %defines %pure-parser %define parse.error verbose %debug %define api.prefix "calc" %verbose %yacc %parse-param {semantic_value *result} {int *count}]) diff --git a/tests/conflicts.at b/tests/conflicts.at index 3934a6cf..37c54050 100644 --- a/tests/conflicts.at +++ b/tests/conflicts.at @@ -1,7 +1,6 @@ # Exercising Bison on conflicts. -*- Autotest -*- -# Copyright (C) 2002-2005, 2007, 2009-2012 Free Software Foundation, -# Inc. +# Copyright (C) 2002-2005, 2007-2012 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 @@ -38,7 +37,7 @@ e: 'e' | /* Nothing. */; ]]) AT_BISON_CHECK([-o input.c input.y], 0, [], -[[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */ +[[input.y:4.9: warning: rule useless in parser due to conflicts: e: /* empty */ [-Wother] ]]) AT_CLEANUP @@ -118,10 +117,10 @@ AT_NONASSOC_AND_EOF_CHECK([], [[incorrect]]) # We must disable default reductions in inconsistent states in order to # have an explicit list of all expected tokens. -AT_NONASSOC_AND_EOF_CHECK([[-Dlr.default-reductions=consistent]], +AT_NONASSOC_AND_EOF_CHECK([[-Dlr.default-reduction=consistent]], [[correct]]) -# lr.default-reductions=consistent happens to work for this test case. +# lr.default-reduction=consistent happens to work for this test case. # However, for other grammars, lookahead sets can be merged for # different left contexts, so it is still possible to have an incorrect # expected list. Canonical LR is almost a general solution (that is, it @@ -142,11 +141,11 @@ AT_CLEANUP -## -------------------------------------- ## -## %error-verbose and consistent errors. ## -## -------------------------------------- ## +## ------------------------------------------- ## +## parse.error=verbose and consistent errors. ## +## ------------------------------------------- ## -AT_SETUP([[%error-verbose and consistent errors]]) +AT_SETUP([[parse.error=verbose and consistent errors]]) m4_pushdef([AT_CONSISTENT_ERRORS_CHECK], [ @@ -164,7 +163,6 @@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y], }]], [[ %code {]AT_SKEL_CC_IF([[ - #include <cassert> #include <string>]], [[ #include <assert.h> #include <stdio.h> @@ -177,7 +175,7 @@ AT_SKEL_JAVA_IF([AT_DATA], [AT_DATA_GRAMMAR])([input.y], ]$1[ -%error-verbose +%define parse.error verbose %% @@ -312,12 +310,12 @@ AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr # Even canonical LR doesn't foresee the error for 'a'! AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr - %define lr.default-reductions consistent]], + %define lr.default-reduction consistent]], [AT_PREVIOUS_STATE_GRAMMAR], [AT_PREVIOUS_STATE_INPUT], [[$end]], [[ab]]) AT_CONSISTENT_ERRORS_CHECK([[%define lr.type ielr - %define lr.default-reductions accepting]], + %define lr.default-reduction accepting]], [AT_PREVIOUS_STATE_GRAMMAR], [AT_PREVIOUS_STATE_INPUT], [[$end]], [[ab]]) @@ -372,7 +370,7 @@ error-reduce: ; consistent-reduction: /*empty*/ { - assert (yychar == ]AT_SKEL_CC_IF([[yyempty_]], [[YYEMPTY]])[); + assert (yychar == YYEMPTY); yylval = 0; yychar = 'b'; } ; @@ -396,19 +394,15 @@ AT_CONSISTENT_ERRORS_CHECK([[%glr-parser]], [AT_USER_ACTION_GRAMMAR], [AT_USER_ACTION_INPUT], [['b']], [[none]]) -AT_CONSISTENT_ERRORS_CHECK([[%language "c++"]], - [AT_USER_ACTION_GRAMMAR], - [AT_USER_ACTION_INPUT], - [['b']], [[none]]) -# No Java test because yychar cannot be manipulated by users. +# No C++ or Java test because yychar cannot be manipulated by users. -AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions consistent]], +AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reduction consistent]], [AT_USER_ACTION_GRAMMAR], [AT_USER_ACTION_INPUT], [['b']], [[none]]) # Canonical LR doesn't foresee the error for 'a'! -AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reductions accepting]], +AT_CONSISTENT_ERRORS_CHECK([[%define lr.default-reduction accepting]], [AT_USER_ACTION_GRAMMAR], [AT_USER_ACTION_INPUT], [[$end]], [[a]]) @@ -422,7 +416,7 @@ AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full]], [AT_USER_ACTION_INPUT], [['b']], [[none]]) AT_CONSISTENT_ERRORS_CHECK([[%define parse.lac full - %define lr.default-reductions accepting]], + %define lr.default-reduction accepting]], [AT_USER_ACTION_GRAMMAR], [AT_USER_ACTION_INPUT], [[$end]], [[none]]) @@ -504,7 +498,7 @@ AT_BISON_OPTION_POPDEFS # Show canonical LR's failure. AT_BISON_CHECK([[-Dlr.type=canonical-lr -o input.c input.y]], [[0]], [[]], -[[input.y: conflicts: 2 shift/reduce +[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input]], [[1]], [[]], @@ -514,7 +508,7 @@ AT_PARSER_CHECK([[./input]], [[1]], [[]], # It's corrected by LAC. AT_BISON_CHECK([[-Dlr.type=canonical-lr -Dparse.lac=full \ -o input.c input.y]], [[0]], [[]], -[[input.y: conflicts: 2 shift/reduce +[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input]], [[1]], [[]], @@ -524,7 +518,7 @@ AT_PARSER_CHECK([[./input]], [[1]], [[]], # IELR is sufficient when LAC is used. AT_BISON_CHECK([[-Dlr.type=ielr -Dparse.lac=full -o input.c input.y]], [[0]], [[]], -[[input.y: conflicts: 2 shift/reduce +[[input.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input]], [[1]], [[]], @@ -548,8 +542,8 @@ exp: exp OP exp | NUM; ]]) AT_BISON_CHECK([-o input.c --report=all input.y], 0, [], -[input.y: conflicts: 1 shift/reduce -]) +[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +]]) # Check the contents of the report. AT_CHECK([cat input.output], [], @@ -741,6 +735,62 @@ state 5 AT_CLEANUP +## ---------------------- ## +## %precedence suffices. ## +## ---------------------- ## + +AT_SETUP([%precedence suffices]) + +AT_DATA([input.y], +[[%precedence "then" +%precedence "else" +%% +stmt: + "if" cond "then" stmt +| "if" cond "then" stmt "else" stmt +| "stmt" +; + +cond: + "exp" +; +]]) + +AT_BISON_CHECK([-o input.c input.y]) + +AT_CLEANUP + + +## ------------------------------ ## +## %precedence does not suffice. ## +## ------------------------------ ## + +AT_SETUP([%precedence does not suffice]) + +AT_DATA([input.y], +[[%precedence "then" +%precedence "else" +%% +stmt: + "if" cond "then" stmt +| "if" cond "then" stmt "else" stmt +| "stmt" +; + +cond: + "exp" +| cond "then" cond +; +]]) + +AT_BISON_CHECK([-o input.c input.y], 0, [], +[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +input.y:12.3-18: warning: rule useless in parser due to conflicts: cond: cond "then" cond [-Wother] +]]) + +AT_CLEANUP + + ## -------------------------------- ## ## Defaulted Conflicted Reduction. ## ## -------------------------------- ## @@ -778,8 +828,8 @@ id : '0'; ]]) AT_BISON_CHECK([-o input.c --report=all input.y], 0, [], -[[input.y: conflicts: 1 reduce/reduce -input.y:4.6-8: warning: rule useless in parser due to conflicts: id: '0' +[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +input.y:4.6-8: warning: rule useless in parser due to conflicts: id: '0' [-Wother] ]]) # Check the contents of the report. @@ -895,9 +945,8 @@ exp: exp OP exp | NUM; ]]) AT_BISON_CHECK([-o input.c input.y], 1, [], -[input.y: conflicts: 1 shift/reduce -input.y: error: expected 0 shift/reduce conflicts -]) +[[input.y: error: shift/reduce conflicts: 1 found, 0 expected +]]) AT_CLEANUP @@ -932,9 +981,8 @@ exp: exp OP exp | NUM; ]]) AT_BISON_CHECK([-o input.c input.y], 1, [], -[input.y: conflicts: 1 shift/reduce -input.y: error: expected 2 shift/reduce conflicts -]) +[[input.y: error: shift/reduce conflicts: 1 found, 2 expected +]]) AT_CLEANUP @@ -952,9 +1000,8 @@ a: 'a'; ]]) AT_BISON_CHECK([-o input.c input.y], 1, [], -[input.y: conflicts: 1 reduce/reduce -input.y: error: expected 0 reduce/reduce conflicts -]) +[[input.y: error: reduce/reduce conflicts: 1 found, 0 expected +]]) AT_CLEANUP @@ -996,7 +1043,7 @@ e: e '+' e ]]) AT_BISON_CHECK([-o input.c input.y], 0, [], -[[input.y: conflicts: 4 shift/reduce +[[input.y: warning: 4 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_CLEANUP @@ -1098,14 +1145,15 @@ reported_conflicts: ]]) AT_BISON_CHECK([[--report=all input.y]], 0, [], -[[input.y: conflicts: 1 shift/reduce, 1 reduce/reduce -input.y:12.5-20: warning: rule useless in parser due to conflicts: resolved_conflict: 'a' unreachable1 -input.y:20.5-20: warning: rule useless in parser due to conflicts: unreachable1: 'a' unreachable2 -input.y:21.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */ -input.y:25.13: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ -input.y:25.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ -input.y:31.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a' -input.y:32.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */ +[[input.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +input.y:12.5-20: warning: rule useless in parser due to conflicts: resolved_conflict: 'a' unreachable1 [-Wother] +input.y:20.5-20: warning: rule useless in parser due to conflicts: unreachable1: 'a' unreachable2 [-Wother] +input.y:21.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */ [-Wother] +input.y:25.13: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ [-Wother] +input.y:25.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ [-Wother] +input.y:31.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a' [-Wother] +input.y:32.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */ [-Wother] ]]) AT_CHECK([[cat input.output]], 0, @@ -1245,16 +1293,17 @@ state 7 ]]) AT_DATA([[input-keep.y]], -[[%define lr.keep-unreachable-states +[[%define lr.keep-unreachable-state ]]) AT_CHECK([[cat input.y >> input-keep.y]]) AT_BISON_CHECK([[input-keep.y]], 0, [], -[[input-keep.y: conflicts: 2 shift/reduce, 2 reduce/reduce -input-keep.y:22.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */ -input-keep.y:26.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ -input-keep.y:32.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a' -input-keep.y:33.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */ +[[input-keep.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] +input-keep.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] +input-keep.y:22.4: warning: rule useless in parser due to conflicts: unreachable1: /* empty */ [-Wother] +input-keep.y:26.16: warning: rule useless in parser due to conflicts: unreachable2: /* empty */ [-Wother] +input-keep.y:32.5-7: warning: rule useless in parser due to conflicts: reported_conflicts: 'a' [-Wother] +input-keep.y:33.4: warning: rule useless in parser due to conflicts: reported_conflicts: /* empty */ [-Wother] ]]) AT_CLEANUP @@ -1409,9 +1458,40 @@ state 1 AT_CLEANUP -## --------------------------------- ## -## -W versus %expect and %expect-rr ## -## --------------------------------- ## +## -------------------- ## +## %expect-rr non GLR. ## +## -------------------- ## + +AT_SETUP([[%expect-rr non GLR]]) + +AT_DATA([[1.y]], +[[%expect-rr 0 +%% +exp: 'a' +]]) + +AT_BISON_CHECK([[1.y]], [[0]], [], +[[1.y: warning: %expect-rr applies only to GLR parsers [-Wother] +]]) + +AT_DATA([[2.y]], +[[%expect-rr 1 +%% +exp: 'a' | 'a'; +]]) + +AT_BISON_CHECK([[2.y]], [[0]], [], +[[2.y: warning: %expect-rr applies only to GLR parsers [-Wother] +2.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +2.y:3.12-14: warning: rule useless in parser due to conflicts: exp: 'a' [-Wother] +]]) + +AT_CLEANUP + + +## ---------------------------------- ## +## -W versus %expect and %expect-rr. ## +## ---------------------------------- ## AT_SETUP([[-W versus %expect and %expect-rr]]) @@ -1437,17 +1517,27 @@ B: ; ]]) AT_BISON_CHECK([[sr-rr.y]], [[0]], [[]], -[[sr-rr.y: conflicts: 1 shift/reduce, 1 reduce/reduce +[[sr-rr.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +sr-rr.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] ]]) AT_BISON_CHECK([[-Wno-conflicts-sr sr-rr.y]], [[0]], [[]], -[[sr-rr.y: conflicts: 1 reduce/reduce +[[sr-rr.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] ]]) AT_BISON_CHECK([[-Wno-conflicts-rr sr-rr.y]], [[0]], [[]], -[[sr-rr.y: conflicts: 1 shift/reduce +[[sr-rr.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] ]]) -[for gram in sr-rr sr rr; do +[ +# This is piece of code is rather complex for a simple task: try every +# combinaison of (0 or 1 real SR) x (0 or 1 real RR) x (don't %expect +# or %expect 0, 1, or 2 SR) x (don't %expect-rr or %expect-rr 0, 1, or 2 +# RR). + +# Number and types of genuine conflicts in the grammar. +for gram in sr-rr sr rr; do + # Number of expected s/r conflicts. for sr_exp_i in '' 0 1 2; do + # Number of expected r/r conflicts. for rr_exp_i in '' 0 1 2; do test -z "$sr_exp_i" && test -z "$rr_exp_i" && continue @@ -1470,36 +1560,38 @@ AT_BISON_CHECK([[-Wno-conflicts-rr sr-rr.y]], [[0]], [[]], echo "$directives" > $file cat $gram.y >> $file - # Count actual conflicts. - conflicts= - sr_count=0 - rr_count=0 - if test $gram = sr || test $gram = sr-rr; then - conflicts="1 shift/reduce" - sr_count=1 - fi - if test $gram = rr || test $gram = sr-rr; then - if test -n "$conflicts"; then - conflicts="$conflicts, " - fi - conflicts="${conflicts}1 reduce/reduce" - rr_count=1 - fi + # Number of found conflicts. + case $gram in + (sr) sr_count=1; rr_count=0;; + (rr) sr_count=0; rr_count=1;; + (sr-rr) sr_count=1; rr_count=1;; + esac + + # Update number of expected conflicts: if %expect is given then + # %expect-rr defaults to 0, and vice-versa. Leave empty if + # nothing expected. + case $sr_exp_i:$rr_exp_i in + ?:) rr_exp_i=0;; + :?) sr_exp_i=0;; + esac # Run tests. if test $sr_count -eq $sr_exp && test $rr_count -eq $rr_exp; then ]AT_BISON_CHECK([[-Wnone $file]])[ ]AT_BISON_CHECK([[-Werror $file]])[ else - echo "$file: conflicts: $conflicts" > experr - if test $sr_count -ne $sr_exp; then - if test $sr_exp -ne 1; then s=s; else s= ; fi - echo "$file: error: expected $sr_exp shift/reduce conflict$s" >> experr - fi - if test $rr_count -ne $rr_exp; then - if test $rr_exp -ne 1; then s=s; else s= ; fi - echo "$file: error: expected $rr_exp reduce/reduce conflict$s" >> experr - fi + { + if test -z "$sr_exp_i" && test "$sr_count" -ne 0; then + echo "warning: $sr_count shift/reduce conflicts" + elif test "$sr_exp_i" -ne "$sr_count"; then + echo "error: shift/reduce conflicts: $sr_count found, $sr_exp_i expected" + fi + if test -z "$rr_exp_i" && test "$rr_count" -ne 0; then + echo "warning: $rr_count reduce/reduce conflicts" + elif test "$rr_exp_i" -ne "$rr_count"; then + echo "error: reduce/reduce conflicts: $rr_count found, $rr_exp_i expected" + fi + } | sed -e "s/^/$file: /" > experr ]AT_BISON_CHECK([[-Wnone $file]], [[1]], [[]], [[experr]])[ ]AT_BISON_CHECK([[-Werror $file]], [[1]], [[]], [[experr]])[ fi diff --git a/tests/existing.at b/tests/existing.at index 149499d4..20dbde82 100644 --- a/tests/existing.at +++ b/tests/existing.at @@ -115,281 +115,281 @@ AT_TEST_EXISTING_GRAMMAR([[GNU AWK 3.1.0 Grammar]], ]], [[ start - : opt_nls program opt_nls - ; + : opt_nls program opt_nls + ; program - : rule - | program rule - | error - | program error - | /* empty */ - ; + : rule + | program rule + | error + | program error + | /* empty */ + ; rule - : LEX_BEGIN {} action - | LEX_END {} action - | LEX_BEGIN statement_term - | LEX_END statement_term - | pattern action - | action - | pattern statement_term - | function_prologue function_body - ; + : LEX_BEGIN {} action + | LEX_END {} action + | LEX_BEGIN statement_term + | LEX_END statement_term + | pattern action + | action + | pattern statement_term + | function_prologue function_body + ; func_name - : NAME - | FUNC_CALL - | lex_builtin - ; + : NAME + | FUNC_CALL + | lex_builtin + ; lex_builtin - : LEX_BUILTIN - | LEX_LENGTH - ; + : LEX_BUILTIN + | LEX_LENGTH + ; function_prologue - : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls - ; + : LEX_FUNCTION {} func_name '(' opt_param_list r_paren opt_nls + ; function_body - : l_brace statements r_brace opt_semi opt_nls - | l_brace r_brace opt_semi opt_nls - ; + : l_brace statements r_brace opt_semi opt_nls + | l_brace r_brace opt_semi opt_nls + ; pattern - : exp - | exp ',' exp - ; + : exp + | exp ',' exp + ; regexp - /* - * In this rule, want_regexp tells yylex that the next thing - * is a regexp so it should read up to the closing slash. - */ - : '/' {} REGEXP '/' - ; + /* + * In this rule, want_regexp tells yylex that the next thing + * is a regexp so it should read up to the closing slash. + */ + : '/' {} REGEXP '/' + ; action - : l_brace statements r_brace opt_semi opt_nls - | l_brace r_brace opt_semi opt_nls - ; + : l_brace statements r_brace opt_semi opt_nls + | l_brace r_brace opt_semi opt_nls + ; statements - : statement - | statements statement - | error - | statements error - ; + : statement + | statements statement + | error + | statements error + ; statement_term - : nls - | semi opt_nls - ; + : nls + | semi opt_nls + ; statement - : semi opt_nls - | l_brace r_brace - | l_brace statements r_brace - | if_statement - | LEX_WHILE '(' exp r_paren opt_nls statement - | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls - | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement - | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement - | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement - | LEX_BREAK statement_term - | LEX_CONTINUE statement_term - | print '(' expression_list r_paren output_redir statement_term - | print opt_rexpression_list output_redir statement_term - | LEX_NEXT statement_term - | LEX_NEXTFILE statement_term - | LEX_EXIT opt_exp statement_term - | LEX_RETURN {} opt_exp statement_term - | LEX_DELETE NAME '[' expression_list ']' statement_term - | LEX_DELETE NAME statement_term - | exp statement_term - ; + : semi opt_nls + | l_brace r_brace + | l_brace statements r_brace + | if_statement + | LEX_WHILE '(' exp r_paren opt_nls statement + | LEX_DO opt_nls statement LEX_WHILE '(' exp r_paren opt_nls + | LEX_FOR '(' NAME LEX_IN NAME r_paren opt_nls statement + | LEX_FOR '(' opt_exp semi opt_nls exp semi opt_nls opt_exp r_paren opt_nls statement + | LEX_FOR '(' opt_exp semi opt_nls semi opt_nls opt_exp r_paren opt_nls statement + | LEX_BREAK statement_term + | LEX_CONTINUE statement_term + | print '(' expression_list r_paren output_redir statement_term + | print opt_rexpression_list output_redir statement_term + | LEX_NEXT statement_term + | LEX_NEXTFILE statement_term + | LEX_EXIT opt_exp statement_term + | LEX_RETURN {} opt_exp statement_term + | LEX_DELETE NAME '[' expression_list ']' statement_term + | LEX_DELETE NAME statement_term + | exp statement_term + ; print - : LEX_PRINT - | LEX_PRINTF - ; + : LEX_PRINT + | LEX_PRINTF + ; if_statement - : LEX_IF '(' exp r_paren opt_nls statement - | LEX_IF '(' exp r_paren opt_nls statement - LEX_ELSE opt_nls statement - ; + : LEX_IF '(' exp r_paren opt_nls statement + | LEX_IF '(' exp r_paren opt_nls statement + LEX_ELSE opt_nls statement + ; nls - : NEWLINE - | nls NEWLINE - ; + : NEWLINE + | nls NEWLINE + ; opt_nls - : /* empty */ - | nls - ; + : /* empty */ + | nls + ; input_redir - : /* empty */ - | '<' simp_exp - ; + : /* empty */ + | '<' simp_exp + ; output_redir - : /* empty */ - | '>' exp - | APPEND_OP exp - | '|' exp - | TWOWAYIO exp - ; + : /* empty */ + | '>' exp + | APPEND_OP exp + | '|' exp + | TWOWAYIO exp + ; opt_param_list - : /* empty */ - | param_list - ; + : /* empty */ + | param_list + ; param_list - : NAME - | param_list comma NAME - | error - | param_list error - | param_list comma error - ; + : NAME + | param_list comma NAME + | error + | param_list error + | param_list comma error + ; /* optional expression, as in for loop */ opt_exp - : /* empty */ - | exp - ; + : /* empty */ + | exp + ; opt_rexpression_list - : /* empty */ - | rexpression_list - ; + : /* empty */ + | rexpression_list + ; rexpression_list - : rexp - | rexpression_list comma rexp - | error - | rexpression_list error - | rexpression_list error rexp - | rexpression_list comma error - ; + : rexp + | rexpression_list comma rexp + | error + | rexpression_list error + | rexpression_list error rexp + | rexpression_list comma error + ; opt_expression_list - : /* empty */ - | expression_list - ; + : /* empty */ + | expression_list + ; expression_list - : exp - | expression_list comma exp - | error - | expression_list error - | expression_list error exp - | expression_list comma error - ; + : exp + | expression_list comma exp + | error + | expression_list error + | expression_list error exp + | expression_list comma error + ; /* Expressions, not including the comma operator. */ -exp : variable ASSIGNOP {} exp - | '(' expression_list r_paren LEX_IN NAME - | exp '|' LEX_GETLINE opt_variable - | exp TWOWAYIO LEX_GETLINE opt_variable - | LEX_GETLINE opt_variable input_redir - | exp LEX_AND exp - | exp LEX_OR exp - | exp MATCHOP exp - | regexp - | '!' regexp %prec UNARY - | exp LEX_IN NAME - | exp RELOP exp - | exp '<' exp - | exp '>' exp - | exp '?' exp ':' exp - | simp_exp - | exp simp_exp %prec CONCAT_OP - ; +exp : variable ASSIGNOP {} exp + | '(' expression_list r_paren LEX_IN NAME + | exp '|' LEX_GETLINE opt_variable + | exp TWOWAYIO LEX_GETLINE opt_variable + | LEX_GETLINE opt_variable input_redir + | exp LEX_AND exp + | exp LEX_OR exp + | exp MATCHOP exp + | regexp + | '!' regexp %prec UNARY + | exp LEX_IN NAME + | exp RELOP exp + | exp '<' exp + | exp '>' exp + | exp '?' exp ':' exp + | simp_exp + | exp simp_exp %prec CONCAT_OP + ; rexp - : variable ASSIGNOP {} rexp - | rexp LEX_AND rexp - | rexp LEX_OR rexp - | LEX_GETLINE opt_variable input_redir - | regexp - | '!' regexp %prec UNARY - | rexp MATCHOP rexp - | rexp LEX_IN NAME - | rexp RELOP rexp - | rexp '?' rexp ':' rexp - | simp_exp - | rexp simp_exp %prec CONCAT_OP - ; + : variable ASSIGNOP {} rexp + | rexp LEX_AND rexp + | rexp LEX_OR rexp + | LEX_GETLINE opt_variable input_redir + | regexp + | '!' regexp %prec UNARY + | rexp MATCHOP rexp + | rexp LEX_IN NAME + | rexp RELOP rexp + | rexp '?' rexp ':' rexp + | simp_exp + | rexp simp_exp %prec CONCAT_OP + ; simp_exp - : non_post_simp_exp - /* Binary operators in order of decreasing precedence. */ - | simp_exp '^' simp_exp - | simp_exp '*' simp_exp - | simp_exp '/' simp_exp - | simp_exp '%' simp_exp - | simp_exp '+' simp_exp - | simp_exp '-' simp_exp - | variable INCREMENT - | variable DECREMENT - ; + : non_post_simp_exp + /* Binary operators in order of decreasing precedence. */ + | simp_exp '^' simp_exp + | simp_exp '*' simp_exp + | simp_exp '/' simp_exp + | simp_exp '%' simp_exp + | simp_exp '+' simp_exp + | simp_exp '-' simp_exp + | variable INCREMENT + | variable DECREMENT + ; non_post_simp_exp - : '!' simp_exp %prec UNARY - | '(' exp r_paren - | LEX_BUILTIN - '(' opt_expression_list r_paren - | LEX_LENGTH '(' opt_expression_list r_paren - | LEX_LENGTH - | FUNC_CALL '(' opt_expression_list r_paren - | variable - | INCREMENT variable - | DECREMENT variable - | YNUMBER - | YSTRING - | '-' simp_exp %prec UNARY - | '+' simp_exp %prec UNARY - ; + : '!' simp_exp %prec UNARY + | '(' exp r_paren + | LEX_BUILTIN + '(' opt_expression_list r_paren + | LEX_LENGTH '(' opt_expression_list r_paren + | LEX_LENGTH + | FUNC_CALL '(' opt_expression_list r_paren + | variable + | INCREMENT variable + | DECREMENT variable + | YNUMBER + | YSTRING + | '-' simp_exp %prec UNARY + | '+' simp_exp %prec UNARY + ; opt_variable - : /* empty */ - | variable - ; + : /* empty */ + | variable + ; variable - : NAME - | NAME '[' expression_list ']' - | '$' non_post_simp_exp - ; + : NAME + | NAME '[' expression_list ']' + | '$' non_post_simp_exp + ; l_brace - : '{' opt_nls - ; + : '{' opt_nls + ; r_brace - : '}' opt_nls - ; + : '}' opt_nls + ; r_paren - : ')' - ; + : ')' + ; opt_semi - : /* empty */ - | semi - ; + : /* empty */ + | semi + ; semi - : ';' - ; + : ';' + ; -comma : ',' opt_nls - ; +comma : ',' opt_nls + ; ]], dnl INPUT @@ -427,8 +427,8 @@ dnl don't like even `print $!4;'. dnl BISON-STDERR [AT_COND_CASE([[canonical LR]], -[[input.y: conflicts: 265 shift/reduce]], -[[input.y: conflicts: 65 shift/reduce]])[ +[[input.y: warning: 265 shift/reduce conflicts [-Wconflicts-sr]]], +[[input.y: warning: 65 shift/reduce conflicts [-Wconflicts-sr]]])[ ]], dnl LAST-STATE @@ -783,33 +783,33 @@ dnl In the case of the syntax error, the parser recovers, so it returns 0. AT_TEST_EXISTING_GRAMMAR([[GNU Cim Grammar]], [[ %token - HACTIVATE HAFTER /*HAND*/ HARRAY HAT - HBEFORE HBEGIN HBOOLEAN - HCHARACTER HCLASS /*HCOMMENT*/ HCONC - HDELAY HDO - HELSE HEND HEQ /*HEQV*/ HEXTERNAL - HFOR - HGE HGO HGOTO HGT - HHIDDEN - HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS - HLABEL HLE HLONG HLT - HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT - /*HOR*/ HOTHERWISE - HPRIOR HPROCEDURE HPROTECTED - HQUA - HREACTIVATE HREAL HREF - HSHORT HSTEP HSWITCH - HTEXT HTHEN HTHIS HTO - HUNTIL - HVALUE HVAR HVIRTUAL - HWHEN HWHILE - - HASSIGNVALUE HASSIGNREF - /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR - HBEGPAR HENDPAR - HEQR HNER - HADD HSUB HMUL HDIV HINTDIV HEXP - HDOTDOTDOT + HACTIVATE HAFTER /*HAND*/ HARRAY HAT + HBEFORE HBEGIN HBOOLEAN + HCHARACTER HCLASS /*HCOMMENT*/ HCONC + HDELAY HDO + HELSE HEND HEQ /*HEQV*/ HEXTERNAL + HFOR + HGE HGO HGOTO HGT + HHIDDEN + HIF /*HIMP*/ HIN HINNER HINSPECT HINTEGER HIS + HLABEL HLE HLONG HLT + HNAME HNE HNEW HNONE /*HNOT*/ HNOTEXT + /*HOR*/ HOTHERWISE + HPRIOR HPROCEDURE HPROTECTED + HQUA + HREACTIVATE HREAL HREF + HSHORT HSTEP HSWITCH + HTEXT HTHEN HTHIS HTO + HUNTIL + HVALUE HVAR HVIRTUAL + HWHEN HWHILE + + HASSIGNVALUE HASSIGNREF + /*HDOT*/ HPAREXPSEPARATOR HLABELSEPARATOR HSTATEMENTSEPARATOR + HBEGPAR HENDPAR + HEQR HNER + HADD HSUB HMUL HDIV HINTDIV HEXP + HDOTDOTDOT %token HIDENTIFIER %token HBOOLEANKONST HINTEGERKONST HCHARACTERKONST @@ -829,7 +829,7 @@ AT_TEST_EXISTING_GRAMMAR([[GNU Cim Grammar]], %left HVALRELOPERATOR HREFRELOPERATOR HOBJRELOPERATOR -%left HCONC +%left HCONC %left HTERMOPERATOR %left UNEAR @@ -845,522 +845,522 @@ AT_TEST_EXISTING_GRAMMAR([[GNU Cim Grammar]], [[ /* GRAMATIKK FOR PROGRAM MODULES */ MAIN_MODULE : {} - MODULS - | error HSTATEMENTSEPARATOR MBEE_DECLSTMS - ; -EXT_DECLARATION : HEXTERNAL - MBEE_TYPE - HPROCEDURE - {} - EXT_LIST - | - HEXTERNAL - HIDENTIFIER - HPROCEDURE - {} - HIDENTIFIER {} - EXTERNAL_KIND_ITEM - | HEXTERNAL - HCLASS - {} - EXT_LIST - - ; -EXTERNAL_KIND_ITEM: EXT_IDENT - HOBJRELOPERATOR - {} - MBEE_TYPE HPROCEDURE - HIDENTIFIER - {} - HEADING EMPTY_BLOCK - {} -/* | - EXT_IDENT - {} - MBEE_REST_EXT_LIST - ; -MBEE_REST_EXT_LIST: /* EMPTY - | HPAREXPSEPARATOR EXT_KIND_LIST - ; -EXT_KIND_LIST : EXT_KIND_ITEM - | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM - ; -EXT_KIND_ITEM : HIDENTIFIER - EXT_IDENT - {}*/ - ; -EMPTY_BLOCK : /*EMPT*/ - | HBEGIN HEND - ; -EXT_LIST : EXT_ITEM - | EXT_LIST HPAREXPSEPARATOR EXT_ITEM - ; -EXT_ITEM : HIDENTIFIER - EXT_IDENT - ; -EXT_IDENT : /* EMPTY */ - | HVALRELOPERATOR {} - HTEXTKONST - ; + MODULS + | error HSTATEMENTSEPARATOR MBEE_DECLSTMS + ; +EXT_DECLARATION : HEXTERNAL + MBEE_TYPE + HPROCEDURE + {} + EXT_LIST + | + HEXTERNAL + HIDENTIFIER + HPROCEDURE + {} + HIDENTIFIER {} + EXTERNAL_KIND_ITEM + | HEXTERNAL + HCLASS + {} + EXT_LIST + + ; +EXTERNAL_KIND_ITEM: EXT_IDENT + HOBJRELOPERATOR + {} + MBEE_TYPE HPROCEDURE + HIDENTIFIER + {} + HEADING EMPTY_BLOCK + {} +/* | + EXT_IDENT + {} + MBEE_REST_EXT_LIST + ; +MBEE_REST_EXT_LIST: /* EMPTY + | HPAREXPSEPARATOR EXT_KIND_LIST + ; +EXT_KIND_LIST : EXT_KIND_ITEM + | EXT_KIND_LIST HPAREXPSEPARATOR EXT_KIND_ITEM + ; +EXT_KIND_ITEM : HIDENTIFIER + EXT_IDENT + {}*/ + ; +EMPTY_BLOCK : /*EMPT*/ + | HBEGIN HEND + ; +EXT_LIST : EXT_ITEM + | EXT_LIST HPAREXPSEPARATOR EXT_ITEM + ; +EXT_ITEM : HIDENTIFIER + EXT_IDENT + ; +EXT_IDENT : /* EMPTY */ + | HVALRELOPERATOR {} + HTEXTKONST + ; /* GRAMATIKK FOR TYPER */ NO_TYPE : /*EMPT*/ - ; + ; MBEE_TYPE : NO_TYPE - | TYPE - ; + | TYPE + ; TYPE : HREF HBEGPAR - HIDENTIFIER - {} - HENDPAR - | HTEXT - | HBOOLEAN - | HCHARACTER - | HSHORT HINTEGER - | HINTEGER - | HREAL - | HLONG HREAL - ; + HIDENTIFIER + {} + HENDPAR + | HTEXT + | HBOOLEAN + | HCHARACTER + | HSHORT HINTEGER + | HINTEGER + | HREAL + | HLONG HREAL + ; /* GRAMATIKK FOR DEL AV SETNINGER */ MBEE_ELSE_PART : /*EMPT*/ -/* | HELSE - HIF - EXPRESSION - HTHEN {} - BLOCK {} - MBEE_ELSE_PART {}*/ - | HELSE {} - BLOCK - ; +/* | HELSE + HIF + EXPRESSION + HTHEN {} + BLOCK {} + MBEE_ELSE_PART {}*/ + | HELSE {} + BLOCK + ; FOR_LIST : FOR_LIST_ELEMENT - | FOR_LIST_ELEMENT - HPAREXPSEPARATOR - FOR_LIST - ; + | FOR_LIST_ELEMENT + HPAREXPSEPARATOR + FOR_LIST + ; FOR_LIST_ELEMENT: EXPRESSION - MBEE_F_L_EL_R_PT - ; + MBEE_F_L_EL_R_PT + ; MBEE_F_L_EL_R_PT: /*EMPT*/ - | HWHILE - EXPRESSION - | HSTEP - EXPRESSION - HUNTIL - EXPRESSION - ; + | HWHILE + EXPRESSION + | HSTEP + EXPRESSION + HUNTIL + EXPRESSION + ; GOTO : HGO - HTO - | HGOTO - ; + HTO + | HGOTO + ; CONN_STATE_R_PT : WHEN_CLAUSE_LIST - | HDO {} - BLOCK - ; + | HDO {} + BLOCK + ; WHEN_CLAUSE_LIST: HWHEN - HIDENTIFIER - HDO {} - BLOCK - | WHEN_CLAUSE_LIST - HWHEN - HIDENTIFIER - HDO {} - BLOCK - ; + HIDENTIFIER + HDO {} + BLOCK + | WHEN_CLAUSE_LIST + HWHEN + HIDENTIFIER + HDO {} + BLOCK + ; MBEE_OTWI_CLAUS : /*EMPT*/ - | HOTHERWISE {} - - BLOCK - ; -ACTIVATOR : HACTIVATE - | HREACTIVATE - ; -SCHEDULE : /*EMPT*/ - | ATDELAY EXPRESSION {} - PRIOR - | BEFOREAFTER {} - EXPRESSION - ; -ATDELAY : HAT - | HDELAY - ; -BEFOREAFTER : HBEFORE - | HAFTER - ; -PRIOR : /*EMPT*/ - | HPRIOR - ; + | HOTHERWISE {} + + BLOCK + ; +ACTIVATOR : HACTIVATE + | HREACTIVATE + ; +SCHEDULE : /*EMPT*/ + | ATDELAY EXPRESSION {} + PRIOR + | BEFOREAFTER {} + EXPRESSION + ; +ATDELAY : HAT + | HDELAY + ; +BEFOREAFTER : HBEFORE + | HAFTER + ; +PRIOR : /*EMPT*/ + | HPRIOR + ; /* GRAMATIKK FOR SETNINGER OG DEKLARASJONER */ MODULSTATEMENT : HWHILE - EXPRESSION - HDO {} - BLOCK - | HIF - EXPRESSION - HTHEN {} - BLOCK {} - MBEE_ELSE_PART - | HFOR - HIDENTIFIER - HASSIGN {} - FOR_LIST - HDO {} - BLOCK - | GOTO - EXPRESSION - | HINSPECT - EXPRESSION {} - CONN_STATE_R_PT - {} - MBEE_OTWI_CLAUS - | HINNER - | HIDENTIFIER - HLABELSEPARATOR - {} - DECLSTATEMENT - | EXPRESSION_SIMP - HBEGIN - {} - IMPORT_SPEC_MODULE - {} - MBEE_DECLSTMS - HEND - | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR - MBEE_DECLSTMS HEND - | EXPRESSION_SIMP HBEGIN error HEND - | EXPRESSION_SIMP - | ACTIVATOR EXPRESSION SCHEDULE - | HBEGIN - {} - MBEE_DECLSTMS - HEND - | MBEE_TYPE HPROCEDURE - HIDENTIFIER - {} - HEADING BLOCK - | HIDENTIFIER - HCLASS - NO_TYPE - {} - IMPORT_SPEC_MODULE - HIDENTIFIER - {} - HEADING - BLOCK - | HCLASS - NO_TYPE - HIDENTIFIER - {} - HEADING - BLOCK - | EXT_DECLARATION - | /*EMPT*/ - ; + EXPRESSION + HDO {} + BLOCK + | HIF + EXPRESSION + HTHEN {} + BLOCK {} + MBEE_ELSE_PART + | HFOR + HIDENTIFIER + HASSIGN {} + FOR_LIST + HDO {} + BLOCK + | GOTO + EXPRESSION + | HINSPECT + EXPRESSION {} + CONN_STATE_R_PT + {} + MBEE_OTWI_CLAUS + | HINNER + | HIDENTIFIER + HLABELSEPARATOR + {} + DECLSTATEMENT + | EXPRESSION_SIMP + HBEGIN + {} + IMPORT_SPEC_MODULE + {} + MBEE_DECLSTMS + HEND + | EXPRESSION_SIMP HBEGIN error HSTATEMENTSEPARATOR + MBEE_DECLSTMS HEND + | EXPRESSION_SIMP HBEGIN error HEND + | EXPRESSION_SIMP + | ACTIVATOR EXPRESSION SCHEDULE + | HBEGIN + {} + MBEE_DECLSTMS + HEND + | MBEE_TYPE HPROCEDURE + HIDENTIFIER + {} + HEADING BLOCK + | HIDENTIFIER + HCLASS + NO_TYPE + {} + IMPORT_SPEC_MODULE + HIDENTIFIER + {} + HEADING + BLOCK + | HCLASS + NO_TYPE + HIDENTIFIER + {} + HEADING + BLOCK + | EXT_DECLARATION + | /*EMPT*/ + ; IMPORT_SPEC_MODULE: - ; -DECLSTATEMENT : MODULSTATEMENT - | TYPE - HIDENTIFIER - MBEE_CONSTANT - HPAREXPSEPARATOR - {} - IDENTIFIER_LISTC - | TYPE - HIDENTIFIER - MBEE_CONSTANT - | MBEE_TYPE - HARRAY {} - ARR_SEGMENT_LIST - | HSWITCH - HIDENTIFIER - HASSIGN {} - SWITCH_LIST - ; + ; +DECLSTATEMENT : MODULSTATEMENT + | TYPE + HIDENTIFIER + MBEE_CONSTANT + HPAREXPSEPARATOR + {} + IDENTIFIER_LISTC + | TYPE + HIDENTIFIER + MBEE_CONSTANT + | MBEE_TYPE + HARRAY {} + ARR_SEGMENT_LIST + | HSWITCH + HIDENTIFIER + HASSIGN {} + SWITCH_LIST + ; BLOCK : DECLSTATEMENT - | HBEGIN MBEE_DECLSTMS HEND - | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND - | HBEGIN error HEND - ; + | HBEGIN MBEE_DECLSTMS HEND + | HBEGIN error HSTATEMENTSEPARATOR MBEE_DECLSTMS HEND + | HBEGIN error HEND + ; MBEE_DECLSTMS : MBEE_DECLSTMSU - ; + ; MBEE_DECLSTMSU : DECLSTATEMENT - | MBEE_DECLSTMSU - HSTATEMENTSEPARATOR - DECLSTATEMENT - ; -MODULS : MODULSTATEMENT - | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT - ; + | MBEE_DECLSTMSU + HSTATEMENTSEPARATOR + DECLSTATEMENT + ; +MODULS : MODULSTATEMENT + | MODULS HSTATEMENTSEPARATOR MODULSTATEMENT + ; /* GRAMATIKK FOR DEL AV DEKLARASJONER */ ARR_SEGMENT_LIST: ARR_SEGMENT - | ARR_SEGMENT_LIST - HPAREXPSEPARATOR - ARR_SEGMENT - ; -ARR_SEGMENT : ARRAY_SEGMENT - HBEGPAR - BAUND_PAIR_LIST HENDPAR - ; + | ARR_SEGMENT_LIST + HPAREXPSEPARATOR + ARR_SEGMENT + ; +ARR_SEGMENT : ARRAY_SEGMENT + HBEGPAR + BAUND_PAIR_LIST HENDPAR + ; ARRAY_SEGMENT : ARRAY_SEGMENT_EL {} - | ARRAY_SEGMENT_EL - HPAREXPSEPARATOR - ARRAY_SEGMENT - ; + | ARRAY_SEGMENT_EL + HPAREXPSEPARATOR + ARRAY_SEGMENT + ; ARRAY_SEGMENT_EL: HIDENTIFIER - ; + ; BAUND_PAIR_LIST : BAUND_PAIR - | BAUND_PAIR - HPAREXPSEPARATOR - BAUND_PAIR_LIST - ; + | BAUND_PAIR + HPAREXPSEPARATOR + BAUND_PAIR_LIST + ; BAUND_PAIR : EXPRESSION - HLABELSEPARATOR - EXPRESSION - ; + HLABELSEPARATOR + EXPRESSION + ; SWITCH_LIST : EXPRESSION - | EXPRESSION - HPAREXPSEPARATOR - SWITCH_LIST - ; + | EXPRESSION + HPAREXPSEPARATOR + SWITCH_LIST + ; HEADING : MBEE_FMAL_PAR_P HSTATEMENTSEPARATOR {} - MBEE_MODE_PART {} - MBEE_SPEC_PART {} - MBEE_PROT_PART {} - MBEE_VIRT_PART - ; + MBEE_MODE_PART {} + MBEE_SPEC_PART {} + MBEE_PROT_PART {} + MBEE_VIRT_PART + ; MBEE_FMAL_PAR_P : /*EMPT*/ - | FMAL_PAR_PART - ; + | FMAL_PAR_PART + ; FMAL_PAR_PART : HBEGPAR NO_TYPE - MBEE_LISTV HENDPAR - ; + MBEE_LISTV HENDPAR + ; MBEE_LISTV : /*EMPT*/ - | LISTV - ; + | LISTV + ; LISTV : HIDENTIFIER - | FPP_CATEG HDOTDOTDOT - | HIDENTIFIER {} - HPAREXPSEPARATOR LISTV - | FPP_SPEC - | FPP_SPEC - HPAREXPSEPARATOR LISTV - ; + | FPP_CATEG HDOTDOTDOT + | HIDENTIFIER {} + HPAREXPSEPARATOR LISTV + | FPP_SPEC + | FPP_SPEC + HPAREXPSEPARATOR LISTV + ; FPP_HEADING : HBEGPAR NO_TYPE - FPP_MBEE_LISTV HENDPAR - ; + FPP_MBEE_LISTV HENDPAR + ; FPP_MBEE_LISTV : /*EMPT*/ - | FPP_LISTV - ; -FPP_LISTV : FPP_CATEG HDOTDOTDOT - | FPP_SPEC - | FPP_SPEC - HPAREXPSEPARATOR LISTV - ; + | FPP_LISTV + ; +FPP_LISTV : FPP_CATEG HDOTDOTDOT + | FPP_SPEC + | FPP_SPEC + HPAREXPSEPARATOR LISTV + ; FPP_SPEC : FPP_CATEG SPECIFIER HIDENTIFIER - | FPP_CATEG FPP_PROC_DECL_IN_SPEC - ; + | FPP_CATEG FPP_PROC_DECL_IN_SPEC + ; FPP_CATEG : HNAME HLABELSEPARATOR - | HVALUE HLABELSEPARATOR - | HVAR HLABELSEPARATOR - | /*EMPT*/ - ; -FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE - HIDENTIFIER - {} - FPP_HEADING {} { /* Yes, two "final" actions. */ } - ; + | HVALUE HLABELSEPARATOR + | HVAR HLABELSEPARATOR + | /*EMPT*/ + ; +FPP_PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE + HIDENTIFIER + {} + FPP_HEADING {} { /* Yes, two "final" actions. */ } + ; IDENTIFIER_LISTV: HIDENTIFIER - | HDOTDOTDOT - | HIDENTIFIER {} - HPAREXPSEPARATOR IDENTIFIER_LISTV - ; + | HDOTDOTDOT + | HIDENTIFIER {} + HPAREXPSEPARATOR IDENTIFIER_LISTV + ; MBEE_MODE_PART : /*EMPT*/ - | MODE_PART - ; + | MODE_PART + ; MODE_PART : NAME_PART - | VALUE_PART - | VAR_PART - | NAME_PART VALUE_PART - | VALUE_PART NAME_PART - | NAME_PART VAR_PART - | VAR_PART NAME_PART - | VALUE_PART VAR_PART - | VAR_PART VALUE_PART - | VAR_PART NAME_PART VALUE_PART - | NAME_PART VAR_PART VALUE_PART - | NAME_PART VALUE_PART VAR_PART - | VAR_PART VALUE_PART NAME_PART - | VALUE_PART VAR_PART NAME_PART - | VALUE_PART NAME_PART VAR_PART - ; + | VALUE_PART + | VAR_PART + | NAME_PART VALUE_PART + | VALUE_PART NAME_PART + | NAME_PART VAR_PART + | VAR_PART NAME_PART + | VALUE_PART VAR_PART + | VAR_PART VALUE_PART + | VAR_PART NAME_PART VALUE_PART + | NAME_PART VAR_PART VALUE_PART + | NAME_PART VALUE_PART VAR_PART + | VAR_PART VALUE_PART NAME_PART + | VALUE_PART VAR_PART NAME_PART + | VALUE_PART NAME_PART VAR_PART + ; NAME_PART : HNAME {} - IDENTIFIER_LISTV - HSTATEMENTSEPARATOR - ; + IDENTIFIER_LISTV + HSTATEMENTSEPARATOR + ; VAR_PART : HVAR {} - IDENTIFIER_LISTV - HSTATEMENTSEPARATOR - ; + IDENTIFIER_LISTV + HSTATEMENTSEPARATOR + ; VALUE_PART : HVALUE {} - IDENTIFIER_LISTV HSTATEMENTSEPARATOR - ; + IDENTIFIER_LISTV HSTATEMENTSEPARATOR + ; MBEE_SPEC_PART : /*EMPT*/ - | SPEC_PART - ; + | SPEC_PART + ; SPEC_PART : ONE_SPEC - | SPEC_PART ONE_SPEC - ; -ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR - | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR - {} - PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR - | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR - | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR - | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR - IDENTIFIER_LIST HSTATEMENTSEPARATOR - ; + | SPEC_PART ONE_SPEC + ; +ONE_SPEC : SPECIFIER IDENTIFIER_LIST HSTATEMENTSEPARATOR + | NO_TYPE HPROCEDURE HIDENTIFIER HOBJRELOPERATOR + {} + PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR + | FPP_PROC_DECL_IN_SPEC HSTATEMENTSEPARATOR + | MBEE_TYPE HPROCEDURE HIDENTIFIER HSTATEMENTSEPARATOR + | MBEE_TYPE HPROCEDURE HIDENTIFIER HPAREXPSEPARATOR + IDENTIFIER_LIST HSTATEMENTSEPARATOR + ; SPECIFIER : TYPE - | MBEE_TYPE - HARRAY - | HLABEL - | HSWITCH - ; -PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE - HIDENTIFIER - {} - HEADING - {} - MBEE_BEGIN_END - ; -MBEE_BEGIN_END : /* EMPTY */ - | HBEGIN HEND - ; + | MBEE_TYPE + HARRAY + | HLABEL + | HSWITCH + ; +PROC_DECL_IN_SPEC: MBEE_TYPE HPROCEDURE + HIDENTIFIER + {} + HEADING + {} + MBEE_BEGIN_END + ; +MBEE_BEGIN_END : /* EMPTY */ + | HBEGIN HEND + ; MBEE_PROT_PART : /*EMPT*/ - | PROTECTION_PART - ; + | PROTECTION_PART + ; PROTECTION_PART : PROT_SPECIFIER IDENTIFIER_LIST - HSTATEMENTSEPARATOR - | PROTECTION_PART PROT_SPECIFIER - IDENTIFIER_LIST HSTATEMENTSEPARATOR - ; + HSTATEMENTSEPARATOR + | PROTECTION_PART PROT_SPECIFIER + IDENTIFIER_LIST HSTATEMENTSEPARATOR + ; PROT_SPECIFIER : HHIDDEN - | HPROTECTED - | HHIDDEN - HPROTECTED - | HPROTECTED - HHIDDEN - ; + | HPROTECTED + | HHIDDEN + HPROTECTED + | HPROTECTED + HHIDDEN + ; MBEE_VIRT_PART : /*EMPT*/ - | VIRTUAL_PART - ; + | VIRTUAL_PART + ; VIRTUAL_PART : HVIRTUAL - HLABELSEPARATOR - MBEE_SPEC_PART - ; + HLABELSEPARATOR + MBEE_SPEC_PART + ; IDENTIFIER_LIST : HIDENTIFIER - | IDENTIFIER_LIST HPAREXPSEPARATOR - HIDENTIFIER - ; + | IDENTIFIER_LIST HPAREXPSEPARATOR + HIDENTIFIER + ; IDENTIFIER_LISTC: HIDENTIFIER - MBEE_CONSTANT - | IDENTIFIER_LISTC HPAREXPSEPARATOR - HIDENTIFIER - MBEE_CONSTANT - ; -MBEE_CONSTANT : /* EMPTY */ - | HVALRELOPERATOR - {} - EXPRESSION - ; + MBEE_CONSTANT + | IDENTIFIER_LISTC HPAREXPSEPARATOR + HIDENTIFIER + MBEE_CONSTANT + ; +MBEE_CONSTANT : /* EMPTY */ + | HVALRELOPERATOR + {} + EXPRESSION + ; /* GRAMATIKK FOR UTTRYKK */ EXPRESSION : EXPRESSION_SIMP - | HIF - EXPRESSION - HTHEN - EXPRESSION - HELSE - EXPRESSION - ; -EXPRESSION_SIMP : EXPRESSION_SIMP - HASSIGN - EXPRESSION - | - - EXPRESSION_SIMP - HCONC - EXPRESSION_SIMP - | EXPRESSION_SIMP HOR - HELSE - EXPRESSION_SIMP - %prec HORELSE - | EXPRESSION_SIMP HAND - HTHEN - EXPRESSION_SIMP - %prec HANDTHEN - | EXPRESSION_SIMP - HEQV EXPRESSION_SIMP - | EXPRESSION_SIMP - HIMP EXPRESSION_SIMP - | EXPRESSION_SIMP - HOR EXPRESSION_SIMP - | EXPRESSION_SIMP - HAND EXPRESSION_SIMP - | HNOT EXPRESSION_SIMP - | EXPRESSION_SIMP - HVALRELOPERATOR - EXPRESSION_SIMP - | EXPRESSION_SIMP - HREFRELOPERATOR - EXPRESSION_SIMP - | EXPRESSION_SIMP - HOBJRELOPERATOR - EXPRESSION_SIMP - | HTERMOPERATOR - EXPRESSION_SIMP %prec UNEAR - | EXPRESSION_SIMP - HTERMOPERATOR - EXPRESSION_SIMP - | EXPRESSION_SIMP - HFACTOROPERATOR - EXPRESSION_SIMP - | EXPRESSION_SIMP - HPRIMARYOPERATOR - EXPRESSION_SIMP - | HBEGPAR - EXPRESSION HENDPAR - | HTEXTKONST - | HCHARACTERKONST - | HREALKONST - | HINTEGERKONST - | HBOOLEANKONST - | HNONE - | HIDENTIFIER - {} - MBEE_ARG_R_PT - | HTHIS HIDENTIFIER - | HNEW - HIDENTIFIER - ARG_R_PT - | EXPRESSION_SIMP - HDOT - EXPRESSION_SIMP - | EXPRESSION_SIMP - HQUA HIDENTIFIER - ; + | HIF + EXPRESSION + HTHEN + EXPRESSION + HELSE + EXPRESSION + ; +EXPRESSION_SIMP : EXPRESSION_SIMP + HASSIGN + EXPRESSION + | + + EXPRESSION_SIMP + HCONC + EXPRESSION_SIMP + | EXPRESSION_SIMP HOR + HELSE + EXPRESSION_SIMP + %prec HORELSE + | EXPRESSION_SIMP HAND + HTHEN + EXPRESSION_SIMP + %prec HANDTHEN + | EXPRESSION_SIMP + HEQV EXPRESSION_SIMP + | EXPRESSION_SIMP + HIMP EXPRESSION_SIMP + | EXPRESSION_SIMP + HOR EXPRESSION_SIMP + | EXPRESSION_SIMP + HAND EXPRESSION_SIMP + | HNOT EXPRESSION_SIMP + | EXPRESSION_SIMP + HVALRELOPERATOR + EXPRESSION_SIMP + | EXPRESSION_SIMP + HREFRELOPERATOR + EXPRESSION_SIMP + | EXPRESSION_SIMP + HOBJRELOPERATOR + EXPRESSION_SIMP + | HTERMOPERATOR + EXPRESSION_SIMP %prec UNEAR + | EXPRESSION_SIMP + HTERMOPERATOR + EXPRESSION_SIMP + | EXPRESSION_SIMP + HFACTOROPERATOR + EXPRESSION_SIMP + | EXPRESSION_SIMP + HPRIMARYOPERATOR + EXPRESSION_SIMP + | HBEGPAR + EXPRESSION HENDPAR + | HTEXTKONST + | HCHARACTERKONST + | HREALKONST + | HINTEGERKONST + | HBOOLEANKONST + | HNONE + | HIDENTIFIER + {} + MBEE_ARG_R_PT + | HTHIS HIDENTIFIER + | HNEW + HIDENTIFIER + ARG_R_PT + | EXPRESSION_SIMP + HDOT + EXPRESSION_SIMP + | EXPRESSION_SIMP + HQUA HIDENTIFIER + ; ARG_R_PT : /*EMPTY*/ - | HBEGPAR - ARGUMENT_LIST HENDPAR - ; + | HBEGPAR + ARGUMENT_LIST HENDPAR + ; MBEE_ARG_R_PT : /*EMPTY*/ - | HBEGPAR - ARGUMENT_LIST HENDPAR - ; + | HBEGPAR + ARGUMENT_LIST HENDPAR + ; ARGUMENT_LIST : EXPRESSION - | EXPRESSION - HPAREXPSEPARATOR - ARGUMENT_LIST - ; + | EXPRESSION + HPAREXPSEPARATOR + ARGUMENT_LIST + ; ]], dnl INPUT @@ -1368,8 +1368,10 @@ dnl INPUT dnl BISON-STDERR [AT_COND_CASE([[canonical LR]], -[[input.y: conflicts: 1876 shift/reduce, 144 reduce/reduce]], -[[input.y: conflicts: 78 shift/reduce, 10 reduce/reduce]])[ +[[input.y: warning: 1876 shift/reduce conflicts [-Wconflicts-sr] +input.y: warning: 144 reduce/reduce conflicts [-Wconflicts-rr]]], +[[input.y: warning: 78 shift/reduce conflicts [-Wconflicts-sr] +input.y: warning: 10 reduce/reduce conflicts [-Wconflicts-rr]]])[ ]], dnl LAST-STATE @@ -1570,367 +1572,367 @@ works */ ]], [[ top: - optional_separator - | element_list - ; + optional_separator + | element_list + ; element_list: - optional_separator middle_element_list optional_separator - ; + optional_separator middle_element_list optional_separator + ; middle_element_list: - element - | middle_element_list separator element - ; + element + | middle_element_list separator element + ; optional_separator: - /* empty */ - | separator - ; + /* empty */ + | separator + ; separator: - ';' - | separator ';' - ; + ';' + | separator ';' + ; placeless_element: - VARIABLE '=' any_expr - | VARIABLE ':' '=' any_expr - | UP - | DOWN - | LEFT - | RIGHT - | COMMAND_LINE - | COMMAND print_args - | PRINT print_args - | SH - {} - DELIMITED - | COPY TEXT - | COPY TEXT THROUGH - {} - DELIMITED - {} - until - | COPY THROUGH - {} - DELIMITED - {} - until - | FOR VARIABLE '=' expr TO expr optional_by DO - {} - DELIMITED - | simple_if - | simple_if ELSE - {} - DELIMITED - | reset_variables - | RESET - ; + VARIABLE '=' any_expr + | VARIABLE ':' '=' any_expr + | UP + | DOWN + | LEFT + | RIGHT + | COMMAND_LINE + | COMMAND print_args + | PRINT print_args + | SH + {} + DELIMITED + | COPY TEXT + | COPY TEXT THROUGH + {} + DELIMITED + {} + until + | COPY THROUGH + {} + DELIMITED + {} + until + | FOR VARIABLE '=' expr TO expr optional_by DO + {} + DELIMITED + | simple_if + | simple_if ELSE + {} + DELIMITED + | reset_variables + | RESET + ; reset_variables: - RESET VARIABLE - | reset_variables VARIABLE - | reset_variables ',' VARIABLE - ; + RESET VARIABLE + | reset_variables VARIABLE + | reset_variables ',' VARIABLE + ; print_args: - print_arg - | print_args print_arg - ; + print_arg + | print_args print_arg + ; print_arg: - expr %prec ',' - | text - | position %prec ',' - ; + expr %prec ',' + | text + | position %prec ',' + ; simple_if: - IF any_expr THEN - {} - DELIMITED - ; + IF any_expr THEN + {} + DELIMITED + ; until: - /* empty */ - | UNTIL TEXT - ; + /* empty */ + | UNTIL TEXT + ; any_expr: - expr - | text_expr - ; + expr + | text_expr + ; text_expr: - text EQUALEQUAL text - | text NOTEQUAL text - | text_expr ANDAND text_expr - | text_expr ANDAND expr - | expr ANDAND text_expr - | text_expr OROR text_expr - | text_expr OROR expr - | expr OROR text_expr - | '!' text_expr - ; + text EQUALEQUAL text + | text NOTEQUAL text + | text_expr ANDAND text_expr + | text_expr ANDAND expr + | expr ANDAND text_expr + | text_expr OROR text_expr + | text_expr OROR expr + | expr OROR text_expr + | '!' text_expr + ; optional_by: - /* empty */ - | BY expr - | BY '*' expr - ; + /* empty */ + | BY expr + | BY '*' expr + ; element: - object_spec - | LABEL ':' optional_separator element - | LABEL ':' optional_separator position_not_place - | LABEL ':' optional_separator place - | '{' {} element_list '}' - {} - optional_element - | placeless_element - ; + object_spec + | LABEL ':' optional_separator element + | LABEL ':' optional_separator position_not_place + | LABEL ':' optional_separator place + | '{' {} element_list '}' + {} + optional_element + | placeless_element + ; optional_element: - /* empty */ - | element - ; + /* empty */ + | element + ; object_spec: - BOX - | CIRCLE - | ELLIPSE - | ARC - | LINE - | ARROW - | MOVE - | SPLINE - | text %prec TEXT - | PLOT expr - | PLOT expr text - | '[' - {} - element_list ']' - | object_spec HEIGHT expr - | object_spec RADIUS expr - | object_spec WIDTH expr - | object_spec DIAMETER expr - | object_spec expr %prec HEIGHT - | object_spec UP - | object_spec UP expr - | object_spec DOWN - | object_spec DOWN expr - | object_spec RIGHT - | object_spec RIGHT expr - | object_spec LEFT - | object_spec LEFT expr - | object_spec FROM position - | object_spec TO position - | object_spec AT position - | object_spec WITH path - | object_spec WITH position %prec ',' - | object_spec BY expr_pair - | object_spec THEN - | object_spec SOLID - | object_spec DOTTED - | object_spec DOTTED expr - | object_spec DASHED - | object_spec DASHED expr - | object_spec FILL - | object_spec FILL expr - | object_spec SHADED text - | object_spec COLORED text - | object_spec OUTLINED text - | object_spec CHOP - | object_spec CHOP expr - | object_spec SAME - | object_spec INVISIBLE - | object_spec LEFT_ARROW_HEAD - | object_spec RIGHT_ARROW_HEAD - | object_spec DOUBLE_ARROW_HEAD - | object_spec CW - | object_spec CCW - | object_spec text %prec TEXT - | object_spec LJUST - | object_spec RJUST - | object_spec ABOVE - | object_spec BELOW - | object_spec THICKNESS expr - | object_spec ALIGNED - ; + BOX + | CIRCLE + | ELLIPSE + | ARC + | LINE + | ARROW + | MOVE + | SPLINE + | text %prec TEXT + | PLOT expr + | PLOT expr text + | '[' + {} + element_list ']' + | object_spec HEIGHT expr + | object_spec RADIUS expr + | object_spec WIDTH expr + | object_spec DIAMETER expr + | object_spec expr %prec HEIGHT + | object_spec UP + | object_spec UP expr + | object_spec DOWN + | object_spec DOWN expr + | object_spec RIGHT + | object_spec RIGHT expr + | object_spec LEFT + | object_spec LEFT expr + | object_spec FROM position + | object_spec TO position + | object_spec AT position + | object_spec WITH path + | object_spec WITH position %prec ',' + | object_spec BY expr_pair + | object_spec THEN + | object_spec SOLID + | object_spec DOTTED + | object_spec DOTTED expr + | object_spec DASHED + | object_spec DASHED expr + | object_spec FILL + | object_spec FILL expr + | object_spec SHADED text + | object_spec COLORED text + | object_spec OUTLINED text + | object_spec CHOP + | object_spec CHOP expr + | object_spec SAME + | object_spec INVISIBLE + | object_spec LEFT_ARROW_HEAD + | object_spec RIGHT_ARROW_HEAD + | object_spec DOUBLE_ARROW_HEAD + | object_spec CW + | object_spec CCW + | object_spec text %prec TEXT + | object_spec LJUST + | object_spec RJUST + | object_spec ABOVE + | object_spec BELOW + | object_spec THICKNESS expr + | object_spec ALIGNED + ; text: - TEXT - | SPRINTF '(' TEXT sprintf_args ')' - ; + TEXT + | SPRINTF '(' TEXT sprintf_args ')' + ; sprintf_args: - /* empty */ - | sprintf_args ',' expr - ; + /* empty */ + | sprintf_args ',' expr + ; position: - position_not_place - | place - ; + position_not_place + | place + ; position_not_place: - expr_pair - | position '+' expr_pair - | position '-' expr_pair - | '(' position ',' position ')' - | expr between position AND position - | expr '<' position ',' position '>' - ; + expr_pair + | position '+' expr_pair + | position '-' expr_pair + | '(' position ',' position ')' + | expr between position AND position + | expr '<' position ',' position '>' + ; between: - BETWEEN - | OF THE WAY BETWEEN - ; + BETWEEN + | OF THE WAY BETWEEN + ; expr_pair: - expr ',' expr - | '(' expr_pair ')' - ; + expr ',' expr + | '(' expr_pair ')' + ; place: - /* line at A left == line (at A) left */ - label %prec CHOP - | label corner - | corner label - | corner OF label - | HERE - ; + /* line at A left == line (at A) left */ + label %prec CHOP + | label corner + | corner label + | corner OF label + | HERE + ; label: - LABEL - | nth_primitive - | label '.' LABEL - ; + LABEL + | nth_primitive + | label '.' LABEL + ; ordinal: - ORDINAL - | '`' any_expr TH - ; + ORDINAL + | '`' any_expr TH + ; optional_ordinal_last: - LAST - | ordinal LAST - ; + LAST + | ordinal LAST + ; nth_primitive: - ordinal object_type - | optional_ordinal_last object_type - ; + ordinal object_type + | optional_ordinal_last object_type + ; object_type: - BOX - | CIRCLE - | ELLIPSE - | ARC - | LINE - | ARROW - | SPLINE - | '[' ']' - | TEXT - ; + BOX + | CIRCLE + | ELLIPSE + | ARC + | LINE + | ARROW + | SPLINE + | '[' ']' + | TEXT + ; label_path: - '.' LABEL - | label_path '.' LABEL - ; + '.' LABEL + | label_path '.' LABEL + ; relative_path: - corner %prec CHOP - /* give this a lower precedence than LEFT and RIGHT so that - [A: box] with .A left == [A: box] with (.A left) */ - | label_path %prec TEXT - | label_path corner - ; + corner %prec CHOP + /* give this a lower precedence than LEFT and RIGHT so that + [A: box] with .A left == [A: box] with (.A left) */ + | label_path %prec TEXT + | label_path corner + ; path: - relative_path - | '(' relative_path ',' relative_path ')' - {} - /* The rest of these rules are a compatibility sop. */ - | ORDINAL LAST object_type relative_path - | LAST object_type relative_path - | ORDINAL object_type relative_path - | LABEL relative_path - ; + relative_path + | '(' relative_path ',' relative_path ')' + {} + /* The rest of these rules are a compatibility sop. */ + | ORDINAL LAST object_type relative_path + | LAST object_type relative_path + | ORDINAL object_type relative_path + | LABEL relative_path + ; corner: - DOT_N - | DOT_E - | DOT_W - | DOT_S - | DOT_NE - | DOT_SE - | DOT_NW - | DOT_SW - | DOT_C - | DOT_START - | DOT_END - | TOP - | BOTTOM - | LEFT - | RIGHT - | UPPER LEFT - | LOWER LEFT - | UPPER RIGHT - | LOWER RIGHT - | LEFT_CORNER - | RIGHT_CORNER - | UPPER LEFT_CORNER - | LOWER LEFT_CORNER - | UPPER RIGHT_CORNER - | LOWER RIGHT_CORNER - | NORTH - | SOUTH - | EAST - | WEST - | CENTER - | START - | END - ; + DOT_N + | DOT_E + | DOT_W + | DOT_S + | DOT_NE + | DOT_SE + | DOT_NW + | DOT_SW + | DOT_C + | DOT_START + | DOT_END + | TOP + | BOTTOM + | LEFT + | RIGHT + | UPPER LEFT + | LOWER LEFT + | UPPER RIGHT + | LOWER RIGHT + | LEFT_CORNER + | RIGHT_CORNER + | UPPER LEFT_CORNER + | LOWER LEFT_CORNER + | UPPER RIGHT_CORNER + | LOWER RIGHT_CORNER + | NORTH + | SOUTH + | EAST + | WEST + | CENTER + | START + | END + ; expr: - VARIABLE - | NUMBER - | place DOT_X - | place DOT_Y - | place DOT_HT - | place DOT_WID - | place DOT_RAD - | expr '+' expr - | expr '-' expr - | expr '*' expr - | expr '/' expr - | expr '%' expr - | expr '^' expr - | '-' expr %prec '!' - | '(' any_expr ')' - | SIN '(' any_expr ')' - | COS '(' any_expr ')' - | ATAN2 '(' any_expr ',' any_expr ')' - | LOG '(' any_expr ')' - | EXP '(' any_expr ')' - | SQRT '(' any_expr ')' - | K_MAX '(' any_expr ',' any_expr ')' - | K_MIN '(' any_expr ',' any_expr ')' - | INT '(' any_expr ')' - | RAND '(' any_expr ')' - | RAND '(' ')' - | SRAND '(' any_expr ')' - | expr '<' expr - | expr LESSEQUAL expr - | expr '>' expr - | expr GREATEREQUAL expr - | expr EQUALEQUAL expr - | expr NOTEQUAL expr - | expr ANDAND expr - | expr OROR expr - | '!' expr - ; + VARIABLE + | NUMBER + | place DOT_X + | place DOT_Y + | place DOT_HT + | place DOT_WID + | place DOT_RAD + | expr '+' expr + | expr '-' expr + | expr '*' expr + | expr '/' expr + | expr '%' expr + | expr '^' expr + | '-' expr %prec '!' + | '(' any_expr ')' + | SIN '(' any_expr ')' + | COS '(' any_expr ')' + | ATAN2 '(' any_expr ',' any_expr ')' + | LOG '(' any_expr ')' + | EXP '(' any_expr ')' + | SQRT '(' any_expr ')' + | K_MAX '(' any_expr ',' any_expr ')' + | K_MIN '(' any_expr ',' any_expr ')' + | INT '(' any_expr ')' + | RAND '(' any_expr ')' + | RAND '(' ')' + | SRAND '(' any_expr ')' + | expr '<' expr + | expr LESSEQUAL expr + | expr '>' expr + | expr GREATEREQUAL expr + | expr EQUALEQUAL expr + | expr NOTEQUAL expr + | expr ANDAND expr + | expr OROR expr + | '!' expr + ; ]], dnl INPUT @@ -1951,7 +1953,7 @@ dnl without being followed by "of".) [[VARIABLE, '=', LABEL, LEFT, DOT_X]], dnl BISON-STDERR -[[input.y:470.11-48: warning: rule useless in parser due to conflicts: path: ORDINAL LAST object_type relative_path +[[input.y:470.11-48: warning: rule useless in parser due to conflicts: path: ORDINAL LAST object_type relative_path [-Wother] ]], dnl LAST-STATE diff --git a/tests/glr-regression.at b/tests/glr-regression.at index aacc57c8..b376c1c0 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -93,8 +93,8 @@ yylex (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr1.c glr-regr1.y]], 0, [], -[glr-regr1.y: conflicts: 1 shift/reduce -]) +[[glr-regr1.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +]]) AT_COMPILE([glr-regr1]) AT_PARSER_CHECK([[echo BPBPB | ./glr-regr1]], 0, [[E -> 'B' @@ -208,8 +208,8 @@ main (int argc, char **argv) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr2a.c glr-regr2a.y]], 0, [], -[glr-regr2a.y: conflicts: 2 shift/reduce -]) +[[glr-regr2a.y: warning: 2 shift/reduce conflicts [-Wconflicts-sr] +]]) AT_COMPILE([glr-regr2a]) AT_PARSER_CHECK([[echo s VARIABLE_1 t v x q | ./glr-regr2a]], 0, @@ -325,8 +325,9 @@ main(int argc, char* argv[]) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr3.c glr-regr3.y]], 0, [], -[glr-regr3.y: conflicts: 1 shift/reduce, 1 reduce/reduce -]) +[[glr-regr3.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +glr-regr3.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr3]) AT_PARSER_CHECK([[echo p1 t4 o2 p1 p1 t1 o1 t2 p2 o1 t3 p2 p2 | ./glr-regr3]], @@ -417,8 +418,8 @@ merge (YYSTYPE s1, YYSTYPE s2) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr4.c glr-regr4.y]], 0, [], -[glr-regr4.y: conflicts: 1 reduce/reduce -]) +[[glr-regr4.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr4]) AT_PARSER_CHECK([[./glr-regr4]], 0, @@ -477,8 +478,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [], -[glr-regr5.y: conflicts: 1 reduce/reduce -]) +[[glr-regr5.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr5]) AT_PARSER_CHECK([[./glr-regr5]], 0, [], @@ -529,8 +530,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [], -[glr-regr6.y: conflicts: 1 reduce/reduce -]) +[[glr-regr6.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr6]) AT_PARSER_CHECK([[./glr-regr6]], 0, @@ -618,8 +619,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr7.c glr-regr7.y]], 0, [], -[glr-regr7.y: conflicts: 2 reduce/reduce -]) +[[glr-regr7.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr7]) AT_PARSER_CHECK([[./glr-regr7]], 2, [], @@ -712,8 +713,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr8.c glr-regr8.y]], 0, [], -[glr-regr8.y: conflicts: 1 reduce/reduce -]) +[[glr-regr8.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr8]) AT_PARSER_CHECK([[./glr-regr8]], 0, @@ -792,8 +793,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr9.c glr-regr9.y]], 0, [], -[glr-regr9.y: conflicts: 1 reduce/reduce -]) +[[glr-regr9.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr9]) AT_PARSER_CHECK([[./glr-regr9]], 0, [], @@ -848,8 +849,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr10.c glr-regr10.y]], 0, [], -[glr-regr10.y: conflicts: 1 reduce/reduce -]) +[[glr-regr10.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr10]) AT_PARSER_CHECK([[./glr-regr10]], 0, [], []) @@ -906,8 +907,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr11.c glr-regr11.y]], 0, [], -[glr-regr11.y: conflicts: 1 reduce/reduce -]) +[[glr-regr11.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr11]) AT_PARSER_CHECK([[./glr-regr11]], 0, [], []) @@ -1027,8 +1028,9 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr12.c glr-regr12.y]], 0, [], -[glr-regr12.y: conflicts: 1 shift/reduce, 1 reduce/reduce -]) +[[glr-regr12.y: warning: 1 shift/reduce conflict [-Wconflicts-sr] +glr-regr12.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr12]) AT_PARSER_CHECK([[./glr-regr12]], 0, [], []) @@ -1357,8 +1359,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr14.c glr-regr14.y]], 0, [], -[glr-regr14.y: conflicts: 3 reduce/reduce -]) +[[glr-regr14.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr14]) AT_PARSER_CHECK([[./glr-regr14]], 0, @@ -1450,8 +1452,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr15.c glr-regr15.y]], 0, [], -[glr-regr15.y: conflicts: 2 reduce/reduce -]) +[[glr-regr15.y: warning: 2 reduce/reduce conflicts [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr15]) AT_PARSER_CHECK([[./glr-regr15]], 0, [], @@ -1510,8 +1512,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr16.c glr-regr16.y]], 0, [], -[glr-regr16.y: conflicts: 1 reduce/reduce -]) +[[glr-regr16.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr16]) AT_PARSER_CHECK([[./glr-regr16]], 0, [], @@ -1595,8 +1597,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [], -[glr-regr17.y: conflicts: 3 reduce/reduce -]) +[[glr-regr17.y: warning: 3 reduce/reduce conflicts [-Wconflicts-rr] +]]) AT_COMPILE([glr-regr17]) AT_PARSER_CHECK([[./glr-regr17]], 0, [], @@ -1650,11 +1652,11 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o glr-regr18.c glr-regr18.y]], 1, [], -[glr-regr18.y:26.18-24: error: result type clash on merge function 'merge': <type2> != <type1> +[[glr-regr18.y:26.18-24: error: result type clash on merge function 'merge': <type2> != <type1> glr-regr18.y:25.18-24: previous declaration glr-regr18.y:27.13-19: error: result type clash on merge function 'merge': <type3> != <type2> glr-regr18.y:26.18-24: previous declaration -]) +]]) AT_CLEANUP @@ -1698,8 +1700,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o input.c input.y]], 0, [], -[input.y: conflicts: 1 reduce/reduce -]) +[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] +]]) AT_COMPILE([input]) AT_PARSER_CHECK([[./input]], 1, [], diff --git a/tests/headers.at b/tests/headers.at index 96a75583..4192c05b 100644 --- a/tests/headers.at +++ b/tests/headers.at @@ -169,13 +169,14 @@ AT_SKEL_CC_IF([], [AT_CHECK([$EGREP yy $1.h], [1])]) # Check there is not 'YY' left. -# Ignore comments, YYPARSE_PARAM (obsolete), YYPUSH_MORE(_DEFINED)? -# (constant definition), YY_\w+_INCLUDED (header guards). +# Ignore comments, YYPUSH_MORE(_DEFINED)? (constant definition), +# YY_\w+_INCLUDED (header guards). # # YYDEBUG (not renamed) can be read, but not changed. -AT_CHECK([[sed -ne 's,/\*[^*]*\*/,,g;s,//.*,,' \ - -e '/YY/p' ]$1.AT_SKEL_CC_IF([hh], [h])[ | - $EGREP -wv 'YY(PARSE_PARAM|PUSH_MORE(_DEFINED)?|_[0-9A-Z_]+_INCLUDED)|(defined|if) YYDEBUG']], +AT_CHECK([[$PERL -0777 -e 's{/\*.*?\*/}{}sg;s,//.*,,;' \ + ]$1.AT_SKEL_CC_IF([hh], [h])[ | + grep 'YY' | + $EGREP -wv 'YY(PUSH_MORE(_DEFINED)?|_[0-9A-Z_]+_INCLUDED)|(defined|if) YYDEBUG']], [1]) AT_LANG_COMPILE([$1.o]) diff --git a/tests/input.at b/tests/input.at index 16a9308d..fe2df5bd 100644 --- a/tests/input.at +++ b/tests/input.at @@ -60,9 +60,9 @@ exp: foo { $$; } foo { $2; } foo AT_BISON_CHECK([input.y], [1], [], [[input.y:5.12-13: error: $$ for the midrule at $2 of 'exp' has no declared type input.y:5.24-25: error: $2 of 'exp' has no declared type -input.y:5.6-32: warning: type clash on default action: <bar> != <> -input.y:6.6-8: warning: type clash on default action: <bar> != <> -input.y:7.5: warning: empty rule for typed nonterminal, and no action +input.y:5.6-32: warning: type clash on default action: <bar> != <> [-Wother] +input.y:6.6-8: warning: type clash on default action: <bar> != <> [-Wother] +input.y:7.5: warning: empty rule for typed nonterminal, and no action [-Wother] ]]) AT_CLEANUP @@ -72,7 +72,6 @@ AT_CLEANUP # -------------------------------- # Generate the token, type, and destructor # declarations for the unused values tests. - m4_define([_AT_UNUSED_VALUES_DECLARATIONS], [[[%token <integer> INT; %type <integer> a b c d e f g h i j k l; @@ -80,15 +79,11 @@ m4_define([_AT_UNUSED_VALUES_DECLARATIONS], # AT_CHECK_UNUSED_VALUES(DECLARATIONS_AFTER, CHECK_MIDRULE_VALUES) -# ------------------------------------------------------------------ -# Generate a grammar to test unused values, -# compile it, run it. If DECLARATIONS_AFTER -# is set, then the token, type, and destructor -# declarations are generated after the rules -# rather than before. If CHECK_MIDRULE_VALUES -# is set, then --warnings=midrule-values is -# set. - +# ---------------------------------------------------------------- +# Generate a grammar to test unused values, compile it, run it. If +# DECLARATIONS_AFTER is set, then the token, type, and destructor +# declarations are generated after the rules rather than before. If +# CHECK_MIDRULE_VALUES is set, then --warnings=midrule-values is set. m4_define([AT_CHECK_UNUSED_VALUES], [AT_DATA([input.y], m4_ifval($1, [ @@ -118,39 +113,39 @@ _AT_UNUSED_VALUES_DECLARATIONS]) ) AT_BISON_CHECK(m4_ifval($2, [ --warnings=midrule-values ])[ input.y], [0], [], -[[input.y:11.10-32: warning: unset value: $]$[ -input.y:11.10-32: warning: unused value: $]1[ -input.y:11.10-32: warning: unused value: $]3[ -input.y:11.10-32: warning: unused value: $]5[ -input.y:12.9: warning: empty rule for typed nonterminal, and no action -]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $$ -input.y:13.26-41: warning: unset value: $$ -]]])[[input.y:13.10-62: warning: unset value: $]$[ -input.y:13.10-62: warning: unused value: $]3[ -input.y:13.10-62: warning: unused value: $]5[ -]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $$ -]]])[[input.y:14.10-49: warning: unset value: $]$[ -input.y:14.10-49: warning: unused value: $]3[ -input.y:14.10-49: warning: unused value: $]5[ -input.y:15.10-37: warning: unset value: $]$[ -input.y:15.10-37: warning: unused value: $]3[ -input.y:15.10-37: warning: unused value: $]5[ -input.y:17.10-58: warning: unset value: $]$[ -input.y:17.10-58: warning: unused value: $]1[ -]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]2[ -]]])[[input.y:17.10-58: warning: unused value: $]3[ -]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]4[ -]]])[[input.y:17.10-58: warning: unused value: $]5[ -input.y:18.10-72: warning: unset value: $]$[ -input.y:18.10-72: warning: unused value: $]1[ -input.y:18.10-72: warning: unused value: $]3[ -]]m4_ifval($2, [[[input.y:18.10-72: warning: unused value: $]4[ -]]])[[input.y:18.10-72: warning: unused value: $]5[ -]]m4_ifval($2, [[[input.y:20.10-55: warning: unused value: $]3[ -]]])[[input.y:21.10-68: warning: unset value: $]$[ -input.y:21.10-68: warning: unused value: $]1[ -input.y:21.10-68: warning: unused value: $]2[ -]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[ +[[input.y:11.10-32: warning: unset value: $]$[ [-Wother] +input.y:11.10-32: warning: unused value: $]1[ [-Wother] +input.y:11.10-32: warning: unused value: $]3[ [-Wother] +input.y:11.10-32: warning: unused value: $]5[ [-Wother] +input.y:12.9: warning: empty rule for typed nonterminal, and no action [-Wother] +]]m4_ifval($2, [[[input.y:13.14-20: warning: unset value: $$ [-Wmidrule-values] +input.y:13.26-41: warning: unset value: $$ [-Wmidrule-values] +]]])[[input.y:13.10-62: warning: unset value: $]$[ [-Wother] +input.y:13.10-62: warning: unused value: $]3[ [-Wother] +input.y:13.10-62: warning: unused value: $]5[ [-Wother] +]]m4_ifval($2, [[[input.y:14.14-16: warning: unset value: $$ [-Wmidrule-values] +]]])[[input.y:14.10-49: warning: unset value: $]$[ [-Wother] +input.y:14.10-49: warning: unused value: $]3[ [-Wother] +input.y:14.10-49: warning: unused value: $]5[ [-Wother] +input.y:15.10-37: warning: unset value: $]$[ [-Wother] +input.y:15.10-37: warning: unused value: $]3[ [-Wother] +input.y:15.10-37: warning: unused value: $]5[ [-Wother] +input.y:17.10-58: warning: unset value: $]$[ [-Wother] +input.y:17.10-58: warning: unused value: $]1[ [-Wother] +]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]2[ [-Wmidrule-values] +]]])[[input.y:17.10-58: warning: unused value: $]3[ [-Wother] +]]m4_ifval($2, [[[input.y:17.10-58: warning: unused value: $]4[ [-Wmidrule-values] +]]])[[input.y:17.10-58: warning: unused value: $]5[ [-Wother] +input.y:18.10-72: warning: unset value: $]$[ [-Wother] +input.y:18.10-72: warning: unused value: $]1[ [-Wother] +input.y:18.10-72: warning: unused value: $]3[ [-Wother] +]]m4_ifval($2, [[[input.y:18.10-72: warning: unused value: $]4[ [-Wmidrule-values] +]]])[[input.y:18.10-72: warning: unused value: $]5[ [-Wother] +]]m4_ifval($2, [[[input.y:20.10-55: warning: unused value: $]3[ [-Wmidrule-values] +]]])[[input.y:21.10-68: warning: unset value: $]$[ [-Wother] +input.y:21.10-68: warning: unused value: $]1[ [-Wother] +input.y:21.10-68: warning: unused value: $]2[ [-Wother] +]]m4_ifval($2, [[[input.y:21.10-68: warning: unused value: $]4[ [-Wmidrule-values] ]]]))]) @@ -205,29 +200,29 @@ start: ; ]]) AT_BISON_CHECK([input.y], [1], [], -[[input.y:1.13-29: error: redeclaration for default tagged %destructor +[[input.y:1.13-29: error: %destructor redeclaration for <*> input.y:1.13-29: previous declaration -input.y:2.10-24: error: redeclaration for default tagged %printer +input.y:2.10-24: error: %printer redeclaration for <*> input.y:2.10-24: previous declaration -input.y:4.13-29: error: redeclaration for default tagged %destructor +input.y:4.13-29: error: %destructor redeclaration for <*> input.y:1.13-29: previous declaration -input.y:5.10-24: error: redeclaration for default tagged %printer +input.y:5.10-24: error: %printer redeclaration for <*> input.y:2.10-24: previous declaration -input.y:7.13-29: error: redeclaration for default tagless %destructor +input.y:7.13-29: error: %destructor redeclaration for <> input.y:7.13-29: previous declaration -input.y:8.10-24: error: redeclaration for default tagless %printer +input.y:8.10-24: error: %printer redeclaration for <> input.y:8.10-24: previous declaration -input.y:10.13-29: error: redeclaration for default tagless %destructor +input.y:10.13-29: error: %destructor redeclaration for <> input.y:7.13-29: previous declaration -input.y:11.10-24: error: redeclaration for default tagless %printer +input.y:11.10-24: error: %printer redeclaration for <> input.y:8.10-24: previous declaration -input.y:17.13-29: error: redeclaration for default tagged %destructor +input.y:17.13-29: error: %destructor redeclaration for <*> input.y:4.13-29: previous declaration -input.y:18.10-24: error: redeclaration for default tagged %printer +input.y:18.10-24: error: %printer redeclaration for <*> input.y:5.10-24: previous declaration -input.y:20.13-29: error: redeclaration for default tagless %destructor +input.y:20.13-29: error: %destructor redeclaration for <> input.y:10.13-29: previous declaration -input.y:21.10-24: error: redeclaration for default tagless %printer +input.y:21.10-24: error: %printer redeclaration for <> input.y:11.10-24: previous declaration ]]) @@ -276,6 +271,123 @@ input.y:5.10-24: previous declaration AT_CLEANUP +## ------------------- ## +## Undefined symbols. ## +## ------------------- ## + +AT_SETUP([Undefined symbols]) + +AT_DATA([[input.y]], +[[%printer {} foo baz +%destructor {} bar +%type <foo> qux +%% +exp: bar; +]]) + +AT_BISON_CHECK([input.y], [1], [], +[[input.y:2.16-18: error: symbol bar is used, but is not defined as a token and has no rules +input.y:1.17-19: warning: symbol baz is used, but is not defined as a token and has no rules [-Wother] +input.y:1.13-15: warning: symbol foo is used, but is not defined as a token and has no rules [-Wother] +input.y:3.13-15: warning: symbol qux is used, but is not defined as a token and has no rules [-Wother] +]]) + +AT_CLEANUP + + +## ----------------------------------------------------- ## +## Unassociated types used for a printer or destructor. ## +## ----------------------------------------------------- ## + +AT_SETUP([Unassociated types used for a printer or destructor]) + +AT_DATA([[input.y]], +[[%token <type1> tag1 +%type <type2> tag2 + +%printer { } <type1> <type3> +%destructor { } <type2> <type4> + +%% + +exp: tag1 { $1; } + | tag2 { $1; } + +tag2: "a" { $$; } +]]) + +AT_BISON_CHECK([input.y], [0], [], +[[input.y:4.22-28: warning: type <type3> is used, but is not associated to any symbol [-Wother] +input.y:5.25-31: warning: type <type4> is used, but is not associated to any symbol [-Wother] +]]) + +AT_CLEANUP + + +## --------------------------------- ## +## Useless printers or destructors. ## +## --------------------------------- ## + +AT_SETUP([Useless printers or destructors]) + +# AT_TEST([INPUT], [STDERR]) +# -------------------------- +m4_pushdef([AT_TEST], +[AT_DATA([[input.y]], +[$1 +]) +AT_BISON_CHECK([input.y], [0], [], [$2 +])]) + +AT_TEST([[%token <type1> token1 +%token <type2> token2 +%token <type3> token3 +%token <type4> token4 +%token <type5> token51 token52 +%token <type6> token61 token62 +%token <type7> token7 + +%printer {} token1 +%destructor {} token2 +%printer {} token51 +%destructor {} token61 + +%printer {} token7 + +%printer {} <type1> +%destructor {} <type2> +%printer {} <type3> +%destructor {} <type4> + +%printer {} <type5> +%destructor {} <type6> + +%destructor {} <type7> + +%% +exp: "a";]], +[[input.y:16.13-19: warning: useless %printer for type <type1> [-Wother] +input.y:17.16-22: warning: useless %destructor for type <type2> [-Wother]]]) + +# If everybody is typed, <> is useless. +AT_TEST([[%type <type> exp +%token <type> a +%printer {} <> <*> +%% +exp: a;]], +[[input.y:3.13-14: warning: useless %printer for type <> [-Wother]]]) + +# If nobody is typed, <*> is useless. +AT_TEST([[%token a +%printer {} <> <*> +%% +exp: a;]], +[[input.y:2.16-18: warning: useless %printer for type <*> [-Wother]]]) + +m4_popdef([AT_TEST]) + +AT_CLEANUP + ## ---------------------------------------- ## ## Unused values with default %destructor. ## @@ -295,9 +407,9 @@ tagged: { } ; ]]) AT_BISON_CHECK([input.y], [0], [], -[[input.y:6.8-45: warning: unset value: $$ -input.y:6.8-45: warning: unused value: $2 -input.y:7.6-8: warning: unset value: $$ +[[input.y:6.8-45: warning: unset value: $$ [-Wother] +input.y:6.8-45: warning: unused value: $2 [-Wother] +input.y:7.6-8: warning: unset value: $$ [-Wother] ]]) AT_DATA([[input.y]], @@ -312,8 +424,8 @@ tagged: { } ; ]]) AT_BISON_CHECK([input.y], [0], [], -[[input.y:6.8-45: warning: unused value: $4 -input.y:8.9-11: warning: unset value: $$ +[[input.y:6.8-45: warning: unused value: $4 [-Wother] +input.y:8.9-11: warning: unset value: $$ [-Wother] ]]) AT_CLEANUP @@ -336,9 +448,9 @@ end: { } ; ]]) AT_BISON_CHECK([input.y], [0], [], -[[input.y:6.8-22: warning: unset value: $$ -input.y:6.8-22: warning: unused value: $2 -input.y:7.6-8: warning: unset value: $$ +[[input.y:6.8-22: warning: unset value: $$ [-Wother] +input.y:6.8-22: warning: unused value: $2 [-Wother] +input.y:7.6-8: warning: unset value: $$ [-Wother] ]]) AT_CLEANUP @@ -516,7 +628,7 @@ yylex (void) } ]]) -# Pacify Emacs' font-lock-mode: " +# Pacify Emacs'font-lock-mode: " AT_DATA([main.c], [[typedef int value; @@ -595,8 +707,8 @@ AT_CHECK_REQUIRE(100.0, 63) AT_SETUP([String aliases for character tokens]) -# Bison once thought a character token and its alias were different symbols -# with the same user token number. +# Bison once thought a character token and its alias were different +# symbols with the same user token number. AT_DATA_GRAMMAR([input.y], [[%token 'a' "a" @@ -639,15 +751,15 @@ without_period: "WITHOUT.PERIOD"; AT_BISON_OPTION_POPDEFS # POSIX Yacc accept periods, but not dashes. -AT_BISON_CHECK([--yacc input.y], [1], [], -[[input.y:9.8-16: POSIX Yacc forbids dashes in symbol names: WITH-DASH -input.y:18.8-16: POSIX Yacc forbids dashes in symbol names: with-dash +AT_BISON_CHECK([--yacc -Wno-error input.y], [], [], +[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc] +input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc] ]]) # So warn about them. AT_BISON_CHECK([-Wyacc input.y], [], [], -[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH -input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash +[[input.y:9.8-16: warning: POSIX Yacc forbids dashes in symbol names: WITH-DASH [-Wyacc] +input.y:18.8-16: warning: POSIX Yacc forbids dashes in symbol names: with-dash [-Wyacc] ]]) # Dashes are fine for GNU Bison. @@ -720,10 +832,10 @@ AT_CLEANUP AT_SETUP([Unclosed constructs]) -# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed constructs, so -# they were prepended to whatever it STRING_GROW'ed next. It also threw them -# away rather than returning them to the parser. The effect was confusing -# subsequent error messages. +# Bison's scan-gram.l once forgot to STRING_FINISH some unclosed +# constructs, so they were prepended to whatever it STRING_GROW'ed +# next. It also threw them away rather than returning them to the +# parser. The effect was confusing subsequent error messages. AT_DATA([input.y], [[%token A "a @@ -765,8 +877,8 @@ AT_CLEANUP AT_SETUP([%start after first rule]) -# Bison once complained that a %start after the first rule was a redeclaration -# of the start symbol. +# Bison once complained that a %start after the first rule was a +# redeclaration of the start symbol. AT_DATA([input.y], [[%% @@ -815,7 +927,7 @@ start: %prec PREC ; ]]) AT_BISON_CHECK([[input.y]], [[0]], [], -[[input.y:2.8-17: warning: token for %prec is not defined: PREC +[[input.y:2.8-17: warning: token for %prec is not defined: PREC [-Wother] ]]) AT_CLEANUP @@ -1027,15 +1139,15 @@ AT_SETUP([[%define enum variables]]) # Front-end. AT_DATA([[input.y]], -[[%define lr.default-reductions bogus +[[%define lr.default-reduction bogus %% start: ; ]]) AT_BISON_CHECK([[input.y]], [[1]], [[]], -[[input.y:1.9-29: error: invalid value for %define variable 'lr.default-reductions': 'bogus' -input.y:1.9-29: accepted value: 'most' -input.y:1.9-29: accepted value: 'consistent' -input.y:1.9-29: accepted value: 'accepting' +[[input.y:1.9-28: error: invalid value for %define variable 'lr.default-reduction': 'bogus' +input.y:1.9-28: accepted value: 'most' +input.y:1.9-28: accepted value: 'consistent' +input.y:1.9-28: accepted value: 'accepting' ]]) # Back-end. @@ -1047,9 +1159,9 @@ start: ; ]]) AT_BISON_CHECK([[input.y]], [1], [], [[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither' -input.y:1.9-21: error: accepted value: 'pull' -input.y:1.9-21: error: accepted value: 'push' -input.y:1.9-21: error: accepted value: 'both' +input.y:1.9-21: accepted value: 'pull' +input.y:1.9-21: accepted value: 'push' +input.y:1.9-21: accepted value: 'both' ]]) AT_CLEANUP @@ -1069,10 +1181,11 @@ AT_DATA([[input.y]], start: ; ]]) AT_BISON_CHECK([[input.y]], [1], [], -[[input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither' -input.y:1.9-21: error: accepted value: 'pull' -input.y:1.9-21: error: accepted value: 'push' -input.y:1.9-21: error: accepted value: 'both' +[[input.y:1.9-21: warning: deprecated %define variable name: 'api.push_pull', use 'api.push-pull' [-Wdeprecated] +input.y:1.9-21: error: invalid value for %define variable 'api.push-pull': 'neither' +input.y:1.9-21: accepted value: 'pull' +input.y:1.9-21: accepted value: 'push' +input.y:1.9-21: accepted value: 'both' ]]) AT_DATA([[input.y]], @@ -1081,7 +1194,20 @@ AT_DATA([[input.y]], start: ; ]]) AT_BISON_CHECK([[input.y]], [1], [], -[[input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-states' +[[input.y:1.9-34: warning: deprecated %define variable name: 'lr.keep_unreachable_states', use 'lr.keep-unreachable-state' [-Wdeprecated] +input.y:1.9-34: error: invalid value for %define Boolean variable 'lr.keep-unreachable-state' +]]) + +AT_DATA([[input.y]], +[[%define namespace "foo" +%define api.namespace "foo" +%% +start: ; +]]) +AT_BISON_CHECK([[input.y]], [1], [], +[[input.y:1.9-17: warning: deprecated %define variable name: 'namespace', use 'api.namespace' [-Wdeprecated] +input.y:2.9-21: error: %define variable 'api.namespace' redefined +input.y:1.9-17: previous definition ]]) AT_DATA([[input.y]], @@ -1142,14 +1268,14 @@ m4_define([AT_CHECK_NAMESPACE_ERROR], AT_DATA([[input.y]], [[%language "C++" %defines -%define namespace "]$1[" +%define api.namespace "]$1[" %% start: ; ]]) AT_BISON_CHECK([[input.y]], [1], [], [m4_foreach([b4_arg], m4_dquote(m4_shift($@)), -[[input.y:3.9-17: error: ]b4_arg[ +[[input.y:3.9-21: error: ]b4_arg[ ]])]) ]) @@ -1198,10 +1324,10 @@ start: ' AT_CHECK([[$PERL -e "print 'start: \'';" >> empty.y || exit 77]]) AT_BISON_CHECK([empty.y], [1], [], -[[empty.y:2.8-9: warning: empty character literal -empty.y:3.8-4.0: warning: empty character literal +[[empty.y:2.8-9: warning: empty character literal [-Wother] +empty.y:3.8-4.0: warning: empty character literal [-Wother] empty.y:3.8-4.0: error: missing "'" at end of line -empty.y:4.8: warning: empty character literal +empty.y:4.8: warning: empty character literal [-Wother] empty.y:4.8: error: missing "'" at end of file ]]) @@ -1213,10 +1339,10 @@ start: 'ab AT_CHECK([[$PERL -e "print 'start: \'ab';" >> two.y || exit 77]]) AT_BISON_CHECK([two.y], [1], [], -[[two.y:2.8-11: warning: extra characters in character literal -two.y:3.8-4.0: warning: extra characters in character literal +[[two.y:2.8-11: warning: extra characters in character literal [-Wother] +two.y:3.8-4.0: warning: extra characters in character literal [-Wother] two.y:3.8-4.0: error: missing "'" at end of line -two.y:4.8-10: warning: extra characters in character literal +two.y:4.8-10: warning: extra characters in character literal [-Wother] two.y:4.8-10: error: missing "'" at end of file ]]) @@ -1228,10 +1354,10 @@ start: 'abc AT_CHECK([[$PERL -e "print 'start: \'abc';" >> three.y || exit 77]]) AT_BISON_CHECK([three.y], [1], [], -[[three.y:2.8-12: warning: extra characters in character literal -three.y:3.8-4.0: warning: extra characters in character literal +[[three.y:2.8-12: warning: extra characters in character literal [-Wother] +three.y:3.8-4.0: warning: extra characters in character literal [-Wother] three.y:3.8-4.0: error: missing "'" at end of line -three.y:4.8-11: warning: extra characters in character literal +three.y:4.8-11: warning: extra characters in character literal [-Wother] three.y:4.8-11: error: missing "'" at end of file ]]) @@ -1259,25 +1385,25 @@ AT_CHECK([[$PERL -e 'print "start: \"\\\t\\\f\\\0\\\1\" ;";' >> input.y \ AT_BISON_CHECK([input.y], [1], [], [[input.y:2.9-12: error: invalid number after \-escape: 777 -input.y:2.8-13: warning: empty character literal +input.y:2.8-13: warning: empty character literal [-Wother] input.y:2.16-17: error: invalid number after \-escape: 0 -input.y:2.15-18: warning: empty character literal +input.y:2.15-18: warning: empty character literal [-Wother] input.y:2.21-25: error: invalid number after \-escape: xfff -input.y:2.20-26: warning: empty character literal +input.y:2.20-26: warning: empty character literal [-Wother] input.y:2.29-31: error: invalid number after \-escape: x0 -input.y:2.28-32: warning: empty character literal +input.y:2.28-32: warning: empty character literal [-Wother] input.y:3.9-14: error: invalid number after \-escape: uffff -input.y:3.8-15: warning: empty character literal +input.y:3.8-15: warning: empty character literal [-Wother] input.y:3.18-23: error: invalid number after \-escape: u0000 -input.y:3.17-24: warning: empty character literal +input.y:3.17-24: warning: empty character literal [-Wother] input.y:3.27-36: error: invalid number after \-escape: Uffffffff -input.y:3.26-37: warning: empty character literal +input.y:3.26-37: warning: empty character literal [-Wother] input.y:3.40-49: error: invalid number after \-escape: U00000000 -input.y:3.39-50: warning: empty character literal +input.y:3.39-50: warning: empty character literal [-Wother] input.y:4.9-10: error: invalid character after \-escape: ' ' -input.y:4.8-11: warning: empty character literal +input.y:4.8-11: warning: empty character literal [-Wother] input.y:4.14-15: error: invalid character after \-escape: A -input.y:4.13-16: warning: empty character literal +input.y:4.13-16: warning: empty character literal [-Wother] input.y:5.9-16: error: invalid character after \-escape: \t input.y:5.17: error: invalid character after \-escape: \f input.y:5.18: error: invalid character after \-escape: \0 @@ -1322,20 +1448,19 @@ foo-bar: ; # -Werror is not enabled by -Wall or equivalent. AT_BISON_CHECK([[-Wall input.y]], [[0]], [[]], -[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc] ]]) AT_BISON_CHECK([[-W input.y]], [[0]], [[]], -[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc] ]]) AT_BISON_CHECK([[-Wno-none input.y]], [[0]], [[]], -[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +[[input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar [-Wyacc] ]]) # -Werror is not disabled by -Wnone or equivalent. AT_BISON_CHECK([[-Werror,none,yacc input.y]], [[1]], [[]], [[stderr]]) AT_CHECK([[sed 's/^.*bison:/bison:/' stderr]], [[0]], -[[bison: warnings being treated as errors -input.y:2.1-7: warning: POSIX Yacc forbids dashes in symbol names: foo-bar +[[input.y:2.1-7: error: POSIX Yacc forbids dashes in symbol names: foo-bar [-Werror=yacc] ]]) [mv stderr experr] AT_BISON_CHECK([[-Werror,no-all,yacc input.y]], [[1]], [[]], [[experr]]) @@ -1382,7 +1507,8 @@ AT_SETUP([[Stray $ or @]]) # check that the warnings are reported once, not three times. AT_DATA_GRAMMAR([[input.y]], -[[%token TOK +[[%type <TYPE> exp +%token <TYPE> TOK TOK2 %destructor { $%; @%; } <*> exp TOK; %initial-action { $%; @%; }; %printer { $%; @%; } <*> exp TOK; @@ -1391,14 +1517,14 @@ exp: TOK { $%; @%; $$ = $1; }; ]]) AT_BISON_CHECK([[input.y]], 0, [], -[[input.y:10.19: warning: stray '$' -input.y:10.23: warning: stray '@' -input.y:11.19: warning: stray '$' -input.y:11.23: warning: stray '@' -input.y:12.19: warning: stray '$' -input.y:12.23: warning: stray '@' -input.y:14.19: warning: stray '$' -input.y:14.23: warning: stray '@' +[[input.y:11.19: warning: stray '$' [-Wother] +input.y:11.23: warning: stray '@' [-Wother] +input.y:12.19: warning: stray '$' [-Wother] +input.y:12.23: warning: stray '@' [-Wother] +input.y:13.19: warning: stray '$' [-Wother] +input.y:13.23: warning: stray '@' [-Wother] +input.y:15.19: warning: stray '$' [-Wother] +input.y:15.23: warning: stray '@' [-Wother] ]]) AT_CLEANUP @@ -1421,6 +1547,7 @@ m4_pushdef([AT_TEST], [AT_DATA([[input.y]], [[%type <$1(DEAD %type)> exp %token <$1(DEAD %token)> a +%token b %initial-action { $$; @@ -1441,13 +1568,13 @@ m4_pushdef([AT_TEST], }; %% exp: - a a[last] + a a[name] b { $$; $][1; $<$1(DEAD action 1)>$ $<$1(DEAD action 2)>1 - $<$1(DEAD action 3)>last + $<$1(DEAD action 3)>name $<$1(DEAD action 4)>0 ; }; @@ -1467,3 +1594,121 @@ AT_TEST([@:>@m4_errprintn]) m4_popdef([AT_TEST]) AT_CLEANUP + +##----------------------- ## +## Deprecated directives. ## +## ---------------------- ## + +AT_SETUP([[Deprecated directives]]) + +AT_KEYWORDS([[deprec]]) + +AT_DATA_GRAMMAR([[input.y]], +[[ +%default_prec +%error_verbose +%expect_rr 42 +%file-prefix = "foo" +%file-prefix + = +"bar" +%fixed-output_files +%fixed_output-files +%fixed-output-files +%name-prefix= "foo" +%no-default_prec +%no_default-prec +%no_lines +%output = "foo" +%pure_parser +%token_table +%% exp : '0' +]]) + +AT_BISON_CHECK([[input.y]], [[0]], [[]], +[[input.y:10.1-13: warning: deprecated directive: '%default_prec', use '%default-prec' [-Wdeprecated] +input.y:11.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] +input.y:12.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] +input.y:13.1-14: warning: deprecated directive: '%file-prefix =', use '%file-prefix' [-Wdeprecated] +input.y:14.1-15.2: warning: deprecated directive: '%file-prefix\n =', use '%file-prefix' [-Wdeprecated] +input.y:17.1-19: warning: deprecated directive: '%fixed-output_files', use '%fixed-output-files' [-Wdeprecated] +input.y:18.1-19: warning: deprecated directive: '%fixed_output-files', use '%fixed-output-files' [-Wdeprecated] +input.y:20.1-13: warning: deprecated directive: '%name-prefix=', use '%name-prefix' [-Wdeprecated] +input.y:21.1-16: warning: deprecated directive: '%no-default_prec', use '%no-default-prec' [-Wdeprecated] +input.y:22.1-16: warning: deprecated directive: '%no_default-prec', use '%no-default-prec' [-Wdeprecated] +input.y:23.1-9: warning: deprecated directive: '%no_lines', use '%no-lines' [-Wdeprecated] +input.y:24.1-9: warning: deprecated directive: '%output =', use '%output' [-Wdeprecated] +input.y:25.1-12: warning: deprecated directive: '%pure_parser', use '%pure-parser' [-Wdeprecated] +input.y:26.1-12: warning: deprecated directive: '%token_table', use '%token-table' [-Wdeprecated] +input.y: warning: %expect-rr applies only to GLR parsers [-Wother] +]]) + +AT_CLEANUP + +## ---------------------------- ## +## Unput's effect on locations. ## +## ---------------------------- ## +dnl When the scanner detects a deprecated construct, it unputs the correct +dnl version, but it should *not* have any impact on the scanner cursor. If it +dnl does, the locations of directives on the same line become erroneous. + +AT_SETUP([[Unput's effect on locations]]) + +AT_KEYWORDS([[deprec]]) + +AT_DATA_GRAMMAR([[input.y]], +[[ +%glr-parser +%expect_rr 42 %expect_rr 42 + %expect_rr 42 +%error_verbose %error_verbose + %error_verbose +%% exp: '0' +]]) + +AT_BISON_CHECK([[input.y]], [[1]], [[]], +[[input.y:11.1-10: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] +input.y:11.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] +input.y:12.15-24: warning: deprecated directive: '%expect_rr', use '%expect-rr' [-Wdeprecated] +input.y:13.1-14: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] +input.y:13.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] +input.y:13.11-21: error: %define variable 'parse.error' redefined +input.y:13-6: previous definition +input.y:14.16-29: warning: deprecated directive: '%error_verbose', use '%define parse.error verbose' [-Wdeprecated] +input.y:14.11-21: error: %define variable 'parse.error' redefined +input.y:13.11-21: previous definition +]]) + +AT_CLEANUP + +##--------------------------- ## +## Non-deprecated directives. ## +## -------------------------- ## + +AT_SETUP([[Non-deprecated directives]]) + +AT_KEYWORDS([[deprec]]) + +AT_DATA_GRAMMAR([[input.y]], +[[ +%default-prec +%error-verbose +%expect-rr 42 +%file-prefix "foo" +%file-prefix +"bar" +%fixed-output-files +%name-prefix "foo" +%no-default-prec +%no-lines +%output "foo" +%pure-parser +%token-table +%% exp : '0' +]]) + +AT_BISON_CHECK([[input.y]], [[0]], [[]], +[[input.y: warning: %expect-rr applies only to GLR parsers [-Wother] +]]) + +AT_CLEANUP diff --git a/tests/java.at b/tests/java.at index db3f5000..1c9bd50d 100644 --- a/tests/java.at +++ b/tests/java.at @@ -24,7 +24,7 @@ AT_BANNER([[Java Calculator.]]) # _AT_DATA_JAVA_CALC_Y($1, $2, $3, [BISON-DIRECTIVES]) -# ---------------------------------------------------------------------- +# ---------------------------------------------------- # Produce `calc.y'. Don't call this macro directly, because it contains # some occurrences of `$1' etc. which will be interpreted by m4. So # you should call it with $1, $2, and $3 as arguments, which is what @@ -137,7 +137,7 @@ AT_LOCATION_IF([[ ]AT_LOCATION_IF([[yypos = new Position (yypos.lineno (), yypos.token () + 1);]])[ if (ttype == st.TT_EOF) - return Calc.EOF; + return EOF; else if (ttype == st.TT_EOL) { @@ -148,7 +148,7 @@ AT_LOCATION_IF([[ else if (ttype == st.TT_WORD) { yylval = new Integer (st.sval); - return Calc.NUM; + return NUM; } else @@ -249,7 +249,7 @@ AT_CHECK([cat stderr], 0, [expout]) ]) # _AT_CHECK_JAVA_CALC([BISON-DIRECTIVES], [BISON-CODE]) -# ----------------------------------------------------------------------- +# ----------------------------------------------------- # Start a testing chunk which compiles `calc' grammar with # BISON-DIRECTIVES, and performs several tests over the parser. m4_define([_AT_CHECK_JAVA_CALC], @@ -341,7 +341,7 @@ AT_CLEANUP # AT_CHECK_JAVA_CALC([BISON-DIRECTIVES]) -# -------------------------------------------------------- +# -------------------------------------- # Start a testing chunk which compiles `calc' grammar with # BISON-DIRECTIVES, and performs several tests over the parser. # Run the test with and without %error-verbose. @@ -394,9 +394,10 @@ AT_DATA([[YYParser.y]], [ %debug %error-verbose %token-table +%token END "end" $1 %% -start: "end" {$2}; +start: END {$2}; %% class m4_default([$3], [Position]) {} ]) @@ -443,14 +444,14 @@ m4_define([AT_CHECK_JAVA_MINIMAL_W_LEXER], # Check that YYParser.java contains exactly COUNT lines matching ^LINE$ # with grep. m4_define([AT_CHECK_JAVA_GREP], - [AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1]) + [AT_CHECK([grep -c '^$1$' YYParser.java], [], [m4_default([$2], [1]) ]) ]) -# ----------------------------------- # -# Java parser class and package names # -# ----------------------------------- # +# ------------------------------------- # +# Java parser class and package names. # +# ------------------------------------- # AT_SETUP([Java parser class and package names]) @@ -460,6 +461,9 @@ AT_CHECK_JAVA_GREP([[class YYParser]]) AT_CHECK_JAVA_MINIMAL([[%name-prefix "Prefix"]]) AT_CHECK_JAVA_GREP([[class PrefixParser]]) +AT_CHECK_JAVA_MINIMAL([[%define api.token.prefix "TOK_"]]) +AT_CHECK_JAVA_GREP([[.*TOK_END.*]]) + AT_CHECK_JAVA_MINIMAL([[%define parser_class_name "ParserClassName"]]) AT_CHECK_JAVA_GREP([[class ParserClassName]]) @@ -469,9 +473,9 @@ AT_CHECK_JAVA_GREP([[package user_java_package;]]) AT_CLEANUP -# --------------------------- # -# Java parser class modifiers # -# --------------------------- # +# ----------------------------- # +# Java parser class modifiers. # +# ----------------------------- # AT_SETUP([Java parser class modifiers]) @@ -524,6 +528,12 @@ AT_CHECK_JAVA_MINIMAL([[ %define strictfp]]) AT_CHECK_JAVA_GREP([[public final strictfp class YYParser]]) +# FIXME: Can't do a Java compile because javacomp.sh is configured for 1.3 +AT_CHECK_JAVA_MINIMAL([[ +%define annotations "/*@Deprecated @SupressWarnings(\"unchecked\") @SupressWarnings({\"unchecked\", \"deprecation\"}) @SupressWarnings(value={\"unchecked\", \"deprecation\"})*/" +%define public]]) +AT_CHECK_JAVA_GREP([[/\*@Deprecated @SupressWarnings("unchecked") @SupressWarnings({"unchecked", "deprecation"}) @SupressWarnings(value={"unchecked", "deprecation"})\*/ public class YYParser]]) + AT_CLEANUP @@ -554,54 +564,54 @@ AT_CLEANUP AT_SETUP([Java %parse-param and %lex-param]) AT_CHECK_JAVA_MINIMAL([]) -AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer) {]]) +AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer) *]]) AT_CHECK_JAVA_MINIMAL([[%parse-param {int parse_param1}]]) AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1) {]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]]) +AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1) *]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]]) AT_CHECK_JAVA_MINIMAL([[ %parse-param {int parse_param1} %parse-param {long parse_param2}]]) AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) {]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]]) +AT_CHECK_JAVA_GREP([[ *public YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]]) AT_CHECK_JAVA_MINIMAL_W_LEXER([], [], [[return EOF;]]) -AT_CHECK_JAVA_GREP([[ *public YYParser () {]]) -AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer) {]]) +AT_CHECK_JAVA_GREP([[ *public YYParser () *]]) +AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer) *]]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[%parse-param {int parse_param1}]], - [], [[return EOF;]]) + [], [[return EOF;]]) AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1) {]]) -AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1) {]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2]) +AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1) *]]) +AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1) *]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[ %parse-param {int parse_param1} %parse-param {long parse_param2}]], - [], [[return EOF;]]) + [], [[return EOF;]]) AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1, *long parse_param2) {]]) -AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) {]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]], [2]) +AT_CHECK_JAVA_GREP([[ *public YYParser (int parse_param1, *long parse_param2) *]]) +AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[%lex-param {char lex_param1}]], - [], [[return EOF;]], [[YYLexer (char lex_param1) {}]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1) {]]) + [], [[return EOF;]], [[YYLexer (char lex_param1) {}]]) +AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1) *]]) AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1);]]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[ %lex-param {char lex_param1} %lex-param {short lex_param2}]], - [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2) {]]) + [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]]) +AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2) *]]) AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]]) AT_CHECK_JAVA_MINIMAL_W_LEXER([[ @@ -609,14 +619,14 @@ AT_CHECK_JAVA_MINIMAL_W_LEXER([[ %parse-param {long parse_param2} %lex-param {char lex_param1} %lex-param {short lex_param2}]], - [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]]) + [], [[return EOF;]], [[YYLexer (char lex_param1, short lex_param2) {}]]) AT_CHECK_JAVA_GREP([[ *protected final int parse_param1;]]) AT_CHECK_JAVA_GREP([[ *protected final long parse_param2;]]) -AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2, *int parse_param1, *long parse_param2) {]]) +AT_CHECK_JAVA_GREP([[ *public YYParser (char lex_param1, *short lex_param2, *int parse_param1, *long parse_param2) *]]) AT_CHECK_JAVA_GREP([[.* = new YYLexer *(lex_param1, *lex_param2);]]) -AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) {]]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param1 = parse_param1;]], [2]) -AT_CHECK_JAVA_GREP([[[ ]*this.parse_param2 = parse_param2;]], [2]) +AT_CHECK_JAVA_GREP([[ *protected YYParser (Lexer yylexer, *int parse_param1, *long parse_param2) *]]) +AT_CHECK_JAVA_GREP([[ *this.parse_param1 = parse_param1;]], [2]) +AT_CHECK_JAVA_GREP([[ *this.parse_param2 = parse_param2;]], [2]) AT_CLEANUP @@ -627,74 +637,74 @@ AT_CLEANUP AT_SETUP([Java throws specifications]) -# %define throws - 0 1 2 -# %define lex-throws - 0 1 2 -# %code lexer 0 1 +# %define throws - 0 1 2 +# %define lex-throws - 0 1 2 +# %code lexer 0 1 m4_define([AT_JT_lex_throws_define], [m4_case(AT_JT_lex_throws, - -1, [], - 0, [[%define lex_throws ""]], - 1, [[%define lex_throws "InterruptedException"]], - 2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])]) + -1, [], + 0, [[%define lex_throws ""]], + 1, [[%define lex_throws "InterruptedException"]], + 2, [[%define lex_throws "InterruptedException, IllegalAccessException"]])]) m4_define([AT_JT_yylex_throws], [m4_case(AT_JT_lex_throws, - -1, [[ throws java.io.IOException]], - 0, [], - 1, [[ throws InterruptedException]], - 2, [[ throws InterruptedException, IllegalAccessException]])]) + -1, [[ throws java.io.IOException]], + 0, [], + 1, [[ throws InterruptedException]], + 2, [[ throws InterruptedException, IllegalAccessException]])]) m4_define([AT_JT_yylex_action], [m4_case(AT_JT_lex_throws, - -1, [[throw new java.io.IOException();]], - 0, [[return EOF;]], - 1, [[throw new InterruptedException();]], - 2, [[throw new IllegalAccessException();]])]) + -1, [[throw new java.io.IOException();]], + 0, [[return EOF;]], + 1, [[throw new InterruptedException();]], + 2, [[throw new IllegalAccessException();]])]) m4_define([AT_JT_throws_define], [m4_case(AT_JT_throws, - -1, [], - 0, [[%define throws ""]], - 1, [[%define throws "ClassNotFoundException"]], - 2, [[%define throws "ClassNotFoundException, InstantiationException"]])]) + -1, [], + 0, [[%define throws ""]], + 1, [[%define throws "ClassNotFoundException"]], + 2, [[%define throws "ClassNotFoundException, InstantiationException"]])]) m4_define([AT_JT_yyaction_throws], [m4_case(AT_JT_throws, - -1, [], - 0, [], - 1, [[ throws ClassNotFoundException]], - 2, [[ throws ClassNotFoundException, InstantiationException]])]) + -1, [], + 0, [], + 1, [[ throws ClassNotFoundException]], + 2, [[ throws ClassNotFoundException, InstantiationException]])]) m4_define([AT_JT_parse_throws_2], [m4_case(AT_JT_throws, - -1, [], - 0, [], - 1, [[, ClassNotFoundException]], - 2, [[, ClassNotFoundException, InstantiationException]])]) + -1, [], + 0, [], + 1, [[, ClassNotFoundException]], + 2, [[, ClassNotFoundException, InstantiationException]])]) m4_define([AT_JT_parse_throws], - [m4_if(m4_quote(AT_JT_yylex_throws), [], - [AT_JT_yyaction_throws], - [AT_JT_yylex_throws[]AT_JT_parse_throws_2])]) + [m4_if(m4_quote(AT_JT_yylex_throws), [], + [AT_JT_yyaction_throws], + [AT_JT_yylex_throws[]AT_JT_parse_throws_2])]) m4_define([AT_JT_initial_action], [m4_case(AT_JT_throws, - -1, [], - 0, [], - 1, [[%initial-action {if (true) throw new ClassNotFoundException();}]], - 2, [[%initial-action {if (true) throw new InstantiationException();}]])]) + -1, [], + 0, [], + 1, [[%initial-action {if (true) throw new ClassNotFoundException();}]], + 2, [[%initial-action {if (true) throw new InstantiationException();}]])]) m4_define([AT_JT_parse_action], [m4_case(AT_JT_throws, - -1, [], - 0, [], - 1, [[throw new ClassNotFoundException();]], - 2, [[throw new ClassNotFoundException();]])]) + -1, [], + 0, [], + 1, [[throw new ClassNotFoundException();]], + 2, [[throw new ClassNotFoundException();]])]) m4_for([AT_JT_lexer], 0, 1, 1, [m4_for([AT_JT_lex_throws], -1, 2, 1, [m4_for([AT_JT_throws], -1, 2, 1, [m4_if(AT_JT_lexer, 0, - [AT_CHECK_JAVA_MINIMAL([ + [AT_CHECK_JAVA_MINIMAL([ AT_JT_throws_define AT_JT_lex_throws_define AT_JT_initial_action], [AT_JT_parse_action])], - [AT_CHECK_JAVA_MINIMAL_W_LEXER([ + [AT_CHECK_JAVA_MINIMAL_W_LEXER([ AT_JT_throws_define AT_JT_lex_throws_define AT_JT_initial_action], @@ -710,6 +720,28 @@ AT_CHECK_JAVA_GREP([[ *public boolean parse ()]AT_JT_parse_throws[ *]]) AT_CLEANUP +# ------------------------------------- # +# Java constructor init and init_throws # +# ------------------------------------- # + +AT_SETUP([Java constructor init and init_throws]) + +AT_CHECK_JAVA_MINIMAL([[ +%define extends "Thread" +%code init { super("Test Thread"); if (true) throw new InterruptedException(); } +%define init_throws "InterruptedException" +%lex-param {int lex_param}]]) +AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]]) + +AT_CHECK_JAVA_MINIMAL_W_LEXER([[ +%define extends "Thread" +%code init { super("Test Thread"); if (true) throw new InterruptedException(); } +%define init_throws "InterruptedException"]], [], [[return EOF;]]) +AT_CHECK([[grep -q 'super("Test Thread"); if (true) throw new InterruptedException();' YYParser.java]]) + +AT_CLEANUP + + # --------------------------------------------- # # Java stype, position_class and location_class # # --------------------------------------------- # diff --git a/tests/local.at b/tests/local.at index f172b244..bddcb00e 100644 --- a/tests/local.at +++ b/tests/local.at @@ -109,7 +109,7 @@ m4_define([AT_BISON_OPTION_PUSHDEFS], # -------------------------------------------------- # This macro works around the impossibility to define macros # inside macros, because issuing `[$1]' is not possible in M4 :(. -# This sucks hard, GNU M4 should really provide M5 like $$1. +# This sucks hard, GNU M4 should really provide M5-like $$1. m4_define([_AT_BISON_OPTION_PUSHDEFS], [m4_if([$1$2], $[1]$[2], [], [m4_fatal([$0: Invalid arguments: $@])])dnl @@ -152,6 +152,9 @@ m4_pushdef([AT_NAME_PREFIX], [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"], [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])], [yy])]) +m4_pushdef([AT_TOKEN_PREFIX], +[m4_bmatch([$3], [%define api.token.prefix ".*"], + [m4_bregexp([$3], [%define api.token.prefix "\(.*\)"], [\1])])]) m4_pushdef([AT_API_prefix], [m4_bmatch([$3], [%define api\.prefix ".*"], [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])], @@ -161,20 +164,20 @@ m4_pushdef([AT_API_PREFIX], # yyerror receives the location if %location & %pure & (%glr or %parse-param). m4_pushdef([AT_YYERROR_ARG_LOC_IF], [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])], - [$2])]) + [$2])]) # yyerror always sees the locations (when activated), except if # (yacc & pure & !param). FIXME: This is wrong. See the manual. m4_pushdef([AT_YYERROR_SEES_LOC_IF], [AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])], - [$1])], - [$1])], - [$2])]) + [$1])], + [$1])], + [$2])]) # The interface is pure: either because %define api.pure, or because we # are using the C++ parsers. m4_pushdef([AT_PURE_LEX_IF], [AT_PURE_IF([$1], - [AT_SKEL_CC_IF([$1], [$2])])]) + [AT_SKEL_CC_IF([$1], [$2])])]) m4_pushdef([AT_YYSTYPE], [AT_SKEL_CC_IF([AT_NAME_PREFIX[::parser::semantic_type]], @@ -188,15 +191,15 @@ AT_PURE_LEX_IF( [m4_pushdef([AT_LOC], [(*llocp)]) m4_pushdef([AT_VAL], [(*lvalp)]) m4_pushdef([AT_YYLEX_FORMALS], - [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])]) + [AT_YYSTYPE *lvalp[]AT_LOCATION_IF([, AT_YYLTYPE *llocp])]) m4_pushdef([AT_YYLEX_ARGS], - [lvalp[]AT_LOCATION_IF([, llocp])]) + [lvalp[]AT_LOCATION_IF([, llocp])]) m4_pushdef([AT_USE_LEX_ARGS], - [(void) lvalp;AT_LOCATION_IF([(void) llocp])]) + [(void) lvalp;AT_LOCATION_IF([(void) llocp])]) m4_pushdef([AT_YYLEX_PRE_FORMALS], - [AT_YYLEX_FORMALS, ]) + [AT_YYLEX_FORMALS, ]) m4_pushdef([AT_YYLEX_PRE_ARGS], - [AT_YYLEX_ARGS, ]) + [AT_YYLEX_ARGS, ]) ], [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]]) m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]]) @@ -215,6 +218,8 @@ AT_SKEL_CC_IF( [AT_LOC_PUSHDEF([begin.line], [begin.column], [end.line], [end.column])])], [AT_LOC_PUSHDEF([first_line], [first_column], [last_line], [last_column])]) + +AT_GLR_IF([AT_KEYWORDS([glr])]) ])# _AT_BISON_OPTION_PUSHDEFS @@ -389,13 +394,11 @@ static }]], [c++], [[/* A C++ error reporting function. */ void -]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m) -{ - (void) l; - std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl; +]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m) +{ std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl; }]], [java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s) - { +{ if (l == null) System.err.println (s); else @@ -470,55 +473,55 @@ m4_define([AT_BISON_CHECK_WARNINGS_], # as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not # the environment variable. if env | grep '^POSIXLY_CORRECT=' >/dev/null; then :; else - ]AT_SAVE_SPECIAL_FILES[ + ]AT_SAVE_SPECIAL_FILES[ - # To avoid expanding it repeatedly, store specified stdout. - ]AT_DATA([expout], [$3])[ + # To avoid expanding it repeatedly, store specified stdout. + ]AT_DATA([expout], [$3])[ - # Run with -Werror. + # Run with -Werror. ]AT_BISON_CHECK_([$1[ -Werror]], [[1]], [expout], [stderr])[ - # Build expected stderr up to and including the "warnings being - # treated as errors" message. - ]AT_DATA([[at-bison-check-warnings]], [$4])[ - at_bison_check_first=`sed -n \ - '/: warning: /{=;q;}' at-bison-check-warnings` - : ${at_bison_check_first:=1} - at_bison_check_first_tmp=`sed -n \ - '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings` - : ${at_bison_check_first_tmp:=1} - if test $at_bison_check_first_tmp -lt $at_bison_check_first; then - at_bison_check_first=$at_bison_check_first_tmp - fi - if test $at_bison_check_first -gt 1; then - sed -n "1,`expr $at_bison_check_first - 1`"p \ - at-bison-check-warnings > experr - fi - echo ']AT_BISON_WERROR_MSG[' >> experr - - # Finish building expected stderr and check. Unlike warnings, - # complaints cause bison to exit early. Thus, with -Werror, bison - # does not necessarily report all warnings that it does without - # -Werror, but it at least reports one. - at_bison_check_last=`sed -n '$=' stderr` - : ${at_bison_check_last:=1} - at_bison_check_last=`expr $at_bison_check_last - 1` - sed -n "$at_bison_check_first,$at_bison_check_last"p \ - at-bison-check-warnings >> experr - ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \ - stderr 1>&2]], [[0]], [[]], [experr])[ - - # Now check --warnings=error. - cp stderr experr + # Build expected stderr up to and including the "warnings being + # treated as errors" message. + ]AT_DATA([[at-bison-check-warnings]], [$4])[ + at_bison_check_first=`sed -n \ + '/: warning: /{=;q;}' at-bison-check-warnings` + : ${at_bison_check_first:=1} + at_bison_check_first_tmp=`sed -n \ + '/conflicts: [0-9].*reduce$/{=;q;}' at-bison-check-warnings` + : ${at_bison_check_first_tmp:=1} + if test $at_bison_check_first_tmp -lt $at_bison_check_first; then + at_bison_check_first=$at_bison_check_first_tmp + fi + if test $at_bison_check_first -gt 1; then + sed -n "1,`expr $at_bison_check_first - 1`"p \ + at-bison-check-warnings > experr + fi + echo ']AT_BISON_WERROR_MSG[' >> experr + + # Finish building expected stderr and check. Unlike warnings, + # complaints cause bison to exit early. Thus, with -Werror, bison + # does not necessarily report all warnings that it does without + # -Werror, but it at least reports one. + at_bison_check_last=`sed -n '$=' stderr` + : ${at_bison_check_last:=1} + at_bison_check_last=`expr $at_bison_check_last - 1` + sed -n "$at_bison_check_first,$at_bison_check_last"p \ + at-bison-check-warnings >> experr + ]AT_CHECK([[sed 's,.*/\(]AT_BISON_WERROR_MSG[\)$,\1,' \ + stderr 1>&2]], [[0]], [[]], [experr])[ + + # Now check --warnings=error. + cp stderr experr ]AT_BISON_CHECK_([$1[ --warnings=error]], [[1]], [expout], [experr])[ - # Now check -Wnone and --warnings=none by making sure that - # -Werror doesn't change the exit status when -Wnone or - # --warnings=none is specified. + # Now check -Wnone and --warnings=none by making sure that + # -Werror doesn't change the exit status when -Wnone or + # --warnings=none is specified. ]AT_BISON_CHECK_([$1[ -Wnone -Werror]], [[0]], [expout])[ ]AT_BISON_CHECK_([$1[ --warnings=none -Werror]], [[0]], [expout])[ - ]AT_RESTORE_SPECIAL_FILES[ + ]AT_RESTORE_SPECIAL_FILES[ fi]dnl ]) @@ -548,10 +551,10 @@ m4_define([AT_BISON_CHECK_XML], # Don't combine these Bison invocations since we want to be sure that # --report=all isn't required to get the full XML file. AT_BISON_CHECK_([[--report=all --report-file=xml-tests/test.output \ - --graph=xml-tests/test.dot ]]AT_BISON_ARGS, - [[0]], [ignore], [ignore]) + --graph=xml-tests/test.dot ]]AT_BISON_ARGS, + [[0]], [ignore], [ignore]) AT_BISON_CHECK_([[--xml=xml-tests/test.xml ]]AT_BISON_ARGS, - [[0]], [ignore], [ignore]) + [[0]], [ignore], [ignore]) m4_popdef([AT_BISON_ARGS])dnl [cp xml-tests/test.output expout] AT_CHECK([[$XSLTPROC \ @@ -600,7 +603,7 @@ m4_define([AT_COMPILE], [-o $1], [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).c])], [m4_bmatch([$1], [[.]], [], [$LIBS])]), - 0, [ignore], [ignore])]) + 0, [ignore], [ignore])]) # AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc]) # --------------------------------------------- @@ -619,7 +622,7 @@ AT_CHECK(m4_join([ ], [-o $1], [m4_default([$2], [m4_bpatsubst([$1], [\.o$]).cc])], [m4_bmatch([$1], [[.]], [], [$LIBS])]), - 0, [ignore], [ignore])]) + 0, [ignore], [ignore])]) # AT_JAVA_COMPILE(SOURCES) # ------------------------ @@ -659,23 +662,23 @@ m4_define([AT_FULL_COMPILE], [java], [AT_BISON_CHECK([-o $1.java $1.y]) AT_LANG_COMPILE([$1], - m4_join([ ], - [$1.java], - m4_ifval($2, [[$1-$2.java]]), + m4_join([ ], + [$1.java], + m4_ifval($2, [[$1-$2.java]]), m4_ifval($3, [[$1-$3.java]])))], [c++], [AT_BISON_CHECK([-o $1.cc $1.y]) AT_LANG_COMPILE([$1], - m4_join([ ], - [$1.cc], - m4_ifval($2, [[$1-$2.cc]]), + m4_join([ ], + [$1.cc], + m4_ifval($2, [[$1-$2.cc]]), m4_ifval($3, [[$1-$3.cc]])))], [c], [AT_BISON_CHECK([-o $1.c $1.y]) AT_LANG_COMPILE([$1], - m4_join([ ], - [$1.c], - m4_ifval($2, [[$1-$2.c]]), + m4_join([ ], + [$1.c], + m4_ifval($2, [[$1-$2.c]]), m4_ifval($3, [[$1-$3.c]])))]) ]) diff --git a/tests/local.mk b/tests/local.mk new file mode 100644 index 00000000..dc5b6c48 --- /dev/null +++ b/tests/local.mk @@ -0,0 +1,125 @@ +## Makefile for Bison testsuite. + +# Copyright (C) 2000-2012 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 +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +EXTRA_DIST += $(TESTSUITE_AT) tests/testsuite + +DISTCLEANFILES += tests/atconfig $(check_SCRIPTS) +MAINTAINERCLEANFILES += $(TESTSUITE) + +## ------------ ## +## package.m4. ## +## ------------ ## + +$(top_srcdir)/tests/package.m4: $(top_srcdir)/configure + $(AM_V_GEN)rm -f $@ $@.tmp + $(AM_V_at){ \ + echo '# Signature of the current package.'; \ + echo 'm4_define([AT_PACKAGE_NAME], [$(PACKAGE_NAME)])'; \ + echo 'm4_define([AT_PACKAGE_TARNAME], [$(PACKAGE_TARNAME)])'; \ + echo 'm4_define([AT_PACKAGE_VERSION], [$(PACKAGE_VERSION)])'; \ + echo 'm4_define([AT_PACKAGE_STRING], [$(PACKAGE_STRING)])'; \ + echo 'm4_define([AT_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])'; \ + } >$@.tmp + $(AM_V_at)mv $@.tmp $@ + +## ------------------------- ## +## Generate the test suite. ## +## ------------------------- ## + +TESTSUITE_AT = \ + tests/testsuite.at \ + \ + tests/actions.at \ + tests/c++.at \ + tests/calc.at \ + tests/conflicts.at \ + tests/cxx-type.at \ + tests/existing.at \ + tests/glr-regression.at \ + tests/headers.at \ + tests/input.at \ + tests/java.at \ + tests/local.at \ + tests/named-refs.at \ + tests/output.at \ + tests/package.m4 \ + tests/push.at \ + tests/reduce.at \ + tests/regression.at \ + tests/sets.at \ + tests/skeletons.at \ + tests/synclines.at \ + tests/torture.at + +TESTSUITE = $(top_srcdir)/tests/testsuite + +AUTOTEST = $(AUTOM4TE) --language=autotest +AUTOTESTFLAGS = -I $(top_srcdir)/tests +$(TESTSUITE): $(TESTSUITE_AT) + $(AM_V_GEN) \ + $(AUTOTEST) $(AUTOTESTFLAGS) $(srcdir)/tests/testsuite.at -o $@.tmp + $(AM_V_at)mv $@.tmp $@ + + +## -------------------- ## +## Run the test suite. ## +## -------------------- ## + +# Move into tests/ so that testsuite.dir etc. be created there. +RUN_TESTSUITE = $(TESTSUITE) -C tests $(TESTSUITEFLAGS) +check_SCRIPTS = $(BISON) tests/atconfig tests/atlocal +RUN_TESTSUITE_deps = $(TESTSUITE) $(check_SCRIPTS) + +clean-local: clean-local-tests +clean-local-tests: + test ! -f $(TESTSUITE) || $(TESTSUITE) -C tests --clean + +check-local: $(RUN_TESTSUITE_deps) + $(RUN_TESTSUITE) + +# Run the test suite on the *installed* tree. +installcheck-local: $(RUN_TESTSUITE_deps) + $(RUN_TESTSUITE) AUTOTEST_PATH='$(bindir)' + +# Be real mean with it. +.PHONY: maintainer-check-g++ +maintainer-check-g++: $(RUN_TESTSUITE_deps) + $(RUN_TESTSUITE) --compile-c-with-cxx + +.PHONY: maintainer-check-posix +maintainer-check-posix: $(RUN_TESTSUITE_deps) + $(RUN_TESTSUITE) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112 + +.PHONY: maintainer-check-valgrind +maintainer-check-valgrind: $(RUN_TESTSUITE_deps) + test -z '$(VALGRIND)' || \ + $(RUN_TESTSUITE) \ + PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \ + VALGRIND_OPTS='--leak-check=full --show-reachable=yes' + +.PHONY: maintainer-check +maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++ + +.PHONY: maintainer-push-check +maintainer-push-check: + $(MAKE) $(AM_MAKEFLAGS) maintainer-check \ + TESTSUITEFLAGS='BISON_USE_PUSH_FOR_PULL=1 $(TESTSUITEFLAGS)' + +.PHONY: maintainer-xml-check +maintainer-xml-check: + $(MAKE) $(AM_MAKEFLAGS) maintainer-check \ + TESTSUITEFLAGS='BISON_TEST_XML=1 $(TESTSUITEFLAGS)' diff --git a/tests/named-refs.at b/tests/named-refs.at index d76e75f3..ff1d4248 100644 --- a/tests/named-refs.at +++ b/tests/named-refs.at @@ -46,10 +46,10 @@ static int power (int base, int exponent); %token <ival> NUM "number" %type <ival> exp -%nonassoc '=' /* comparison */ +%nonassoc '=' /* comparison */ %left '-' '+' %left '*' '/' -%left NEG /* negation--unary minus */ +%precedence NEG /* negation--unary minus */ %right '^' /* exponentiation */ %% @@ -211,10 +211,10 @@ static int power (int base, int exponent); %token <ival> NUM "number" %type <ival> exp -%nonassoc '=' /* comparison */ +%nonassoc '=' /* comparison */ %left '-' '+' %left '*' '/' -%left NEG /* negation--unary minus */ +%precedence NEG /* negation--unary minus */ %right '^' /* exponentiation */ %% @@ -253,7 +253,7 @@ exp: AT_BISON_CHECK([-o test.c test.y], 1, [], [[test.y:50.51-60: error: invalid reference: '$<ival>lo9' test.y:50.3-68: symbol not found in production: lo9 -test.y:51.51-60: warning: misleading reference: '$<ival>exp' +test.y:51.51-60: warning: misleading reference: '$<ival>exp' [-Wother] test.y:42.1-3: refers to: $exp at $$ test.y:51.7: possibly meant: $x, hiding $exp at $1 test.y:51.41: possibly meant: $r, hiding $exp at $4 @@ -277,7 +277,7 @@ foo: '1' foo.bar: '2' ]]) AT_BISON_CHECK([-o test.c test.y], 0, [], -[[test.y:11.22-29: warning: misleading reference: '$foo.bar' +[[test.y:11.22-29: warning: misleading reference: '$foo.bar' [-Wother] test.y:11.8-10: refers to: $foo at $1 test.y:11.12-18: possibly meant: $[foo.bar] at $2 ]]) @@ -573,7 +573,7 @@ start: ; ]]) AT_BISON_CHECK([[test.y]], [[0]], [], -[[test.y:4.9: warning: stray '$' -test.y:5.9: warning: stray '@' +[[test.y:4.9: warning: stray '$' [-Wother] +test.y:5.9: warning: stray '@' [-Wother] ]]) AT_CLEANUP diff --git a/tests/output.at b/tests/output.at index 37d2c3da..81710245 100644 --- a/tests/output.at +++ b/tests/output.at @@ -22,85 +22,91 @@ AT_BANNER([[Output file names.]]) # [ADDITIONAL-TESTS], [PRE-TESTS]) # ----------------------------------------------------------------------------- m4_define([AT_CHECK_OUTPUT], -[AT_SETUP([[Output files: $2 $3 $5]]) -$7 -for file in $1 $4; do - case "$file" in - */*) mkdir -p `echo "$file" | sed 's,/.*,,'`;; +[AT_SETUP([[Output files: ]$2 $3 $5])[ +]$7[ +for file in ]$1 $4[; do + case $file in + */*) mkdir -p `echo "$file" | sed 's,/[^/]*,,'`;; esac done -AT_DATA([$1], -[[$2 +]AT_DATA([$1], +[$2[ %% foo: {}; +]])[ + +]AT_BISON_CHECK([$3 $1 $5], 0)[ +# Ignore the files non-generated files +]AT_CHECK([find . -type f -and -not -path './$1' -and -not -path './testsuite.log' | + sed 's,\./,,' | + sort | + xargs echo], + [], [$4 +])[ +]$6[ +]AT_CLEANUP[ ]]) -AT_BISON_CHECK([$3 $1 $5], 0) -AT_CHECK([ls $4], [], [ignore]) -$6 -AT_CLEANUP -]) - AT_CHECK_OUTPUT([foo.y], [], [-dv], - [foo.output foo.tab.c foo.tab.h]) + [foo.output foo.tab.c foo.tab.h]) # Some versions of Valgrind (at least valgrind-3.6.0.SVN-Debian) report # "fgrep: write error: Bad file descriptor" when stdout is closed, so we # skip this test group during maintainer-check-valgrind. AT_CHECK_OUTPUT([foo.y], [], [-dv], - [foo.output foo.tab.c foo.tab.h], - [>&-], [], - [AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])]) + [foo.output foo.tab.c foo.tab.h], + [>&-], [], + [AT_CHECK([[case "$PREBISON" in *valgrind*) exit 77;; esac]])]) AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c], - [foo.c foo.h foo.output]) + [foo.c foo.h foo.output]) AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c], - [foo.output foo.tab.c foo.tab.h]) + [foo.output foo.tab.c foo.tab.h]) AT_CHECK_OUTPUT([foo.y], [], [-dv -y], - [y.output y.tab.c y.tab.h]) + [y.output y.tab.c y.tab.h]) AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar], - [bar.output bar.tab.c bar.tab.h]) + [bar.output bar.tab.c bar.tab.h]) AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c], - [foo.c foo.dot foo.h foo.output]) + [foo.c foo.dot foo.h foo.output]) AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [], - [foo.output foo.tab.c foo.tab.h]) + [foo.output foo.tab.c foo.tab.h]) AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[], - [y.output y.tab.c y.tab.h]) + [y.output y.tab.c y.tab.h]) AT_CHECK_OUTPUT([foo.yy], [%defines %verbose %yacc],[], - [y.output y.tab.c y.tab.h]) + [y.output y.tab.c y.tab.h]) # Exercise %output and %file-prefix including deprecated '=' AT_CHECK_OUTPUT([foo.y], [%file-prefix "bar" %defines %verbose], [], - [bar.output bar.tab.c bar.tab.h]) -AT_CHECK_OUTPUT([foo.y], [%output="bar.c" %defines %verbose %yacc],[], - [bar.output bar.c bar.h]) + [bar.output bar.tab.c bar.tab.h]) +AT_CHECK_OUTPUT([foo.y], [%output "bar.c" %defines %verbose %yacc],[], + [bar.c bar.h bar.output]) AT_CHECK_OUTPUT([foo.y], - [%file-prefix="baz" %output "bar.c" %defines %verbose %yacc], - [], - [bar.output bar.c bar.h]) + [%file-prefix "baz" %output "bar.c" %defines %verbose %yacc], + [], + [bar.c bar.h bar.output]) # Check priorities of extension control. AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [], - [foo.output foo.tab.cc foo.tab.hh]) + [foo.output foo.tab.cc foo.tab.hh]) AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c], - [foo.c foo.h foo.output]) + [foo.c foo.h foo.output]) AT_CHECK_OUTPUT([foo.yy], [], - [--defines=foo.hpp -o foo.c++], - [foo.c++ foo.hpp]) + [--defines=foo.hpp -o foo.c++], + [foo.c++ foo.hpp]) AT_CHECK_OUTPUT([foo.yy], [%defines "foo.hpp"], - [-o foo.c++], - [foo.c++ foo.hpp]) + [-o foo.c++], + [foo.c++ foo.hpp]) AT_CHECK_OUTPUT([foo.yy], [], - [-o foo.c++ --graph=foo.gph], - [foo.c++ foo.gph]) + [-o foo.c++ --graph=foo.gph], + [foo.c++ foo.gph]) ## ------------ ## @@ -113,22 +119,36 @@ AT_CHECK([grep 'include .subdir/' $1.cc], 1, []) AT_CHECK([grep 'include .subdir/' $1.hh], 1, []) ]) +AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose], [], + [foo.output foo.tab.cc]) + AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], - [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh]) + [foo.output foo.tab.cc foo.tab.hh stack.hh]) + +AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %verbose %locations], [], + [foo.output foo.tab.cc]) + +AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [], + [foo.output foo.tab.cc foo.tab.hh location.hh position.hh stack.hh]) AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], - [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh], - [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])]) + [foo.output foo.tab.cc foo.tab.hh stack.hh], + [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])]) -AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], - [-o subdir/foo.cc], - [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh], - [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])]) +AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], + [-o subdir/foo.cc], + [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/position.hh subdir/stack.hh], + [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])]) AT_CHECK_OUTPUT([gram_dir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"], [], - [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh]) + [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/stack.hh]) + +AT_CHECK_OUTPUT([gram_dir/foo.yy], + [%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"], + [], + [output_dir/foo.output output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/location.hh output_dir/position.hh output_dir/stack.hh]) # AT_CHECK_CONFLICTING_OUTPUT(INPUT-FILE, DIRECTIVES, FLAGS, STDERR, @@ -157,22 +177,22 @@ AT_CLEANUP AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [--graph="foo.tab.c"], -[foo.y: warning: conflicting outputs to file 'foo.tab.c' -]) +[[foo.y: warning: conflicting outputs to file 'foo.tab.c' [-Wother] +]]) AT_CHECK_CONFLICTING_OUTPUT([foo.y], [%defines "foo.output"], [-v], -[foo.y: warning: conflicting outputs to file 'foo.output' -]) +[[foo.y: warning: conflicting outputs to file 'foo.output' [-Wother] +]]) AT_CHECK_CONFLICTING_OUTPUT([foo.y], -[%skeleton "lalr1.cc" %defines], [--graph="location.hh"], -[foo.y: warning: conflicting outputs to file 'location.hh' -]) +[%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"], +[[foo.y: warning: conflicting outputs to file 'location.hh' [-Wother] +]]) AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y], -[foo.y: error: refusing to overwrite the input file 'foo.y' -], 1) +[[foo.y: error: refusing to overwrite the input file 'foo.y' +]], 1) # AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS]) diff --git a/tests/reduce.at b/tests/reduce.at index c528eed8..d2a5c554 100644 --- a/tests/reduce.at +++ b/tests/reduce.at @@ -88,16 +88,16 @@ exp: useful; ]]) AT_BISON_CHECK([[input.y]], 0, [], -[[input.y: warning: 9 nonterminals useless in grammar -input.y:4.8-15: warning: nonterminal useless in grammar: useless1 -input.y:5.8-15: warning: nonterminal useless in grammar: useless2 -input.y:6.8-15: warning: nonterminal useless in grammar: useless3 -input.y:7.8-15: warning: nonterminal useless in grammar: useless4 -input.y:8.8-15: warning: nonterminal useless in grammar: useless5 -input.y:9.8-15: warning: nonterminal useless in grammar: useless6 -input.y:10.8-15: warning: nonterminal useless in grammar: useless7 -input.y:11.8-15: warning: nonterminal useless in grammar: useless8 -input.y:12.8-15: warning: nonterminal useless in grammar: useless9 +[[input.y: warning: 9 nonterminals useless in grammar [-Wother] +input.y:4.8-15: warning: nonterminal useless in grammar: useless1 [-Wother] +input.y:5.8-15: warning: nonterminal useless in grammar: useless2 [-Wother] +input.y:6.8-15: warning: nonterminal useless in grammar: useless3 [-Wother] +input.y:7.8-15: warning: nonterminal useless in grammar: useless4 [-Wother] +input.y:8.8-15: warning: nonterminal useless in grammar: useless5 [-Wother] +input.y:9.8-15: warning: nonterminal useless in grammar: useless6 [-Wother] +input.y:10.8-15: warning: nonterminal useless in grammar: useless7 [-Wother] +input.y:11.8-15: warning: nonterminal useless in grammar: useless8 [-Wother] +input.y:12.8-15: warning: nonterminal useless in grammar: useless9 [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, @@ -143,26 +143,26 @@ useless9: '9'; ]]) AT_BISON_CHECK([[input.y]], 0, [], -[[input.y: warning: 9 nonterminals useless in grammar -input.y: warning: 9 rules useless in grammar -input.y:6.1-8: warning: nonterminal useless in grammar: useless1 -input.y:7.1-8: warning: nonterminal useless in grammar: useless2 -input.y:8.1-8: warning: nonterminal useless in grammar: useless3 -input.y:9.1-8: warning: nonterminal useless in grammar: useless4 -input.y:10.1-8: warning: nonterminal useless in grammar: useless5 -input.y:11.1-8: warning: nonterminal useless in grammar: useless6 -input.y:12.1-8: warning: nonterminal useless in grammar: useless7 -input.y:13.1-8: warning: nonterminal useless in grammar: useless8 -input.y:14.1-8: warning: nonterminal useless in grammar: useless9 -input.y:6.11-13: warning: rule useless in grammar: useless1: '1' -input.y:7.11-13: warning: rule useless in grammar: useless2: '2' -input.y:8.11-13: warning: rule useless in grammar: useless3: '3' -input.y:9.11-13: warning: rule useless in grammar: useless4: '4' -input.y:10.11-13: warning: rule useless in grammar: useless5: '5' -input.y:11.11-13: warning: rule useless in grammar: useless6: '6' -input.y:12.11-13: warning: rule useless in grammar: useless7: '7' -input.y:13.11-13: warning: rule useless in grammar: useless8: '8' -input.y:14.11-13: warning: rule useless in grammar: useless9: '9' +[[input.y: warning: 9 nonterminals useless in grammar [-Wother] +input.y: warning: 9 rules useless in grammar [-Wother] +input.y:6.1-8: warning: nonterminal useless in grammar: useless1 [-Wother] +input.y:7.1-8: warning: nonterminal useless in grammar: useless2 [-Wother] +input.y:8.1-8: warning: nonterminal useless in grammar: useless3 [-Wother] +input.y:9.1-8: warning: nonterminal useless in grammar: useless4 [-Wother] +input.y:10.1-8: warning: nonterminal useless in grammar: useless5 [-Wother] +input.y:11.1-8: warning: nonterminal useless in grammar: useless6 [-Wother] +input.y:12.1-8: warning: nonterminal useless in grammar: useless7 [-Wother] +input.y:13.1-8: warning: nonterminal useless in grammar: useless8 [-Wother] +input.y:14.1-8: warning: nonterminal useless in grammar: useless9 [-Wother] +input.y:6.11-13: warning: rule useless in grammar: useless1: '1' [-Wother] +input.y:7.11-13: warning: rule useless in grammar: useless2: '2' [-Wother] +input.y:8.11-13: warning: rule useless in grammar: useless3: '3' [-Wother] +input.y:9.11-13: warning: rule useless in grammar: useless4: '4' [-Wother] +input.y:10.11-13: warning: rule useless in grammar: useless5: '5' [-Wother] +input.y:11.11-13: warning: rule useless in grammar: useless6: '6' [-Wother] +input.y:12.11-13: warning: rule useless in grammar: useless7: '7' [-Wother] +input.y:13.11-13: warning: rule useless in grammar: useless8: '8' [-Wother] +input.y:14.11-13: warning: rule useless in grammar: useless9: '9' [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, @@ -239,13 +239,13 @@ non_productive: non_productive useless_token ]]) AT_BISON_CHECK([[not-reduced.y]], 0, [], -[[not-reduced.y: warning: 2 nonterminals useless in grammar -not-reduced.y: warning: 3 rules useless in grammar -not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable -not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive -not-reduced.y:11.6-57: warning: rule useless in grammar: exp: non_productive -not-reduced.y:14.16-56: warning: rule useless in grammar: not_reachable: useful -not-reduced.y:17.17-18.63: warning: rule useless in grammar: non_productive: non_productive useless_token +[[not-reduced.y: warning: 2 nonterminals useless in grammar [-Wother] +not-reduced.y: warning: 3 rules useless in grammar [-Wother] +not-reduced.y:14.1-13: warning: nonterminal useless in grammar: not_reachable [-Wother] +not-reduced.y:11.6-19: warning: nonterminal useless in grammar: non_productive [-Wother] +not-reduced.y:11.6-57: warning: rule useless in grammar: exp: non_productive [-Wother] +not-reduced.y:14.16-56: warning: rule useless in grammar: not_reachable: useful [-Wother] +not-reduced.y:17.17-18.63: warning: rule useless in grammar: non_productive: non_productive useless_token [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' not-reduced.output]], 0, @@ -314,13 +314,13 @@ indirection: underivable; ]]) AT_BISON_CHECK([[input.y]], 0, [], -[[input.y: warning: 2 nonterminals useless in grammar -input.y: warning: 3 rules useless in grammar -input.y:5.15-25: warning: nonterminal useless in grammar: underivable -input.y:6.14-24: warning: nonterminal useless in grammar: indirection -input.y:5.15-25: warning: rule useless in grammar: exp: underivable -input.y:6.14-24: warning: rule useless in grammar: underivable: indirection -input.y:7.14-24: warning: rule useless in grammar: indirection: underivable +[[input.y: warning: 2 nonterminals useless in grammar [-Wother] +input.y: warning: 3 rules useless in grammar [-Wother] +input.y:5.15-25: warning: nonterminal useless in grammar: underivable [-Wother] +input.y:6.14-24: warning: nonterminal useless in grammar: indirection [-Wother] +input.y:5.15-25: warning: rule useless in grammar: exp: underivable [-Wother] +input.y:6.14-24: warning: rule useless in grammar: underivable: indirection [-Wother] +input.y:7.14-24: warning: rule useless in grammar: indirection: underivable [-Wother] ]]) AT_CHECK([[sed -n '/^Grammar/q;/^$/!p' input.output]], 0, @@ -350,8 +350,8 @@ exp: exp; ]]) AT_BISON_CHECK([[input.y]], 1, [], -[[input.y: warning: 2 nonterminals useless in grammar -input.y: warning: 2 rules useless in grammar +[[input.y: warning: 2 nonterminals useless in grammar [-Wother] +input.y: warning: 2 rules useless in grammar [-Wother] input.y:3.1-3: fatal error: start symbol exp does not derive any sentence ]]) @@ -396,7 +396,7 @@ AT_TEST_LR_TYPE([[Single State Split]], [[%left 'a' // Conflict resolution renders state 12 unreachable for canonical LR(1). We // keep it so that the paser table diff is easier to code. -%define lr.keep-unreachable-states]], +%define lr.keep-unreachable-state]], [[ S: 'a' A 'a' /* rule 1 */ | 'b' A 'b' /* rule 2 */ @@ -629,7 +629,7 @@ AT_TEST_LR_TYPE([[Lane Split]], [[%left 'a' // Conflict resolution renders state 16 unreachable for canonical LR(1). We // keep it so that the paser table diff is easier to code. -%define lr.keep-unreachable-states]], +%define lr.keep-unreachable-state]], [[ /* Similar to the last test case set but two states must be split. */ S: 'a' A 'a' /* rule 1 */ @@ -873,7 +873,7 @@ AT_TEST_LR_TYPE([[Complex Lane Split]], [[%left 'a' // Conflict resolution renders state 16 unreachable for canonical LR(1). We // keep it so that the paser table diff is easier to code. -%define lr.keep-unreachable-states]], +%define lr.keep-unreachable-state]], [[ /* Similar to the last test case set but forseeing the S/R conflict from the first state that must be split is becoming difficult. Imagine if B were @@ -1139,7 +1139,7 @@ dnl PARSER-EXIT-VALUE, PARSER-STDOUT, PARSER-STDERR ]])]) AT_TEST_LR_TYPE([[Split During Added Lookahead Propagation]], -[[%define lr.keep-unreachable-states]], +[[%define lr.keep-unreachable-state]], [[ /* The partial state chart diagram below is for LALR(1). State 0 is the start state. States are iterated for successor construction in numerical order. @@ -1191,7 +1191,7 @@ dnl INPUT dnl BISON-STDERR [AT_COND_CASE([[LALR]], -[[input.y: conflicts: 1 reduce/reduce +[[input.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr] ]], [])], dnl TABLES @@ -1443,28 +1443,28 @@ dnl PARSER-EXIT-VALUE, PARSER-STDOUT, PARSER-STDERR ## ------------------------------- ## -## %define lr.default-reductions. ## +## %define lr.default-reduction. ## ## ------------------------------- ## # AT_TEST_LR_DEFAULT_REDUCTIONS(GRAMMAR, INPUT, TABLES) # ----------------------------------------------------- m4_define([AT_TEST_LR_DEFAULT_REDUCTIONS], [ -AT_TEST_TABLES_AND_PARSE([[no %define lr.default-reductions]], +AT_TEST_TABLES_AND_PARSE([[no %define lr.default-reduction]], [[most]], [[]], [[]], [$1], [$2], [[]], [$3]) -AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions most]], +AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction most]], [[most]], [[]], - [[%define lr.default-reductions most]], + [[%define lr.default-reduction most]], [$1], [$2], [[]], [$3]) -AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions consistent]], +AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction consistent]], [[consistent]], [[]], - [[%define lr.default-reductions consistent]], + [[%define lr.default-reduction consistent]], [$1], [$2], [[]], [$3]) -AT_TEST_TABLES_AND_PARSE([[%define lr.default-reductions accepting]], +AT_TEST_TABLES_AND_PARSE([[%define lr.default-reduction accepting]], [[accepting]], [[]], - [[%define lr.default-reductions accepting]], + [[%define lr.default-reduction accepting]], [$1], [$2], [[]], [$3]) ]) diff --git a/tests/regression.at b/tests/regression.at index c44b9f88..8a285af1 100644 --- a/tests/regression.at +++ b/tests/regression.at @@ -209,7 +209,7 @@ exp: '(' exp ')' | NUM ; AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([-v -o input.c input.y], 0, [], -[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string +[[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string [-Wother] ]]) AT_CLEANUP @@ -478,8 +478,8 @@ AT_BISON_OPTION_POPDEFS # C-string literal. Also notice that unnecessary escaping, such as "\?", from # the user specification is eliminated. AT_BISON_CHECK([-o input.c input.y], [[0]], [[]], -[[input.y:22.8-14: warning: symbol SPECIAL redeclared -input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string +[[input.y:22.8-14: warning: symbol SPECIAL redeclared [-Wother] +input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string [-Wother] ]]) AT_COMPILE([input]) @@ -538,7 +538,7 @@ AT_SETUP([Web2c Report]) AT_KEYWORDS([report]) AT_DATA([input.y], -[[%token undef_id_tok const_id_tok +[[%token undef_id_tok const_id_tok %start CONST_DEC_PART @@ -548,12 +548,12 @@ CONST_DEC_PART: ; CONST_DEC_LIST: - CONST_DEC + CONST_DEC | CONST_DEC_LIST CONST_DEC ; CONST_DEC: - { } undef_id_tok '=' const_id_tok ';' + { } undef_id_tok '=' const_id_tok ';' ; %% ]]) @@ -759,15 +759,6 @@ AT_CHECK([[cat tables.c]], 0, 2, 2, 2, 2, 2, 2, 1, 2, 3, 4, 5, 6 }; -static const yytype_uint8 yyprhs[] = -{ - 0, 0, 3, 5, 6, 9, 14 -}; -static const yytype_int8 yyrhs[] = -{ - 8, 0, -1, 9, -1, -1, 10, 11, -1, 3, - 4, 5, 8, -1, 6, 8, -1 -}; static const yytype_uint8 yyrline[] = { 0, 2, 2, 3, 3, 4, 5 @@ -781,32 +772,24 @@ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261 }; -static const yytype_uint8 yyr1[] = -{ - 0, 7, 8, 9, 9, 10, 11 -}; -static const yytype_uint8 yyr2[] = +static const yytype_int8 yypact[] = { - 0, 2, 1, 0, 2, 4, 2 + -2, -1, 4, -8, 0, 2, -8, -2, -8, -2, + -8, -8 }; static const yytype_uint8 yydefact[] = { 3, 0, 0, 2, 0, 0, 1, 3, 4, 3, 6, 5 }; -static const yytype_int8 yydefgoto[] = -{ - -1, 2, 3, 4, 8 -}; -static const yytype_int8 yypact[] = -{ - -2, -1, 4, -8, 0, 2, -8, -2, -8, -2, - -8, -8 -}; static const yytype_int8 yypgoto[] = { -8, -7, -8, -8, -8 }; +static const yytype_int8 yydefgoto[] = +{ + -1, 2, 3, 4, 8 +}; static const yytype_uint8 yytable[] = { 10, 1, 11, 5, 6, 0, 7, 9 @@ -820,6 +803,14 @@ static const yytype_uint8 yystos[] = 0, 3, 8, 9, 10, 4, 0, 6, 11, 5, 8, 8 }; +static const yytype_uint8 yyr1[] = +{ + 0, 7, 8, 9, 9, 10, 11 +}; +static const yytype_uint8 yyr2[] = +{ + 0, 2, 1, 0, 2, 4, 2 +}; ]]) AT_CLEANUP @@ -939,11 +930,11 @@ AT_CHECK_DANCER([%skeleton "lalr1.cc"]) # -------------------------------- m4_define([_AT_DATA_EXPECT2_Y], [AT_DATA_GRAMMAR([expect2.y], -[[%{ -static int yylex (]AT_LALR1_CC_IF([int *], [void])); -AT_LALR1_CC_IF([], -[[#include <stdio.h> -#include <stdlib.h> +[%{ +static int yylex (AT_LALR1_CC_IF([int *], [void])); +AT_LALR1_CC_IF([[#include <cstdlib>]], +[[#include <stdlib.h> +#include <stdio.h> ]AT_YYERROR_DECLARE])[ %} $1 @@ -1038,7 +1029,7 @@ AT_DATA_GRAMMAR([input.y], start: { printf ("Bison would once convert this action to a midrule because of the" - " subsequent braced code.\n"); + " subsequent braced code.\n"); } ; @@ -1191,8 +1182,8 @@ main (void) AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([[-o input.c input.y]], [[0]],, -[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start -input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias" +[[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start [-Wother] +input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias" [-Wother] ]]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input]]) @@ -1210,8 +1201,9 @@ AT_CLEANUP AT_SETUP([[parse-gram.y: LALR = IELR]]) -# Avoid differences in synclines by telling bison that the output files -# have the same name. +# Avoid tests/bison's dark magic by processing a local copy of the +# grammar. Avoid differences in synclines by telling bison that the +# output files have the same name. [cp $abs_top_srcdir/src/parse-gram.y input.y] AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]]) [mv input.c lalr.c] @@ -1225,11 +1217,11 @@ AT_CLEANUP -## --------------------------------------- ## -## %error-verbose and YYSTACK_USE_ALLOCA. ## -## --------------------------------------- ## +## -------------------------------------------- ## +## parse.error=verbose and YYSTACK_USE_ALLOCA. ## +## -------------------------------------------- ## -AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]]) +AT_SETUP([[parse.error=verbose and YYSTACK_USE_ALLOCA]]) AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([input.y], @@ -1240,7 +1232,7 @@ AT_DATA_GRAMMAR([input.y], #define YYSTACK_USE_ALLOCA 1 } -%error-verbose +%define parse.error verbose %% @@ -1273,9 +1265,9 @@ syntax_error: %% ]AT_YYERROR_DEFINE[ -/* Induce two syntax error messages (which requires full error - recovery by shifting 3 tokens) in order to detect any loss of the - reallocated buffer. */ + /* Induce two syntax error messages (which requires full error + recovery by shifting 3 tokens) in order to detect any loss of the + reallocated buffer. */ ]AT_YYLEX_DEFINE(["abc"])[ int main (void) @@ -1296,9 +1288,9 @@ AT_CLEANUP -## ------------------------- ## -## %error-verbose overflow. ## -## ------------------------- ## +## ------------------------------ ## +## parse.error=verbose overflow. ## +## ------------------------------ ## # Imagine the case where YYSTACK_ALLOC_MAXIMUM = YYSIZE_MAXIMUM and an # invocation of yysyntax_error has caused yymsg_alloc to grow to exactly @@ -1308,7 +1300,8 @@ AT_CLEANUP # size calculation would return YYSIZE_MAXIMUM to yyparse. Then, # yyparse would invoke yyerror using the old contents of yymsg. -AT_SETUP([[%error-verbose overflow]]) +AT_SETUP([[parse.error=verbose overflow]]) + AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([input.y], [[%code { @@ -1333,7 +1326,7 @@ AT_DATA_GRAMMAR([input.y], #define YYMAXDEPTH 100 } -%error-verbose +%define parse.error verbose %% @@ -1381,8 +1374,8 @@ syntax_error2: %% ]AT_YYERROR_DEFINE[ -/* Induce two syntax error messages (which requires full error - recovery by shifting 3 tokens). */ + /* Induce two syntax error messages (which requires full error + recovery by shifting 3 tokens). */ ]AT_YYLEX_DEFINE(["abc"])[ int main (void) @@ -1432,7 +1425,7 @@ AT_DATA_GRAMMAR([input.y], } ]$1[ -%error-verbose +%define parse.error verbose %token 'c' %% @@ -1468,7 +1461,7 @@ main (void) AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \ -Dparse.lac.memory-trace=full \ -t -o input.c input.y]], [[0]], [], -[[input.y: conflicts: 21 shift/reduce +[[input.y: warning: 21 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_COMPILE([[input]]) AT_PARSER_CHECK([[./input > stdout.txt 2> stderr.txt]], [[1]]) @@ -1544,7 +1537,7 @@ main (void) AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \ -t -o input.c input.y]], [[0]], [], -[[input.y: conflicts: 8 shift/reduce +[[input.y: warning: 8 shift/reduce conflicts [-Wconflicts-sr] ]]) AT_COMPILE([[input]]) AT_BISON_OPTION_POPDEFS diff --git a/tests/sets.at b/tests/sets.at index 388ee099..26664edf 100644 --- a/tests/sets.at +++ b/tests/sets.at @@ -288,15 +288,15 @@ mv stdout expout # Get the final state in the report, from the "accept" action.. AT_CHECK([sed -n ' /^state \(.*\)/{ - s//final state \1/ - x - } - / accept/{ - x - p - q - } - ' input.output], - 0, [expout]) + s//final state \1/ + x + } + / accept/{ + x + p + q + } + ' input.output], + 0, [expout]) AT_CLEANUP diff --git a/tests/skeletons.at b/tests/skeletons.at index 7b5b8f27..dafc74da 100644 --- a/tests/skeletons.at +++ b/tests/skeletons.at @@ -191,8 +191,8 @@ start: ; ]]) AT_BISON_CHECK([[input1.y]], [[1]], [[]], -[[input1.y: warning: foow fubar -foow.y:2.3-5.3: warning: foowat fubar +[[input1.y: warning: foow fubar [-Wother] +foow.y:2.3-5.3: warning: foowat fubar [-Wother] input1.y: error: fooc fubar fooc.y:1.1-10.5: error: foocat fubar input1.y: fatal error: foof fubar @@ -281,7 +281,7 @@ start: ; ]]) AT_BISON_CHECK([[input2.y]], [[1]], [[]], -[[input2.y: warning: morning +[[input2.y: warning: morning [-Wother] foo.y:1.5-6: fatal error: M4 should exit immediately here ]]) diff --git a/tests/testsuite.at b/tests/testsuite.at index 2a5211ab..48133b72 100644 --- a/tests/testsuite.at +++ b/tests/testsuite.at @@ -1,4 +1,4 @@ -# Test suite for GNU Bison. -*- Autotest -*- +# Test suite for GNU Bison. -*- Autotest -*- # Copyright (C) 2000-2004, 2006-2007, 2009-2012 Free Software # Foundation, Inc. |