X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f42c012fcf0c4eb4d07b59caca90de5442f988c3..312c0cff71e784e116c0ecac4c33bc94d54f78de:/tests/actions.at diff --git a/tests/actions.at b/tests/actions.at index b9337acd..9473f6ef 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -32,10 +32,10 @@ AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([[input.y]], [[%define parse.error verbose %debug -%{ +%code { ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ -%} +} %% exp: { putchar ('0'); } '1' { putchar ('1'); } @@ -77,8 +77,7 @@ m4_pushdef([AT_TEST], AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2]) AT_DATA_GRAMMAR([[input.y]], -[[%defines /* FIXME: Required by lalr1.cc in Bison 2.6. */ -%locations +[[%locations %debug %skeleton "$1" ]$2[ @@ -92,7 +91,7 @@ AT_DATA_GRAMMAR([[input.y]], } %% exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << std::endl]], - [[YY_LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; } + [[LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; } %% ]AT_YYERROR_DEFINE[ @@ -146,7 +145,7 @@ AT_TEST([glr.cc]) AT_TEST([yacc.c], [%define api.pure full], [[%{ # define YYLTYPE int -# define YY_LOCATION_PRINT(Stream, Loc) \ +# define LOCATION_PRINT(Stream, Loc) \ (void) (Loc) # define YYLLOC_DEFAULT(Current, Rhs, N) \ (Current) = ((Rhs)[N ? 1 : 0]) @@ -157,7 +156,7 @@ AT_TEST([yacc.c], [%define api.pure full], AT_TEST([yacc.c], [%define api.pure full], [[%{ # define YYLTYPE int -# define YY_LOCATION_PRINT(Stream, Loc) \ +# define LOCATION_PRINT(Stream, Loc) \ fprintf ((Stream), "%d", (Loc)) # define YYLLOC_DEFAULT(Current, Rhs, N) \ (Current) = ((Rhs)[N ? 1 : 0]) @@ -182,21 +181,18 @@ m4_pushdef([AT_TEST], AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" $2]) AT_DATA_GRAMMAR([[input.y]], -[[%defines /* FIXME: Required by lalr1.cc in Bison 2.6. */ -%locations +[[%locations %debug %skeleton "$1" ]$2[ ]$3[ %code { -# include -# include /* getenv */ ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ } %% -exp:; +exp: /* empty */; %% ]AT_YYERROR_DEFINE[ ]AT_YYLEX_DEFINE[ @@ -204,12 +200,15 @@ exp:; int main (void) { + ]AT_YYLTYPE[ loc; +]AT_GLR_CC_IF([loc.initialize();])[ #define TEST(L1, C1, L2, C2) \ - ]AT_LOC_FIRST_LINE[ = L1; \ - ]AT_LOC_FIRST_COLUMN[ = C1; \ - ]AT_LOC_LAST_LINE[ = L2; \ - ]AT_LOC_LAST_COLUMN[ = C2; \ - ]YY_LOCATION_PRINT(stdout, AT_LOC)[;\ + loc.]AT_FIRST_LINE[ = L1; \ + loc.]AT_FIRST_COLUMN[ = C1; \ + loc.]AT_LAST_LINE[ = L2; \ + loc.]AT_LAST_COLUMN[ = C2; \ + ]AT_SKEL_CC_IF([std::cout << loc], + [LOCATION_PRINT(stdout, loc)])[;\ putchar ('\n'); TEST(1, 1, 1, 1); @@ -239,8 +238,8 @@ AT_CLEANUP ## FIXME: test Java, and iterate over skeletons. AT_TEST([yacc.c]) AT_TEST([glr.c]) -#AT_TEST([lalr1.cc]) -#AT_TEST([glr.cc]) +AT_TEST([lalr1.cc]) +AT_TEST([glr.cc]) m4_popdef([AT_TEST]) @@ -256,11 +255,11 @@ AT_BISON_OPTION_PUSHDEFS AT_DATA_GRAMMAR([[input.y]], [[%define parse.error verbose %debug -%{ +%code { ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ # define USE(Var) -%} +} %union { @@ -306,7 +305,6 @@ AT_PARSER_CHECK([./input], 0, AT_DATA_GRAMMAR([[input.y]], [[ %{ -# include ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ typedef struct { int val; } stype; @@ -761,13 +759,11 @@ AT_DATA_GRAMMAR([[input.y]], %debug %locations -%{ -# include -# include +%code { ]AT_YYLEX_DECLARE[ ]AT_YYERROR_DECLARE[ # define USE(SYM) -%} +} %printer { fprintf (yyoutput, "<*> printer should not be called.\n"); @@ -802,8 +798,8 @@ start: 'a' 'b' 'c' 'd' 'e' { $$ = 'S'; USE(($1, $2, $3, $4, $5)); } ; ]]) AT_BISON_CHECK([-o input.c input.y], [], [], -[[input.y:23.3-5: warning: useless %destructor for type <*> [-Wother] -input.y:23.3-5: warning: useless %printer for type <*> [-Wother] +[[input.y:30.3-5: warning: useless %destructor for type <*> [-Wother] +input.y:30.3-5: warning: useless %printer for type <*> [-Wother] ]]) AT_COMPILE([input]) AT_PARSER_CHECK([./input --debug], 1, @@ -856,8 +852,6 @@ AT_DATA_GRAMMAR([[input.y]], %debug %{ -# include -# include ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ # define USE(SYM) @@ -985,13 +979,11 @@ AT_DATA_GRAMMAR([[input]]$1[[.y]], %debug %locations -%{ -# include -# include +%code { ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ # define USE(SYM) -%} +} %destructor { fprintf (yyoutput, "<]]not_kind[[> destructor should not be called.\n"); @@ -1019,7 +1011,7 @@ AT_DATA_GRAMMAR([[input]]$1[[.y]], start: { $$ = 'S'; } ; %% - +#include /* abort */ static int yylex (void) { @@ -1038,11 +1030,11 @@ AT_BISON_OPTION_POPDEFS AT_BISON_CHECK([-o input$1.c input$1.y], [], [], [m4_if([$1], [0], -[[input0.y:23.3-5: warning: useless %destructor for type <*> [-Wother] -input0.y:23.3-5: warning: useless %printer for type <*> [-Wother] +[[input0.y:30.3-5: warning: useless %destructor for type <*> [-Wother] +input0.y:30.3-5: warning: useless %printer for type <*> [-Wother] ]], -[[input1.y:23.3-4: warning: useless %destructor for type <> [-Wother] -input1.y:23.3-4: warning: useless %printer for type <> [-Wother] +[[input1.y:30.3-4: warning: useless %destructor for type <> [-Wother] +input1.y:30.3-4: warning: useless %printer for type <> [-Wother] ]])]) AT_COMPILE([input$1]) @@ -1053,7 +1045,7 @@ AT_PARSER_CHECK([./input$1 --debug], 0, ]], [[Starting parse Entering state 0 -Reducing stack by rule 1 (line 42): +Reducing stack by rule 1 (line 49): -> $$ = nterm start (1.1: <]]kind[[> for 'S' @ 1) Stack now 0 Entering state 1 @@ -1128,8 +1120,8 @@ start: AT_BISON_OPTION_POPDEFS 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] +[[input.y:23.6-8: warning: useless %destructor for type <*> [-Wother] +input.y:23.6-8: warning: useless %printer for type <*> [-Wother] ]]) AT_COMPILE([input]) AT_PARSER_CHECK([./input --debug], [1], [], @@ -1226,8 +1218,8 @@ start: { USE($$); } ; AT_BISON_OPTION_POPDEFS 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] +[[input.y:24.3-4: warning: useless %destructor for type <> [-Wother] +input.y:24.3-4: warning: useless %printer for type <> [-Wother] ]]) AT_COMPILE([input]) @@ -1246,14 +1238,12 @@ AT_DATA_GRAMMAR([[input.y]], [[%debug /* So that %printer is actually compiled. */ %{ -# include -# include ]AT_YYERROR_DECLARE[ ]AT_YYLEX_DECLARE[ # define USE(SYM) # define YYLTYPE int # define YYLLOC_DEFAULT(Current, Rhs, N) (void)(Rhs) -# define YY_LOCATION_PRINT(File, Loc) +# define LOCATION_PRINT(File, Loc) %} %printer { fprintf (yyoutput, "%d", @$); } <>