X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/0fb669f9d648dfdd7a39478a6b658511455ae966..e4f0316ae096a728e62032fa33bc6c42cf4b6455:/tests/actions.at diff --git a/tests/actions.at b/tests/actions.at index 7231e7e6..7a03fb00 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1,5 +1,5 @@ # Executing Actions. -*- Autotest -*- -# Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 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 @@ -30,13 +30,13 @@ AT_SETUP([Mid-rule actions]) # action. AT_DATA_GRAMMAR([[input.y]], -[[%{ +[[%error-verbose +%debug +%{ # include # include static void yyerror (const char *msg); static int yylex (void); -# define YYDEBUG 1 -# define YYERROR_VERBOSE 1 %} %% exp: { putchar ('0'); } @@ -91,13 +91,14 @@ AT_CLEANUP AT_SETUP([Exotic Dollars]) AT_DATA_GRAMMAR([[input.y]], -[[%{ +[[%error-verbose +%debug +%{ # include # include static void yyerror (const char *msg); static int yylex (void); -# define YYDEBUG 1 -# define YYERROR_VERBOSE 1 +# define USE(Var) %} %union @@ -112,6 +113,7 @@ AT_DATA_GRAMMAR([[input.y]], exp: a_1 a_2 { $$ = 3; } { $$ = $3 + 1; } a_5 sum_of_the_five_previous_values { + USE (($1, $2, $3, $4, $5)); printf ("%d\n", $6); } ; @@ -145,7 +147,7 @@ main (void) } ]]) -AT_CHECK([bison -d -v -o input.c input.y]) +AT_CHECK([bison -d -v -o input.c input.y], 0) AT_COMPILE([input]) AT_PARSER_CHECK([./input], 0, [[15 @@ -187,6 +189,7 @@ m4_ifval([$6], [%union { int ival; }]) +AT_LALR1_CC_IF([%define "global_tokens_and_yystype"]) [ %{ ]AT_LALR1_CC_IF([typedef yy::location YYLTYPE; @@ -286,7 +289,7 @@ thing: ; %% /* Alias to ARGV[1]. */ -const char *yysource = 0; +const char *source = 0; static int yylex (]AT_LEX_FORMALS[) @@ -303,12 +306,12 @@ yylex (]AT_LEX_FORMALS[) AT_LOC.last_line = AT_LOC.last_column = AT_LOC.first_line + 9; ])[ - if (yysource[c]) - printf ("sending: '%c'", yysource[c]); + if (source[c]) + printf ("sending: '%c'", source[c]); else printf ("sending: EOF"); printf (" (%d@%d-%d)\n", c, RANGE (]AT_LOC[)); - return yysource[c]; + return source[c]; } ]AT_LALR1_CC_IF( @@ -337,16 +340,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 ()) + source = argv[1]; + 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; } ]]) @@ -371,6 +376,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. ]]) @@ -389,6 +395,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. ]]) @@ -450,7 +457,7 @@ Parsing FAILED. # 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)'], 1, +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) @@ -485,7 +492,7 @@ sending: '(' (18@180-189) sending: 'x' (19@190-199) thing (19@190-199): 'x' (19@190-199) sending: ')' (20@200-209) -200-209: parser stack overflow +200-209: memory exhausted Freeing nterm thing (19@190-199) Freeing nterm line (15@150-179) Freeing nterm line (12@120-149) @@ -493,7 +500,7 @@ 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. +Parsing FAILED (status 2). ]]) ])