X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/e8cd1ad655bcc704b06fb2f191dc3ac1df32b796..d521ee19f824305ac03a38cd52117f3a660a80b7:/tests/input.at diff --git a/tests/input.at b/tests/input.at index daff2eca..4eaa8df3 100644 --- a/tests/input.at +++ b/tests/input.at @@ -1,5 +1,5 @@ # Checking the Bison scanner. -*- Autotest -*- -# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 # Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify @@ -610,6 +610,69 @@ AT_BISON_CHECK([-o input.c input.y]) AT_CLEANUP +## -------------- ## +## Symbol names. ## +## -------------- ## + +AT_SETUP([Symbols]) + +# Bison once thought a character token and its alias were different +# symbols with the same user token number. + +AT_DATA_GRAMMAR([input.y], +[[%token WITH-DASH +%token WITHOUT_DASH "WITHOUT-DASH" +%token WITH.PERIOD +%token WITHOUT_PERIOD "WITHOUT.PERIOD" +%code { + void yyerror (char const *); + int yylex (void); +} +%% +start: with-dash without_dash with.period without_period; +with-dash: WITH-DASH; +without_dash: "WITHOUT-DASH"; +with.period: WITH.PERIOD; +without_period: "WITHOUT.PERIOD"; +%% +]]) + +# 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 +]]) + +# 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 +]]) + +# Dashes are fine for GNU Bison. +AT_BISON_CHECK([-o input.c input.y]) + +# Make sure we don't export silly token identifiers with periods or dashes. +AT_COMPILE([input.o], [-c input.c]) + + +# Period are genuine letters, they can start identifiers. Dashes +# and digits can't. +AT_DATA_GRAMMAR([input.y], +[[%token .good +%token -wrong +%token 1nv4l1d +%% +start: .good +]]) +AT_BISON_CHECK([-o input.c input.y], [1], [], +[[input.y:10.8: invalid character: `-' +input.y:11.8: syntax error, unexpected integer, expecting char or identifier or +]]) + +AT_CLEANUP + + ## --------------------- ## ## Unclosed constructs. ## ## --------------------- ## @@ -829,14 +892,14 @@ AT_DATA([input.y], start: ; ]]) -AT_BISON_CHECK([[input.y -DFOO -DFOO -Dvar=value]], [0], [], -[[:4: warning: %define variable `FOO' redefined -:3: warning: previous definition +AT_BISON_CHECK([[-DFOO -DFOO -Dvar=value input.y]], [0], [], +[[:3: warning: %define variable `FOO' redefined +:2: warning: previous definition input.y:1.9-11: warning: %define variable `var' redefined -:5: warning: previous definition +:4: warning: previous definition +:2: warning: %define variable `FOO' is not used :3: warning: %define variable `FOO' is not used -:4: warning: %define variable `FOO' is not used -:5: warning: %define variable `var' is not used +:4: warning: %define variable `var' is not used input.y:1.9-11: warning: %define variable `var' is not used ]]) @@ -868,14 +931,30 @@ AT_CLEANUP AT_SETUP([[%define enum variables]]) +# Front-end. AT_DATA([[input.y]], -[[%define api.push_pull "neither" +[[%define lr.default_reductions "bogus" %% start: ; ]]) +AT_BISON_CHECK([[input.y]], [[1]], [[]], +[[input.y:1.9-29: invalid value for %define variable `lr.default_reductions': `bogus' +input.y:1.9-29: accepted value: `all' +input.y:1.9-29: accepted value: `consistent' +input.y:1.9-29: accepted value: `accepting' +]]) +# Back-end. +AT_DATA([[input.y]], +[[%define api.push_pull "neither" +%% +start: ; +]]) AT_BISON_CHECK([[input.y]], [1], [], [[input.y:1.9-21: 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_CLEANUP