1 # Checking the output filenames. -*- Autotest -*-
2 # Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 AT_BANNER([[C++ Features.]])
24 # AT_CHECK_VARIANTS([DIRECTIVES])
25 # -------------------------------
26 # Check the support of variants in C++, with the additional DIRECTIVES.
27 m4_define([AT_CHECK_VARIANTS],
28 [AT_SETUP([Variants $1])
30 # Store strings and integers in a list of strings.
36 ]m4_bpatsubst([$1], [\\n], [
39 %code requires // code for the .hh file
43 typedef std::list<std::string> strings_type;
46 %code // code for the .cc file
53 // Prototype of the yylex function providing subsequent tokens.
54 static yy::parser::token_type yylex(yy::parser::semantic_type* yylval);
56 // Printing a list of strings.
57 // Koening look up will look into std, since that's an std::list.
61 operator<<(std::ostream& o, const strings_type& s)
63 std::copy(s.begin(), s.end(),
64 std::ostream_iterator<strings_type::value_type>(o, "\n"));
69 // Conversion to string.
73 string_cast (const T& t)
81 %token <std::string> TEXT;
83 %printer { debug_stream() << $][$; } <int> <std::string> <strings_type>;
86 %type <std::string> item;
87 %type <strings_type> list result;
92 list { std::cout << $][1; }
96 /* nothing */ { /* Generates an empty string list */ }
97 | list item { std::swap($][$,$][1); $$.push_back($][2); }
101 TEXT { std::swap($][$,$][1); }
102 | NUMBER { $][$ = string_cast($][1); }
107 yy::parser::token_type
108 yylex(yy::parser::semantic_type* yylval)
110 static int stage = 0;
111 yy::parser::token_type result;
117 #ifdef ONE_STAGE_BUILD
118 yylval->build(string_cast(stage));
120 yylval->build<std::string>() = string_cast(stage);
122 result = yy::parser::token::TEXT;
127 #ifdef ONE_STAGE_BUILD
128 yylval->build(stage);
130 yylval->build<int>() = stage;
132 result = yy::parser::token::NUMBER;
135 result = yy::parser::token::END_OF_FILE;
144 yy::parser::error(const std::string& message)
146 std::cerr << message << std::endl;
150 main(int argc, char *argv[])
153 p.set_debug_level(!!getenv("YYDEBUG"));
158 AT_BISON_CHECK([-o list.cc list.yy])
159 AT_COMPILE_CXX([list])
160 AT_CHECK([./list], 0,
171 AT_CHECK_VARIANTS([])
172 AT_CHECK_VARIANTS([%define assert])
173 AT_CHECK_VARIANTS([[%define assert %code {\n#define ONE_STAGE_BUILD\n}]])
176 ## ----------------------- ##
177 ## Doxygen Documentation. ##
178 ## ----------------------- ##
180 m4_define([AT_CHECK_DOXYGEN],
182 [Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])],
183 [Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])],
184 [m4_fatal([invalid argument: $1])])
185 AT_SETUP([Doxygen $1 Documentation])
188 [[%skeleton "lalr1.cc"
195 yy::parser::error (const location& l, const std::string& m)
197 std::cerr << l << s << std::endl;
201 AT_BISON_CHECK([-o input.cc input.yy], 0)
204 [# The PROJECT_NAME tag is a single word (or a sequence of words
205 # surrounded by quotes) that should identify the project.
206 PROJECT_NAME = "Bison C++ Parser"
208 # The QUIET tag can be used to turn on/off the messages that are
209 # generated by doxygen. Possible values are YES and NO. If left blank
213 # The WARNINGS tag can be used to turn on/off the warning messages
214 # that are generated by doxygen. Possible values are YES and NO. If
215 # left blank NO is used.
217 # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate
218 # warnings for undocumented members. If EXTRACT_ALL is set to YES then
219 # this flag will automatically be disabled.
220 WARN_IF_UNDOCUMENTED = YES
221 # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings
222 # for potential errors in the documentation, such as not documenting
223 # some parameters in a documented function, or documenting parameters
224 # that don't exist or using markup commands wrongly.
225 WARN_IF_DOC_ERROR = YES
226 # The WARN_FORMAT tag determines the format of the warning messages
227 # that doxygen can produce. The string should contain the $file,
228 # $line, and $text tags, which will be replaced by the file and line
229 # number from which the warning originated and the warning text.
230 WARN_FORMAT = "$file:$line: $text"
232 # If the EXTRACT_ALL tag is set to YES doxygen will assume all
233 # entities in documentation are documented, even if no documentation
234 # was available. Private class members and static file members will
235 # be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set
239 # If the EXTRACT_PRIVATE tag is set to YES all private members of a
240 # class will be included in the documentation.
241 EXTRACT_PRIVATE = AT_DOXYGEN_PRIVATE
243 # If the EXTRACT_STATIC tag is set to YES all static members of a file
244 # will be included in the documentation.
245 EXTRACT_STATIC = AT_DOXYGEN_PRIVATE
248 AT_CHECK([doxygen --version || exit 77], 0, ignore)
249 AT_CHECK([doxygen], 0, [], [ignore])
253 m4_popdef([AT_DOXYGEN_PRIVATE])
256 AT_CHECK_DOXYGEN([Public])
257 AT_CHECK_DOXYGEN([Private])
266 # AT_CHECK_NAMESPACE(NAMESPACE-DECL, [COMPILE-ERROR])
267 # ---------------------------------------------------
268 # See if Bison can handle %define namespace "NAMESPACE-DECL". If COMPILE-ERROR
269 # is specified, then Bison should accept the input, but compilation will fail,
270 # so don't check compilation.
271 m4_define([AT_CHECK_NAMESPACE],
274 AT_DATA_GRAMMAR([[input.y]],
277 %define namespace "]$1["
279 %define global_tokens_and_yystype
283 // YYSTYPE contains a namespace reference.
284 int yylex (YYSTYPE *lval, const ]$1[::parser::location_type* lloc) {
297 ]$1[::parser::error (const ]$1[::parser::location_type &loc,
298 const std::string &msg)
300 std::cerr << "At " << loc << ": " << msg << std::endl;
311 AT_BISON_CHECK([[-o input.cc input.y]])
314 [AT_COMPILE_CXX([[input]], [[input.cc]])
315 AT_PARSER_CHECK([[./input]])])
319 AT_SETUP([[Relative namespace references]])
320 AT_CHECK_NAMESPACE([[foo]])
321 AT_CHECK_NAMESPACE([[foo::bar]])
322 AT_CHECK_NAMESPACE([[foo::bar::baz]])
325 AT_SETUP([[Absolute namespace references]])
326 AT_CHECK_NAMESPACE([[::foo]])
327 AT_CHECK_NAMESPACE([[::foo::bar]])
328 AT_CHECK_NAMESPACE([[::foo::bar::baz]])
329 AT_CHECK_NAMESPACE([[ ::foo]])
330 AT_CHECK_NAMESPACE([[ ::foo::bar]])
331 AT_CHECK_NAMESPACE([[ ::foo::bar::baz]])
334 AT_SETUP([[Syntactically invalid namespace references]])
335 AT_CHECK_NAMESPACE([[:foo:bar]], [[-]])
336 AT_CHECK_NAMESPACE([[foo: :bar]], [[-]])
337 # This one is interesting because `[3]' is encoded as `@<:@3@:>@', which
338 # contains single occurrences of `:'.
339 AT_CHECK_NAMESPACE([[foo[3]::bar::baz]], [[-]])
340 AT_CHECK_NAMESPACE([[foo::bar,baz]], [[-]])
341 AT_CHECK_NAMESPACE([[foo::bar::(baz]], [[-]])