]> git.saurik.com Git - bison.git/blame - tests/local.at
* bootstrap: Sync from coreutils.
[bison.git] / tests / local.at
CommitLineData
67a25fed
AD
1# Process this -*- Autotest -*- file with autom4te.
2
3# Macros for the GNU Bison Test suite.
8f7e3cf9 4# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
67a25fed
AD
5
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2, or (at your option)
9# any later version.
10
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
0fb669f9
PE
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19# 02110-1301, USA.
67a25fed 20
1f7a61ff 21# We want a recent Autotest.
ce05140d 22m4_version_prereq([2.58])
1f7a61ff 23
67a25fed
AD
24
25## ------------------------------- ##
26## Macros decoding Bison options. ##
27## ------------------------------- ##
28
29
30# AT_BISON_OPTION_PUSHDEFS([BISON-OPTIONS])
31# -----------------------------------------
32m4_define([AT_BISON_OPTION_PUSHDEFS],
33[_AT_BISON_OPTION_PUSHDEFS($[1], $[2], [$1])])
34
35
36# _AT_BISON_OPTION_PUSHDEFS($1, $2, [BISON-OPTIONS])
37# --------------------------------------------------
38# This macro works around the impossibility to define macros
39# inside macros, because issuing `[$1]' is not possible in M4 :(.
40# This sucks hard, GNU M4 should really provide M5 like $$1.
41m4_define([_AT_BISON_OPTION_PUSHDEFS],
42[m4_if([$1$2], $[1]$[2], [],
43 [m4_fatal([$0: Invalid arguments: $@])])dnl
44m4_pushdef([AT_LALR1_CC_IF],
45[m4_bmatch([$3], ["lalr1.cc"], [$1], [$2])])
8f7e3cf9
AD
46m4_pushdef([AT_GLR_CC_IF],
47[m4_bmatch([$3], ["glr.cc"], [$1], [$2])])
48m4_pushdef([AT_SKEL_CC_IF],
49[m4_bmatch([$3], ["\(glr\|lalr1\).cc"], [$1], [$2])])
67a25fed
AD
50m4_pushdef([AT_GLR_IF],
51[m4_bmatch([$3], [%glr-parser], [$1], [$2])])
52# Using yacc.c?
53m4_pushdef([AT_YACC_IF],
54[m4_bmatch([$3], [%glr-parser\|%skeleton], [$2], [$1])])
55m4_pushdef([AT_PARAM_IF],
56[m4_bmatch([$3], [%parse-param], [$1], [$2])])
57m4_pushdef([AT_LOCATION_IF],
58[m4_bmatch([$3], [%locations], [$1], [$2])])
59m4_pushdef([AT_PURE_IF],
60[m4_bmatch([$3], [%pure-parser], [$1], [$2])])
55a30bda
JD
61m4_pushdef([AT_PUSH_IF],
62[m4_bmatch([$3], [%push-parser], [$1], [$2])])
63m4_pushdef([AT_PURE_OR_PUSH_IF],
64[m4_bmatch([$3], [%pure-parser\|%push-parser], [$1], [$2])])
67a25fed
AD
65m4_pushdef([AT_PURE_AND_LOC_IF],
66[m4_bmatch([$3], [%locations.*%pure-parser\|%pure-parser.*%locations],
02650b7f 67 [$1], [$2])])
67a25fed
AD
68m4_pushdef([AT_GLR_OR_PARAM_IF],
69[m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])])
aa08666d 70m4_pushdef([AT_NAME_PREFIX],
02975b9a
JD
71[m4_bmatch([$3], [%name-prefix ".*"],
72 [m4_bregexp([$3], [name-prefix "\([^"]*\)"], [\1])],
5cf61e93 73 [yy])])
67a25fed
AD
74# yyerror receives the location if %location & %pure & (%glr or %parse-param).
75m4_pushdef([AT_YYERROR_ARG_LOC_IF],
76[AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])],
02650b7f 77 [$2])])
67a25fed 78# yyerror always sees the locations (when activated), except if
55a30bda 79# push or (yacc & pure & !param).
67a25fed 80m4_pushdef([AT_YYERROR_SEES_LOC_IF],
55a30bda 81[AT_PUSH_IF([$2],[AT_LOCATION_IF([AT_YACC_IF([AT_PURE_IF([AT_PARAM_IF([$1], [$2])],
02650b7f
PE
82 [$1])],
83 [$1])],
55a30bda 84 [$2])])])
67a25fed
AD
85
86# The interface is pure: either because %pure-parser, or because we
87# are using the C++ parsers.
88m4_pushdef([AT_PURE_LEX_IF],
55a30bda 89[AT_PURE_OR_PUSH_IF([$1],
aa08666d 90 [AT_SKEL_CC_IF([$1], [$2])])])
67a25fed
AD
91
92AT_PURE_LEX_IF(
ebc3737e
PE
93[m4_pushdef([AT_LOC], [(*llocp)])
94 m4_pushdef([AT_VAL], [(*lvalp)])
67a25fed 95 m4_pushdef([AT_LEX_FORMALS],
02650b7f 96 [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])])
67a25fed 97 m4_pushdef([AT_LEX_ARGS],
02650b7f 98 [lvalp[]AT_LOCATION_IF([, llocp])])
67a25fed 99 m4_pushdef([AT_USE_LEX_ARGS],
02650b7f 100 [(void) lvalp;AT_LOCATION_IF([(void) llocp])])
67a25fed 101 m4_pushdef([AT_LEX_PRE_FORMALS],
02650b7f 102 [AT_LEX_FORMALS, ])
67a25fed 103 m4_pushdef([AT_LEX_PRE_ARGS],
02650b7f 104 [AT_LEX_ARGS, ])
67a25fed
AD
105],
106[m4_pushdef([AT_LOC], [(yylloc)])
107 m4_pushdef([AT_VAL], [(yylval)])
108 m4_pushdef([AT_LEX_FORMALS], [void])
109 m4_pushdef([AT_LEX_ARGS], [])
110 m4_pushdef([AT_USE_LEX_ARGS], [])
111 m4_pushdef([AT_LEX_PRE_FORMALS], [])
112 m4_pushdef([AT_LEX_PRE_ARGS], [])
113])
114])# _AT_BISON_OPTION_PUSHDEFS
115
116
117# AT_BISON_OPTION_POPDEFS
118# -----------------------
119m4_define([AT_BISON_OPTION_POPDEFS],
120[m4_popdef([AT_LEX_PRE_ARGS])
121m4_popdef([AT_LEX_PRE_FORMALS])
122m4_popdef([AT_USE_LEX_ARGS])
123m4_popdef([AT_LEX_ARGS])
124m4_popdef([AT_LEX_FORMALS])
125m4_popdef([AT_VAL])
126m4_popdef([AT_LOC])
127m4_popdef([AT_PURE_LEX_IF])
128m4_popdef([AT_YYERROR_SEES_LOC_IF])
129m4_popdef([AT_YYERROR_ARG_LOC_IF])
aa08666d 130m4_popdef([AT_NAME_PREFIX])
67a25fed
AD
131m4_popdef([AT_GLR_OR_PARAM_IF])
132m4_popdef([AT_PURE_AND_LOC_IF])
133m4_popdef([AT_LOCATION_IF])
134m4_popdef([AT_PARAM_IF])
135m4_popdef([AT_YACC_IF])
136m4_popdef([AT_GLR_IF])
8f7e3cf9
AD
137m4_popdef([AT_SKEL_CC_IF])
138m4_popdef([AT_GLR_CC_IF])
67a25fed
AD
139m4_popdef([AT_LALR1_CC_IF])
140])# AT_BISON_OPTION_POPDEFS
141
142
143
144## -------------------------- ##
145## Generating Grammar Files. ##
146## -------------------------- ##
147
148
149# AT_DATA_GRAMMAR_PROLOGUE
150# ------------------------
151# The prologue that should be included in any grammar which parser is
152# meant to be compiled.
153m4_define([AT_DATA_GRAMMAR_PROLOGUE],
154[[%{
231ed89a
PE
155#include <config.h>
156/* We don't need perfect functions for these tests. */
157#undef malloc
158#undef memcmp
159#undef realloc
67a25fed
AD
160%}]
161])
162
163
164# AT_DATA_GRAMMAR(NAME, CONTENT)
165# ------------------------------
166# Generate the file NAME, which CONTENT is preceded by
167# AT_DATA_GRAMMAR_PROLOGUE.
168m4_define([AT_DATA_GRAMMAR],
169[AT_DATA([$1],
170[AT_DATA_GRAMMAR_PROLOGUE
171$2])
172])
173
174
175## ------------------------ ##
176## Compiling C, C++ Files. ##
177## ------------------------ ##
178
179
180# AT_COMPILE(OUTPUT, [SOURCES = OUTPUT.c])
181# ----------------------------------------
182# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
183# assume that we are linking too; this is a hack.
184m4_define([AT_COMPILE],
72d848c2 185[AT_CHECK([$CC $CFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.c])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
006d217d 186 0, [ignore], [ignore])])
67a25fed 187
07971983 188# AT_COMPILE_CXX(OUTPUT, [SOURCES = OUTPUT.cc])
67a25fed 189# --------------------------------------------
51f4735e
PE
190# Compile SOURCES into OUTPUT. If OUTPUT does not contain '.',
191# assume that we are linking too; this is a hack.
209ea708 192# If the C++ compiler does not work, ignore the test.
67a25fed
AD
193m4_define([AT_COMPILE_CXX],
194[AT_KEYWORDS(c++)
209ea708 195AT_CHECK([$BISON_CXX_WORKS], 0, ignore, ignore)
e6efa9da 196AT_CHECK([$CXX $CXXFLAGS $CPPFLAGS m4_bmatch([$1], [[.]], [], [$LDFLAGS ])-o $1 m4_default([$2], [$1.cc])[]m4_bmatch([$1], [[.]], [], [ $LIBS])],
02650b7f 197 0, [ignore], [ignore])])
67a25fed
AD
198
199
200
201## ---------------------------- ##
202## Running a generated parser. ##
203## ---------------------------- ##
204
205# AT_PARSER_CHECK(COMMAND, EXIT-STATUS, EXPOUT, EXPERR)
206# -----------------------------------------------------
207# So that we can run `./testsuite PREPARSER='valgrind -q' for instance.
208m4_define([AT_PARSER_CHECK],
209[AT_CHECK([$PREPARSER $1], [$2], [$3], [$4])])
1f7a61ff
AD
210
211
212
213
214## ----------------------- ##
215## Launch the test suite. ##
216## ----------------------- ##
217
218AT_INIT
219
220AT_TESTED([bison])