X-Git-Url: https://git.saurik.com/bison.git/blobdiff_plain/8e0a5e9e735620ef5196a155eed1f8cf4d3aab5f..7b30971d7b915f5d9f7bccd24ab5f5b0e18680e1:/tests/actions.at diff --git a/tests/actions.at b/tests/actions.at index b38475e8..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]], -[[%code "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], [[%code "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]])