X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/41253c3a9ddb07c1347983fb47a9f18fbccaecf2..d521ee19f824305ac03a38cd52117f3a660a80b7:/tests/input.at?ds=inline diff --git a/tests/input.at b/tests/input.at index 69c83901..4eaa8df3 100644 --- a/tests/input.at +++ b/tests/input.at @@ -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. ## ## --------------------- ## @@ -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