X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/a14a26fa443e16247559a62b3e7cd00b2b81e40d..e6efa9daccc2491b69bd385a5bd965e676632881:/tests/actions.at diff --git a/tests/actions.at b/tests/actions.at index 15f25c03..7d7109f9 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1,5 +1,5 @@ # Executing Actions. -*- Autotest -*- -# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -# 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. AT_BANNER([[User Actions.]]) @@ -174,6 +174,9 @@ AT_DATA_GRAMMAR([[input.y]], #include #include #include + +#define YYINITDEPTH 10 +#define YYMAXDEPTH 10 ]AT_LALR1_CC_IF( [#define RANGE(Location) (Location).begin.line, (Location).end.line], [#define RANGE(Location) (Location).first_line, (Location).last_line]) @@ -186,7 +189,7 @@ m4_ifval([$6], [%union }]) [ %{ -]AT_LALR1_CC_IF([typedef yy::Location YYLTYPE; +]AT_LALR1_CC_IF([typedef yy::location YYLTYPE; m4_ifval([$6], , [#define YYSTYPE int])]) [static int yylex (]AT_LEX_FORMALS[); ]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);]) @@ -311,16 +314,17 @@ yylex (]AT_LEX_FORMALS[) ]AT_LALR1_CC_IF( [/* A C++ error reporting function. */ void -yy::Parser::error_ () +yy::parser::error (const location& l, const std::string& m) { - printf ("%d-%d: %s\n", RANGE (location), message.c_str()); + printf ("%d-%d: %s\n", RANGE (l), m.c_str()); } static bool yydebug; int yyparse () { - yy::Parser parser (yydebug); + yy::parser parser; + parser.set_debug_level (yydebug); return parser.parse (); } ], @@ -333,16 +337,18 @@ yyerror (const char *msg) int main (int argc, const char *argv[]) { + int status; yydebug = !!getenv ("YYDEBUG"); assert (argc == 2); yysource = argv[1]; - if (yyparse ()) + status = yyparse (); + switch (status) { - printf ("Parsing FAILED.\n"); - exit (1); + case 0: printf ("Successful parse.\n"); break; + case 1: printf ("Parsing FAILED.\n"); break; + default: printf ("Parsing FAILED (status %d).\n", status); break; } - printf ("Successful parse.\n"); - return 0; + return status; } ]]) @@ -367,6 +373,7 @@ line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29) sending: EOF (3@30-39) input (0@29-29): /* Nothing */ input (2@0-29): line (0@0-29) input (0@29-29) +Freeing nterm input (2@0-29) Successful parse. ]]) @@ -385,6 +392,7 @@ line (-1@0-29): '(' (0@0-9) error (@10-19) ')' (2@20-29) sending: EOF (3@30-39) input (0@29-29): /* Nothing */ input (2@0-29): line (-1@0-29) input (0@29-29) +Freeing nterm input (2@0-29) Successful parse. ]]) @@ -441,6 +449,58 @@ Freeing token 'y' (13@130-139) Parsing FAILED. ]]) +# Check destruction upon stack overflow +# ------------------------------------- +# Upon stack overflow, all symbols on the stack should be destroyed. +# Only check for yacc.c. +AT_YACC_IF([ +AT_PARSER_CHECK([./input '(x)(x)(x)(x)(x)(x)(x)'], 2, +[[sending: '(' (0@0-9) +sending: 'x' (1@10-19) +thing (1@10-19): 'x' (1@10-19) +sending: ')' (2@20-29) +line (0@0-29): '(' (0@0-9) thing (1@10-19) ')' (2@20-29) +sending: '(' (3@30-39) +sending: 'x' (4@40-49) +thing (4@40-49): 'x' (4@40-49) +sending: ')' (5@50-59) +line (3@30-59): '(' (3@30-39) thing (4@40-49) ')' (5@50-59) +sending: '(' (6@60-69) +sending: 'x' (7@70-79) +thing (7@70-79): 'x' (7@70-79) +sending: ')' (8@80-89) +line (6@60-89): '(' (6@60-69) thing (7@70-79) ')' (8@80-89) +sending: '(' (9@90-99) +sending: 'x' (10@100-109) +thing (10@100-109): 'x' (10@100-109) +sending: ')' (11@110-119) +line (9@90-119): '(' (9@90-99) thing (10@100-109) ')' (11@110-119) +sending: '(' (12@120-129) +sending: 'x' (13@130-139) +thing (13@130-139): 'x' (13@130-139) +sending: ')' (14@140-149) +line (12@120-149): '(' (12@120-129) thing (13@130-139) ')' (14@140-149) +sending: '(' (15@150-159) +sending: 'x' (16@160-169) +thing (16@160-169): 'x' (16@160-169) +sending: ')' (17@170-179) +line (15@150-179): '(' (15@150-159) thing (16@160-169) ')' (17@170-179) +sending: '(' (18@180-189) +sending: 'x' (19@190-199) +thing (19@190-199): 'x' (19@190-199) +sending: ')' (20@200-209) +200-209: memory exhausted +Freeing nterm thing (19@190-199) +Freeing nterm line (15@150-179) +Freeing nterm line (12@120-149) +Freeing nterm line (9@90-119) +Freeing nterm line (6@60-89) +Freeing nterm line (3@30-59) +Freeing nterm line (0@0-29) +Parsing FAILED (status 2). +]]) +]) + ]) @@ -467,10 +527,8 @@ AT_CHECK_PRINTER_AND_DESTRUCTOR([], [with union]) # These tests currently fail on a Debian GNU/Linux 3.0r2 x86 host, # but the 2nd test succeeds on a Solaris 9 sparc hosts (Forte 7 cc). # Skip them until we figure out what the problem is. -AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], , - [AT_CHECK([exit 77])]) -AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [with union], - [AT_CHECK([exit 77])]) +AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"]) +AT_CHECK_PRINTER_AND_DESTRUCTOR([%defines %skeleton "lalr1.cc"], [with union]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser]) AT_CHECK_PRINTER_AND_DESTRUCTOR([%glr-parser], [with union])