X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/287b314eefdbf95b888f5f13f19bb6f472285b6d..e785ccf715929f1571afc185717b661f5f37e5d4:/tests/actions.at diff --git a/tests/actions.at b/tests/actions.at index a464bd22..0e833a39 100644 --- a/tests/actions.at +++ b/tests/actions.at @@ -1,5 +1,6 @@ # Executing Actions. -*- Autotest -*- -# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 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 @@ -178,7 +179,7 @@ m4_if([$1$2$3], $[1]$[2]$[3], [], # helping macros. So don't put any directly in the Bison file. AT_BISON_OPTION_PUSHDEFS([$5]) AT_DATA_GRAMMAR([[input.y]], -[[%requires { +[[%code requires { #include #include #include @@ -196,8 +197,8 @@ m4_ifval([$6], [%union { int ival; }]) -AT_LALR1_CC_IF([%define "global_tokens_and_yystype"]) -m4_ifval([$6], [[%provides {]], [[%code {]]) +AT_LALR1_CC_IF([%define global_tokens_and_yystype]) +m4_ifval([$6], [[%code provides {]], [[%code {]]) AT_LALR1_CC_IF([typedef yy::location YYLTYPE;]) [static int yylex (]AT_LEX_FORMALS[); ]AT_LALR1_CC_IF([], [static void yyerror (const char *msg);]) @@ -1246,3 +1247,62 @@ Stack now 0 ]]) AT_CLEANUP + + +## ----------------------- ## +## @$ implies %locations. ## +## ----------------------- ## + +# Bison once forgot to check for @$ in actions other than semantic actions. + +# AT_CHECK_ACTION_LOCATIONS(ACTION-DIRECTIVE) +# ------------------------------------------------------- +m4_define([AT_CHECK_ACTION_LOCATIONS], +[AT_SETUP([[@$ in ]$1[ implies %locations]]) + +AT_DATA_GRAMMAR([[input.y]], +[[%code { + #include + static int yylex (void); + static void yyerror (char const *msg); +} + +%debug + +]$1[ { + printf ("%d\n", @$.first_line); +} ]m4_if($1, [%initial-action], [], [[start]])[ + +%% + +start: ; + +%% + +static int +yylex (void) +{ + return 0; +} + +static void +yyerror (char const *msg) +{ + fprintf (stderr, "%s\n", msg); +} + +int +main (void) +{ + return yyparse (); +} +]]) + +AT_CHECK([[bison -o input.c input.y]]) +AT_COMPILE([[input]]) + +AT_CLEANUP]) + +AT_CHECK_ACTION_LOCATIONS([[%initial-action]]) +AT_CHECK_ACTION_LOCATIONS([[%destructor]]) +AT_CHECK_ACTION_LOCATIONS([[%printer]])