X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/f3ead217b8636f623399e66bd937b1c51774d4af..4c9b8f1318c68238074ee19e7ab976a22924540e:/tests/glr-regression.at diff --git a/tests/glr-regression.at b/tests/glr-regression.at index a826a5e3..9eb429c7 100644 --- a/tests/glr-regression.at +++ b/tests/glr-regression.at @@ -1,6 +1,6 @@ # Checking GLR Parsing: Regression Tests -*- Autotest -*- -# Copyright (C) 2002-2003, 2005-2007, 2009-2012 Free Software +# Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software # Foundation, Inc. # This program is free software: you can redistribute it and/or modify @@ -18,9 +18,9 @@ AT_BANNER([[GLR Regression Tests]]) -## --------------------------- ## -## Badly Collapsed GLR States. ## -## --------------------------- ## +## ---------------------------- ## +## Badly Collapsed GLR States. ## +## ---------------------------- ## AT_SETUP([Badly Collapsed GLR States]) @@ -67,7 +67,7 @@ static YYSTYPE exprMerge (YYSTYPE x0, YYSTYPE x1) return 0; } -const char *input = NULL; +const char *input = YY_NULL; int main (int argc, const char* argv[]) @@ -105,9 +105,9 @@ E -> E 'P' E AT_CLEANUP -## ------------------------------------------------------------ ## -## Improper handling of embedded actions and $-N in GLR parsers ## -## ------------------------------------------------------------ ## +## -------------------------------------------------------------- ## +## Improper handling of embedded actions and $-N in GLR parsers. ## +## -------------------------------------------------------------- ## AT_SETUP([Improper handling of embedded actions and dollar(-N) in GLR parsers]) @@ -195,10 +195,11 @@ yylex (void) int main (int argc, char **argv) { + int res; input = stdin; if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3; - int res = yyparse (); + res = yyparse (); if (argc == 2 && fclose (input)) return 4; return res; @@ -236,9 +237,9 @@ AT_PARSER_CHECK([[./glr-regr2a input3.txt]], 0, AT_CLEANUP -## ------------------------------------------------------------ ## -## Improper merging of GLR delayed action sets ## -## ------------------------------------------------------------ ## +## --------------------------------------------- ## +## Improper merging of GLR delayed action sets. ## +## --------------------------------------------- ## AT_SETUP([Improper merging of GLR delayed action sets]) @@ -325,12 +326,13 @@ int yylex (void) } int -main(int argc, char* argv[]) +main (int argc, char* argv[]) { + int res; input = stdin; if (argc == 2 && !(input = fopen (argv[1], "r"))) return 3; - int res = yyparse (); + res = yyparse (); if (argc == 2 && fclose (input)) return 4; return res; @@ -355,10 +357,10 @@ AT_PARSER_CHECK([[./glr-regr3 input.txt]], AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Duplicate representation of merged trees. See ## -## . ## -## ------------------------------------------------------------------------- ## +## ---------------------------------------------------------------------- ## +## Duplicate representation of merged trees. See ## +## . ## +## ---------------------------------------------------------------------- ## AT_SETUP([Duplicate representation of merged trees]) @@ -446,10 +448,10 @@ AT_PARSER_CHECK([[./glr-regr4]], 0, AT_CLEANUP -## -------------------------------------------------------------------------- ## -## User destructor for unresolved GLR semantic value. See ## -## . ## -## -------------------------------------------------------------------------- ## +## ------------------------------------------------------------------------- ## +## User destructor for unresolved GLR semantic value. See ## +## . ## +## ------------------------------------------------------------------------- ## AT_SETUP([User destructor for unresolved GLR semantic value]) @@ -486,11 +488,7 @@ start: %% ]AT_YYLEX_DEFINE(["a"])[ ]AT_YYERROR_DEFINE[ -int -main (void) -{ - return yyparse () != 1; -} +]AT_MAIN_DEFINE[ ]]) AT_BISON_OPTION_POPDEFS @@ -499,17 +497,17 @@ AT_BISON_CHECK([[-o glr-regr5.c glr-regr5.y]], 0, [], ]]) AT_COMPILE([glr-regr5]) -AT_PARSER_CHECK([[./glr-regr5]], 0, [], +AT_PARSER_CHECK([[./glr-regr5]], 1, [], [syntax is ambiguous ]) AT_CLEANUP -## -------------------------------------------------------------------------- ## -## User destructor after an error during a split parse. See ## -## . ## -## -------------------------------------------------------------------------- ## +## ------------------------------------------------------------------------- ## +## User destructor after an error during a split parse. See ## +## . ## +## ------------------------------------------------------------------------- ## AT_SETUP([User destructor after an error during a split parse]) @@ -538,11 +536,7 @@ start: 'a' | 'a' ; %% ]AT_YYERROR_DEFINE[ ]AT_YYLEX_DEFINE(["a"])[ -int -main (void) -{ - return yyparse () != 1; -} +]AT_MAIN_DEFINE[ ]]) AT_BISON_OPTION_POPDEFS @@ -551,7 +545,7 @@ AT_BISON_CHECK([[-o glr-regr6.c glr-regr6.y]], 0, [], ]]) AT_COMPILE([glr-regr6]) -AT_PARSER_CHECK([[./glr-regr6]], 0, +AT_PARSER_CHECK([[./glr-regr6]], 1, [Destructor called. ], [syntax is ambiguous @@ -561,7 +555,7 @@ AT_CLEANUP ## ------------------------------------------------------------------------- ## -## Duplicated user destructor for lookahead. See ## +## Duplicated user destructor for lookahead. See ## ## . ## ## ------------------------------------------------------------------------- ## @@ -649,7 +643,7 @@ AT_CLEANUP ## ------------------------------------------------------------------------- ## ## Incorrect default location for empty right-hand sides. Adapted from bug ## -## report by Claudia Hermann. ## +## report by Claudia Hermann. ## ## See http://lists.gnu.org/archive/html/bug-bison/2005-10/msg00069.html and ## ## http://lists.gnu.org/archive/html/bug-bison/2005-10/msg00072.html ## ## ------------------------------------------------------------------------- ## @@ -675,25 +669,25 @@ AT_DATA_GRAMMAR([glr-regr8.y], %% -PortClause : T_PORT InterfaceDeclaration T_PORT - { printf("%d/%d - %d/%d - %d/%d\n", - @1.first_column, @1.last_column, - @2.first_column, @2.last_column, - @3.first_column, @3.last_column); } - ; +PortClause : T_PORT InterfaceDeclaration T_PORT + { printf("%d/%d - %d/%d - %d/%d\n", + @1.first_column, @1.last_column, + @2.first_column, @2.last_column, + @3.first_column, @3.last_column); } + ; -InterfaceDeclaration : OptConstantWord %dprec 1 - | OptSignalWord %dprec 2 - ; +InterfaceDeclaration : OptConstantWord %dprec 1 + | OptSignalWord %dprec 2 + ; -OptConstantWord : /* empty */ - | T_CONSTANT - ; +OptConstantWord : /* empty */ + | T_CONSTANT + ; -OptSignalWord : /* empty */ - { printf("empty: %d/%d\n", @$.first_column, @$.last_column); } - | T_SIGNAL - ; +OptSignalWord : /* empty */ + { printf("empty: %d/%d\n", @$.first_column, @$.last_column); } + | T_SIGNAL + ; %% @@ -720,12 +714,7 @@ int yylex (void) } } -int -main (void) -{ - yyparse(); - return 0; -} +]AT_MAIN_DEFINE[ ]]) AT_BISON_OPTION_POPDEFS @@ -744,7 +733,7 @@ AT_CLEANUP ## ------------------------------------------------------------------------- ## -## No users destructors if stack 0 deleted. See ## +## No users destructors if stack 0 deleted. See ## ## . ## ## ------------------------------------------------------------------------- ## @@ -821,9 +810,9 @@ AT_PARSER_CHECK([[./glr-regr9]], 0, [], AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Corrupted semantic options if user action cuts parse. ## -## ------------------------------------------------------------------------- ## +## ------------------------------------------------------ ## +## Corrupted semantic options if user action cuts parse. ## +## ------------------------------------------------------ ## AT_SETUP([Corrupted semantic options if user action cuts parse]) @@ -875,9 +864,9 @@ AT_PARSER_CHECK([[./glr-regr10]], 0, [], []) AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Undesirable destructors if user action cuts parse. ## -## ------------------------------------------------------------------------- ## +## --------------------------------------------------- ## +## Undesirable destructors if user action cuts parse. ## +## --------------------------------------------------- ## AT_SETUP([Undesirable destructors if user action cuts parse]) @@ -933,9 +922,9 @@ AT_PARSER_CHECK([[./glr-regr11]], 0, [], []) AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Leaked semantic values if user action cuts parse. ## -## ------------------------------------------------------------------------- ## +## -------------------------------------------------- ## +## Leaked semantic values if user action cuts parse. ## +## -------------------------------------------------- ## AT_SETUP([Leaked semantic values if user action cuts parse]) @@ -1026,17 +1015,17 @@ main (void) int exit_status = yyparse (); if (parent_rhs_before_value) { - fprintf (stderr, "`parent_rhs_before' destructor not called.\n"); + fprintf (stderr, "'parent_rhs_before' destructor not called.\n"); exit_status = 1; } if (merged_value) { - fprintf (stderr, "`merged' destructor not called.\n"); + fprintf (stderr, "'merged' destructor not called.\n"); exit_status = 1; } if (parent_rhs_after_value) { - fprintf (stderr, "`PARENT_RHS_AFTER' destructor not called.\n"); + fprintf (stderr, "'PARENT_RHS_AFTER' destructor not called.\n"); exit_status = 1; } return exit_status; @@ -1056,7 +1045,7 @@ AT_CLEANUP ## ------------------------------------------------------------------------- ## -## Incorrect lookahead during deterministic GLR. See ## +## Incorrect lookahead during deterministic GLR. See ## ## and ## ## . ## ## ------------------------------------------------------------------------- ## @@ -1144,10 +1133,10 @@ print_lookahead (char const *reduction) { printf ("'%c', yylval='", yychar); if (yylval.value > ' ') - printf ("%c", yylval.value); + printf ("%c", yylval.value); printf ("', yylloc=(%d,%d),(%d,%d)", - yylloc.first_line, yylloc.first_column, - yylloc.last_line, yylloc.last_column); + yylloc.first_line, yylloc.first_column, + yylloc.last_line, yylloc.last_column); } printf ("\n"); } @@ -1181,9 +1170,9 @@ start <- defstate_init defstate_shift 'b': AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Incorrect lookahead during nondeterministic GLR. ## -## ------------------------------------------------------------------------- ## +## ------------------------------------------------- ## +## Incorrect lookahead during nondeterministic GLR. ## +## ------------------------------------------------- ## AT_SETUP([Incorrect lookahead during nondeterministic GLR]) @@ -1244,7 +1233,7 @@ merge: | conflict defstate_look 'a' nonconflict2 'b' defstate_shift %dprec 2 { USE ($3); USE ($5); print_lookahead ("merge <- conflict defstate_look 'a' nonconflict2 'b'" - " defstate_shift"); + " defstate_shift"); } ; @@ -1291,7 +1280,7 @@ alt1: USE ($1); if (yychar != 'd' && yychar != YYEOF) { - fprintf (stderr, "Incorrect lookahead during stack explosion.\n"); + fprintf (stderr, "Incorrect lookahead during stack explosion.\n"); } } ; @@ -1300,7 +1289,7 @@ alt2: USE ($1); if (yychar != 'd' && yychar != YYEOF) { - fprintf (stderr, "Incorrect lookahead during stack explosion.\n"); + fprintf (stderr, "Incorrect lookahead during stack explosion.\n"); } } ; @@ -1309,7 +1298,7 @@ alt3: USE ($1); if (yychar != 'd' && yychar != YYEOF) { - fprintf (stderr, "Incorrect lookahead during stack explosion.\n"); + fprintf (stderr, "Incorrect lookahead during stack explosion.\n"); } } ; @@ -1317,8 +1306,8 @@ no_look: { if (yychar != YYEMPTY) { - fprintf (stderr, - "Found lookahead where shouldn't during stack explosion.\n"); + fprintf (stderr, + "Found lookahead where shouldn't during stack explosion.\n"); } } ; @@ -1350,10 +1339,10 @@ print_lookahead (char const *reduction) { printf ("'%c', yylval='", yychar); if (yylval.value > ' ') - printf ("%c", yylval.value); + printf ("%c", yylval.value); printf ("', yylloc=(%d,%d),(%d,%d)", - yylloc.first_line, yylloc.first_column, - yylloc.last_line, yylloc.last_column); + yylloc.first_line, yylloc.first_column, + yylloc.last_line, yylloc.last_column); } printf ("\n"); } @@ -1398,9 +1387,9 @@ start <- merge 'c' stack_explosion: AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Leaked semantic values when reporting ambiguity. ## -## ------------------------------------------------------------------------- ## +## ------------------------------------------------- ## +## Leaked semantic values when reporting ambiguity. ## +## ------------------------------------------------- ## AT_SETUP([Leaked semantic values when reporting ambiguity]) @@ -1460,7 +1449,7 @@ main (void) int exit_status = yyparse () != 1; if (parent_rhs_before_value) { - fprintf (stderr, "`parent_rhs_before' destructor not called.\n"); + fprintf (stderr, "'parent_rhs_before' destructor not called.\n"); exit_status = 1; } return exit_status; @@ -1480,9 +1469,9 @@ AT_PARSER_CHECK([[./glr-regr15]], 0, [], AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Leaked lookahead after nondeterministic parse syntax error. ## -## ------------------------------------------------------------------------- ## +## ------------------------------------------------------------ ## +## Leaked lookahead after nondeterministic parse syntax error. ## +## ------------------------------------------------------------ ## AT_SETUP([Leaked lookahead after nondeterministic parse syntax error]) @@ -1540,9 +1529,9 @@ AT_PARSER_CHECK([[./glr-regr16]], 0, [], AT_CLEANUP -## ------------------------------------------------------------------------- ## -## Uninitialized location when reporting ambiguity. ## -## ------------------------------------------------------------------------- ## +## ------------------------------------------------- ## +## Uninitialized location when reporting ambiguity. ## +## ------------------------------------------------- ## AT_SETUP([Uninitialized location when reporting ambiguity]) @@ -1598,11 +1587,7 @@ yylex (YYSTYPE *lvalp, YYLTYPE *llocp) return input[toknum++]; } -int -main (void) -{ - return yyparse () != 1; -} +]AT_MAIN_DEFINE[ ]]) AT_BISON_OPTION_POPDEFS @@ -1611,16 +1596,16 @@ AT_BISON_CHECK([[-o glr-regr17.c glr-regr17.y]], 0, [], ]]) AT_COMPILE([glr-regr17]) -AT_PARSER_CHECK([[./glr-regr17]], 0, [], +AT_PARSER_CHECK([[./glr-regr17]], 1, [], [1.1-2.2: syntax is ambiguous ]) AT_CLEANUP -## -------------------------------------------------------------## -## Missed %merge type warnings when LHS type is declared later. ## -## -------------------------------------------------------------## +## ------------------------------------------------------------- ## +## Missed %merge type warnings when LHS type is declared later. ## +## ------------------------------------------------------------- ## AT_SETUP([Missed %merge type warnings when LHS type is declared later]) @@ -1653,19 +1638,15 @@ sym3: %merge { $$ = 0; } ; %% ]AT_YYERROR_DEFINE[ ]AT_YYLEX_DEFINE[ -int -main (void) -{ - return yyparse (); -} +]AT_MAIN_DEFINE[ ]]) 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': != -glr-regr18.y:25.18-24: previous declaration -glr-regr18.y:27.13-19: error: result type clash on merge function 'merge': != -glr-regr18.y:26.18-24: previous declaration +[[glr-regr18.y:28.18-24: error: result type clash on merge function 'merge': != +glr-regr18.y:27.18-24: previous declaration +glr-regr18.y:29.13-19: error: result type clash on merge function 'merge': != +glr-regr18.y:28.18-24: previous declaration ]]) AT_CLEANUP @@ -1677,7 +1658,7 @@ AT_CLEANUP AT_SETUP([Ambiguity reports]) -AT_BISON_OPTION_PUSHDEFS +AT_BISON_OPTION_PUSHDEFS([%debug]) AT_DATA_GRAMMAR([input.y], [[ %{ @@ -1700,12 +1681,7 @@ d: /* nada. */; %% ]AT_YYLEX_DEFINE(["abc"])[ ]AT_YYERROR_DEFINE[ -int -main (void) -{ - yydebug = 1; - return !!yyparse (); -} +]AT_MAIN_DEFINE[ ]]) AT_BISON_OPTION_POPDEFS @@ -1714,7 +1690,7 @@ AT_BISON_CHECK([[-o input.c input.y]], 0, [], ]]) AT_COMPILE([input]) -AT_PARSER_CHECK([[./input]], 1, [], +AT_PARSER_CHECK([[./input --debug]], 1, [], [Starting parse Entering state 0 Reading a token: Next token is token 'a' () @@ -1723,14 +1699,14 @@ Entering state 1 Reading a token: Next token is token 'b' () Shifting token 'b' () Entering state 3 -Reducing stack 0 by rule 3 (line 25): +Reducing stack 0 by rule 3 (line 27): $1 = token 'b' () -> $$ = nterm b () Entering state 4 Reading a token: Next token is token 'c' () Shifting token 'c' () Entering state 6 -Reducing stack 0 by rule 4 (line 26): +Reducing stack 0 by rule 4 (line 28): -> $$ = nterm d () Entering state 7 Reading a token: Now at end of input.