]> git.saurik.com Git - bison.git/blame - tests/c++.at
doc: fix dependencies
[bison.git] / tests / c++.at
CommitLineData
535ee0cb 1# Checking the C++ Features. -*- Autotest -*-
7d424de1 2
34136e65 3# Copyright (C) 2004-2005, 2007-2012 Free Software Foundation, Inc.
e019c247 4
f16b0819 5# This program is free software: you can redistribute it and/or modify
e019c247 6# it under the terms of the GNU General Public License as published by
f16b0819
PE
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
e019c247
AD
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13# GNU General Public License for more details.
f16b0819 14#
e019c247 15# You should have received a copy of the GNU General Public License
f16b0819 16# along with this program. If not, see <http://www.gnu.org/licenses/>.
e019c247
AD
17
18AT_BANNER([[C++ Features.]])
19
20
76307410
AD
21## ---------- ##
22## Variants. ##
23## ---------- ##
24
e36ec1f4
AD
25# AT_TEST([DIRECTIVES])
26# ---------------------
76307410 27# Check the support of variants in C++, with the additional DIRECTIVES.
e36ec1f4 28m4_pushdef([AT_TEST],
76307410
AD
29[AT_SETUP([Variants $1])
30
e36ec1f4 31AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" $1])
76307410 32# Store strings and integers in a list of strings.
68c989de 33AT_DATA_GRAMMAR([list.yy],
76307410
AD
34[[%debug
35%skeleton "lalr1.cc"
36%defines
37%define variant
e5eb92e7
AD
38]m4_bpatsubst([$1], [\\n], [
39])[
76307410
AD
40
41%code requires // code for the .hh file
42{
43#include <list>
44#include <string>
45typedef std::list<std::string> strings_type;
46}
47
48%code // code for the .cc file
49{
f5fceda5 50#include <cstdlib> // abort, getenv
76307410 51#include <iostream>
76307410
AD
52#include <sstream>
53
e36ec1f4
AD
54 namespace yy
55 {
56 static]AT_TOKEN_CTOR_IF([[
57 parser::symbol_type yylex ()]], [[
f5fceda5
AD
58 parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
59 parser::location_type* yylloc])[)]])[;
e36ec1f4 60 }
76307410 61
dddec537 62 // Printing a list of strings (for %printer).
76307410
AD
63 // Koening look up will look into std, since that's an std::list.
64 namespace std
65 {
66 std::ostream&
67 operator<<(std::ostream& o, const strings_type& s)
68 {
f5da8149 69 o << '(';
77a1a208 70 for (strings_type::const_iterator i = s.begin (); i != s.end (); ++i)
f5da8149
AD
71 {
72 if (i != s.begin ())
73 o << ", ";
74 o << *i;
75 }
76 return o << ')';
76307410
AD
77 }
78 }
79
80 // Conversion to string.
81 template <typename T>
82 inline
83 std::string
84 string_cast (const T& t)
85 {
86 std::ostringstream o;
87 o << t;
77a1a208 88 return o.str ();
76307410
AD
89 }
90}
91
f5da8149 92%token <::std::string> TEXT;
76307410 93%token <int> NUMBER;
76307410
AD
94%token END_OF_FILE 0;
95
f5da8149 96%type <::std::string> item;
cb823b6f
AD
97// Using the template type to exercize its parsing.
98// Starting with :: to ensure we don't output "<::" which starts by the
99// digraph for the left square bracket.
100%type <::std::list<std::string>> list result;
76307410 101
77a1a208 102%printer { yyo << $][$; }
9641b918 103 <int> <::std::string> <::std::list<std::string>>;
76307410
AD
104%%
105
106result:
f5da8149 107 list { std::cout << $][1 << std::endl; }
76307410
AD
108;
109
110list:
cb823b6f 111 /* nothing */ { /* Generates an empty string list */ }
77a1a208
AD
112| list item { std::swap ($][$,$][1); $$.push_back ($][2); }
113| list error { std::swap ($][$,$][1); }
76307410
AD
114;
115
116item:
77a1a208
AD
117 TEXT { std::swap ($][$,$][1); }
118| NUMBER { if ($][1 == 3) YYERROR; else $][$ = string_cast ($][1); }
76307410
AD
119;
120%%
121
e36ec1f4
AD
122#ifdef TWO_STAGE_BUILD
123# define BUILD(Type, Value) build<Type> () = Value
e5eb92e7 124#else
e36ec1f4 125# define BUILD(Type, Value) build (Value)
e5eb92e7 126#endif
76307410 127
e36ec1f4
AD
128#define STAGE_MAX 5
129namespace yy
76307410 130{
e36ec1f4
AD
131 static]AT_TOKEN_CTOR_IF([[
132 parser::symbol_type yylex ()]], [[
f5fceda5
AD
133 parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
134 parser::location_type* yylloc])[)]])[
135 {]AT_LOCATION_IF([
136 typedef parser::location_type location;])[
e36ec1f4
AD
137 static int stage = -1;
138 ++stage;
139 if (stage == STAGE_MAX)
140 {]AT_TOKEN_CTOR_IF([[
f5fceda5
AD
141 return parser::make_END_OF_FILE (]AT_LOCATION_IF([location ()])[);]],
142[AT_LOCATION_IF([
143 *yylloc = location ();])[
e36ec1f4
AD
144 return parser::token::END_OF_FILE;]])[
145 }
146 else if (stage % 2)
147 {]AT_TOKEN_CTOR_IF([[
f5fceda5
AD
148 return parser::make_NUMBER (stage]AT_LOCATION_IF([, location ()])[);]],
149[[
150 yylval->BUILD (int, stage);]AT_LOCATION_IF([
151 *yylloc = location ();])[
e36ec1f4
AD
152 return parser::token::NUMBER;]])[
153 }
154 else
155 {]AT_TOKEN_CTOR_IF([[
f5fceda5
AD
156 return parser::make_TEXT (string_cast (stage)]AT_LOCATION_IF([, location ()])[);]], [[
157 yylval->BUILD (std::string, string_cast (stage));]AT_LOCATION_IF([
158 *yylloc = location ();])[
e36ec1f4
AD
159 return parser::token::TEXT;]])[
160 }
161 abort ();
162 }
76307410
AD
163}
164
f5fceda5
AD
165]AT_YYERROR_DEFINE[
166
e5eb92e7 167int
0bb5783b 168main ()
76307410
AD
169{
170 yy::parser p;
77a1a208
AD
171 p.set_debug_level (!!getenv ("YYDEBUG"));
172 return p.parse ();
76307410
AD
173}
174]])
175
e5eb92e7 176AT_BISON_CHECK([-o list.cc list.yy])
2f130f19 177AT_COMPILE_CXX([list], [$NO_STRICT_ALIAS_CXXFLAGS list.cc])
2c08dc50
AD
178AT_PARSER_CHECK([./list], 0,
179[(0, 1, 2, 4)
76307410
AD
180])
181
e36ec1f4 182AT_BISON_OPTION_POPDEFS
76307410
AD
183AT_CLEANUP
184])
185
e36ec1f4
AD
186AT_TEST([])
187AT_TEST([%define parse.assert])
f5fceda5 188AT_TEST([%locations %define parse.assert])
e36ec1f4
AD
189AT_TEST([[%define parse.assert %code {\n#define TWO_STAGE_BUILD\n}]])
190AT_TEST([[%define parse.assert %define api.token.constructor]])
191AT_TEST([[%define parse.assert %define api.token.constructor %define api.token.prefix "TOK_"]])
f5fceda5 192AT_TEST([[%locations %define parse.assert %define api.token.constructor %define api.token.prefix "TOK_"]])
e36ec1f4
AD
193
194m4_popdef([AT_TEST])
76307410
AD
195
196
e019c247
AD
197## ----------------------- ##
198## Doxygen Documentation. ##
199## ----------------------- ##
200
201m4_define([AT_CHECK_DOXYGEN],
202[m4_case([$1],
203 [Public], [m4_pushdef([AT_DOXYGEN_PRIVATE], [NO])],
204 [Private], [m4_pushdef([AT_DOXYGEN_PRIVATE], [YES])],
e9690142 205 [m4_fatal([invalid argument: $1])])
e019c247
AD
206AT_SETUP([Doxygen $1 Documentation])
207
535ee0cb 208AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
e019c247
AD
209AT_DATA([input.yy],
210[[%skeleton "lalr1.cc"
211%locations
212%debug
213%defines
214%%
215exp:;
216%%
535ee0cb 217]AT_YYERROR_DEFINE[
e019c247
AD
218]])
219
da730230 220AT_BISON_CHECK([-o input.cc input.yy], 0)
e019c247
AD
221
222AT_DATA([Doxyfile],
223[# The PROJECT_NAME tag is a single word (or a sequence of words
224# surrounded by quotes) that should identify the project.
225PROJECT_NAME = "Bison C++ Parser"
226
227# The QUIET tag can be used to turn on/off the messages that are
228# generated by doxygen. Possible values are YES and NO. If left blank
229# NO is used.
230QUIET = YES
231
232# The WARNINGS tag can be used to turn on/off the warning messages
233# that are generated by doxygen. Possible values are YES and NO. If
234# left blank NO is used.
235WARNINGS = YES
236# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate
237# warnings for undocumented members. If EXTRACT_ALL is set to YES then
238# this flag will automatically be disabled.
239WARN_IF_UNDOCUMENTED = YES
240# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings
241# for potential errors in the documentation, such as not documenting
242# some parameters in a documented function, or documenting parameters
243# that don't exist or using markup commands wrongly.
244WARN_IF_DOC_ERROR = YES
245# The WARN_FORMAT tag determines the format of the warning messages
246# that doxygen can produce. The string should contain the $file,
247# $line, and $text tags, which will be replaced by the file and line
248# number from which the warning originated and the warning text.
249WARN_FORMAT = "$file:$line: $text"
250
251# If the EXTRACT_ALL tag is set to YES doxygen will assume all
252# entities in documentation are documented, even if no documentation
253# was available. Private class members and static file members will
254# be hidden unless the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set
255# to YES
256EXTRACT_ALL = YES
257
258# If the EXTRACT_PRIVATE tag is set to YES all private members of a
259# class will be included in the documentation.
260EXTRACT_PRIVATE = AT_DOXYGEN_PRIVATE
261
262# If the EXTRACT_STATIC tag is set to YES all static members of a file
263# will be included in the documentation.
264EXTRACT_STATIC = AT_DOXYGEN_PRIVATE
265])
266
267AT_CHECK([doxygen --version || exit 77], 0, ignore)
268AT_CHECK([doxygen], 0, [], [ignore])
269
535ee0cb 270AT_BISON_OPTION_POPDEFS
e019c247
AD
271AT_CLEANUP
272
273m4_popdef([AT_DOXYGEN_PRIVATE])
274])# AT_CHECK_DOXYGEN
275
276AT_CHECK_DOXYGEN([Public])
277AT_CHECK_DOXYGEN([Private])
793fbca5 278
76307410 279
793fbca5
JD
280## ------------ ##
281## Namespaces. ##
282## ------------ ##
283
284# AT_CHECK_NAMESPACE(NAMESPACE-DECL, [COMPILE-ERROR])
285# ---------------------------------------------------
286# See if Bison can handle %define namespace "NAMESPACE-DECL". If COMPILE-ERROR
287# is specified, then Bison should accept the input, but compilation will fail,
288# so don't check compilation.
289m4_define([AT_CHECK_NAMESPACE],
290[
291
292AT_DATA_GRAMMAR([[input.y]],
293[[%language "C++"
294%defines
67501061 295%define api.namespace "]$1["
793fbca5
JD
296%union { int i; }
297%define global_tokens_and_yystype
2ea7730c 298%locations
793fbca5
JD
299
300%code {
301 // YYSTYPE contains a namespace reference.
d73e55e0 302 int yylex (YYSTYPE *lval, const ]$1[::parser::location_type*) {
793fbca5
JD
303 lval->i = 3;
304 return 0;
305 }
306}
307
308%%
309
310start: ;
311
312%%
313
314void
315]$1[::parser::error (const ]$1[::parser::location_type &loc,
316 const std::string &msg)
317{
318 std::cerr << "At " << loc << ": " << msg << std::endl;
319}
320
321int
0bb5783b 322main ()
793fbca5
JD
323{
324 ]$1[::parser p;
325 return p.parse ();
326}
327]])
328
da730230 329AT_BISON_CHECK([[-o input.cc input.y]])
793fbca5
JD
330
331m4_if([$#], [1],
332[AT_COMPILE_CXX([[input]], [[input.cc]])
333AT_PARSER_CHECK([[./input]])])
334
335])
336
337AT_SETUP([[Relative namespace references]])
338AT_CHECK_NAMESPACE([[foo]])
339AT_CHECK_NAMESPACE([[foo::bar]])
340AT_CHECK_NAMESPACE([[foo::bar::baz]])
341AT_CLEANUP
342
343AT_SETUP([[Absolute namespace references]])
344AT_CHECK_NAMESPACE([[::foo]])
345AT_CHECK_NAMESPACE([[::foo::bar]])
346AT_CHECK_NAMESPACE([[::foo::bar::baz]])
347AT_CHECK_NAMESPACE([[ ::foo]])
348AT_CHECK_NAMESPACE([[ ::foo::bar]])
349AT_CHECK_NAMESPACE([[ ::foo::bar::baz]])
350AT_CLEANUP
351
352AT_SETUP([[Syntactically invalid namespace references]])
353AT_CHECK_NAMESPACE([[:foo:bar]], [[-]])
354AT_CHECK_NAMESPACE([[foo: :bar]], [[-]])
355# This one is interesting because `[3]' is encoded as `@<:@3@:>@', which
356# contains single occurrences of `:'.
357AT_CHECK_NAMESPACE([[foo[3]::bar::baz]], [[-]])
358AT_CHECK_NAMESPACE([[foo::bar,baz]], [[-]])
cb823b6f 359AT_CHECK_NAMESPACE([[foo::bar::(baz /* Pacify Emacs ) */]], [[-]])
793fbca5 360AT_CLEANUP
d59beda0
JD
361
362
363## -------------------------------------- ##
364## Syntax error discarding no lookahead. ##
365## -------------------------------------- ##
366
367# After a syntax error, lalr1.cc used to not check whether there
368# actually is a lookahead before discarding the lookahead. As a result,
369# it mistakenly invoked the destructor for the previous lookahead.
370
371AT_SETUP([[Syntax error discarding no lookahead]])
372
373AT_DATA_GRAMMAR([[input.yy]],
374[[%skeleton "lalr1.cc"
375
376%code {
377 #include <string>
a8c5aaa5 378 int yylex (yy::parser::semantic_type *);
d59beda0
JD
379 #define USE(Args)
380}
381
382%defines
d59beda0
JD
383%define parse.error verbose
384
385%nonassoc 'a' ;
386
387%destructor {
388 std::cerr << "Discarding 'a'." << std::endl;
389} 'a'
390
391%%
392
393start: error-reduce consistent-error 'a' { USE ($3); };
394
395error-reduce:
396 'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); }
397| 'a' error { std::cerr << "Reducing 'a'." << std::endl; USE ($1); }
398;
399
400consistent-error:
401 'a'
402| /*empty*/ %prec 'a'
403;
404
5335b65a
JD
405// Provide another context in which all rules are useful so that this
406// test case looks a little more realistic.
407start: 'b' consistent-error ;
408
d59beda0
JD
409%%
410
411int
a8c5aaa5 412yylex (yy::parser::semantic_type *)
d59beda0
JD
413{
414 static char const *input = "aa";
415 return *input++;
416}
417
418void
a8c5aaa5 419yy::parser::error (const std::string &m)
d59beda0
JD
420{
421 std::cerr << m << std::endl;
422}
423
424int
0bb5783b 425main ()
d59beda0
JD
426{
427 yy::parser parser;
428 return parser.parse ();
429}
430]])
5335b65a 431AT_BISON_CHECK([[-o input.cc input.yy]])
d59beda0
JD
432AT_COMPILE_CXX([[input]])
433# This used to print "Discarding 'a'." again at the end.
434AT_PARSER_CHECK([[./input]], [[1]], [[]],
435[[syntax error
436Discarding 'a'.
437Reducing 'a'.
438]])
439
440AT_CLEANUP
199a2d6d
AD
441
442
443## --------------------------- ##
444## Syntax error as exception. ##
445## --------------------------- ##
446
447AT_SETUP([[Syntax error as exception]])
448
449AT_DATA_GRAMMAR([[input.yy]],
450[[%skeleton "lalr1.cc"
451
452%code
453{
0bb5783b 454 #include <cstdlib>
199a2d6d
AD
455 int yylex (yy::parser::semantic_type *);
456}
457
458%defines
459%define variant
460%define parse.error verbose
461%define parse.trace
462%%
463
464start:
465 thing
466| start thing
467;
468
469thing:
470 error { std::cerr << "caught error" << std::endl; }
471| item
472;
473
474item:
475 'a'
476| 's'
477 {
77a1a208 478 throw yy::parser::syntax_error ("invalid expression");
199a2d6d
AD
479 }
480
481%%
482
483int
484yylex (yy::parser::semantic_type *)
485{
a6552c5d
AD
486 // 's': syntax error, 'l': lexical error.
487 static char const *input = "asal";
199a2d6d
AD
488 switch (int res = *input++)
489 {
a6552c5d 490 case 'l':
77a1a208 491 throw yy::parser::syntax_error ("invalid character");
199a2d6d
AD
492 default:
493 return res;
494 }
495}
496
497void
498yy::parser::error (const std::string &m)
499{
500 std::cerr << "error: " << m << std::endl;
501}
502
503int
0bb5783b 504main ()
199a2d6d
AD
505{
506 yy::parser parser;
77a1a208 507 parser.set_debug_level (!!getenv ("YYDEBUG"));
199a2d6d
AD
508 return parser.parse ();
509}
510]])
511AT_BISON_CHECK([[-o input.cc input.yy]])
512AT_COMPILE_CXX([[input]])
513
514AT_PARSER_CHECK([[./input]], [[0]], [[]],
515[[error: invalid expression
516caught error
a6552c5d
AD
517error: invalid character
518caught error
199a2d6d
AD
519]])
520
521AT_CLEANUP
cff92661
AD
522
523
524## ------------------ ##
525## Exception safety. ##
526## ------------------ ##
527
528AT_SETUP([[Exception safety]])
529
530AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
531
532AT_DATA_GRAMMAR([[input.yy]],
533[[%skeleton "lalr1.cc"
534%defines // FIXME: Mandated in 2.6.
535%debug
e8b86af8 536%error-verbose
cff92661
AD
537
538%code requires
539{
e8b86af8 540 #include <cassert>
cff92661
AD
541 #include <cstdlib> // size_t and getenv.
542 #include <iostream>
e8b86af8 543 #include <list>
cff92661 544
e8b86af8 545 bool debug = false;
cff92661 546
25a6ad2f 547 /// A class that counts its number of instances.
cff92661
AD
548 struct Object
549 {
e8b86af8
AD
550 typedef std::list<const Object*> objects;
551 static objects instances;
552 char val;
cff92661 553
e8b86af8
AD
554 static bool
555 empty ()
556 {
557 return instances.empty();
558 }
559
560 static void
561 log (Object const *o, const std::string& msg)
cff92661 562 {
cff92661 563 if (debug)
e8b86af8
AD
564 {
565 if (o)
566 std::cerr << o << "->";
567 std::cerr << msg << " {";
568 const char* sep = " ";
569 for (objects::const_iterator i = instances.begin(),
570 i_end = instances.end();
571 i != i_end;
572 ++i)
573 {
574 std::cerr << sep << *i;
575 sep = ", ";
576 }
577 std::cerr << " }" << std::endl;
578 }
579 }
580
581 Object (char v)
582 : val (v)
583 {
584 instances.push_back(this);
585 log (this, "Object::Object");
cff92661
AD
586 }
587
588 ~Object ()
589 {
e8b86af8
AD
590 instances.remove(this);
591 log (this, "Object::~Object");
cff92661
AD
592 }
593 };
594}
595
596%code
597{
598 #include <cassert>
a2642464 599 #include <cstring> // strchr
cff92661
AD
600 #include <stdexcept>
601 int yylex (yy::parser::semantic_type *);
e8b86af8 602 Object::objects Object::instances;
cff92661
AD
603 static char const *input;
604}
605
606%union
607{
e8b86af8 608 Object *obj;
cff92661
AD
609}
610
a2642464
AD
611%initial-action
612{
613 if (strchr (input, 'i'))
614 throw std::runtime_error ("initial-action");
615}
616
cff92661 617%destructor { delete $$; } <obj>;
25a6ad2f
AD
618%printer
619{
e8b86af8 620 yyo << $$ << " '" << $$->val << '\'';
25a6ad2f
AD
621 if ($$->val == 'p')
622 throw std::runtime_error ("printer");
623} <obj>;
cff92661 624
e8b86af8 625%token <obj> 'a' 'E' 'e' 'p' 'R' 's' 'T'
cff92661
AD
626%type <obj> list item
627
628%%
629
630start: list { delete $1; };
631
632list:
633 item { $$ = $1; }
25a6ad2f 634| item list { $$ = $1; delete $2; } // Right recursion to load the stack.
cff92661
AD
635;
636
637item:
e8b86af8 638 'a' { $$ = $1; }
23d13411 639| 'e' { YYUSE ($$); YYUSE($1); error ("syntax error"); }
e8b86af8
AD
640// Not just 'E', otherwise we reduce when 'E' is the lookahead, and
641// then the stack is emptied, defeating the point of the test.
642| 'E' 'a' { YYUSE($1); $$ = $2; }
643| 'R' { $$ = YY_NULL; delete $1; YYERROR; }
644| 'p' { $$ = $1; }
645| 's' { $$ = $1; throw std::runtime_error ("reduction"); }
646| 'T' { $$ = YY_NULL; delete $1; YYABORT; }
647| error { $$ = YY_NULL; yyerrok; }
648;
cff92661
AD
649%%
650
651int
652yylex (yy::parser::semantic_type *lvalp)
653{
a2642464 654 // 'a': no error.
e8b86af8
AD
655 // 'e': user action calls error.
656 // 'E': syntax error, with yyerror that throws.
a2642464
AD
657 // 'i': initial action throws.
658 // 'l': yylex throws.
e8b86af8 659 // 'R': call YYERROR in the action
a2642464 660 // 's': reduction throws.
e8b86af8 661 // 'T': call YYABORT in the action
cff92661
AD
662 switch (int res = *input++)
663 {
664 case 'l':
a2642464 665 throw std::runtime_error ("yylex");
cff92661 666 default:
25a6ad2f 667 lvalp->obj = new Object (res);
cff92661
AD
668 // Fall through.
669 case 0:
670 return res;
671 }
672}
673
e8b86af8
AD
674/* A C++ error reporting function. */
675void
23d13411 676yy::parser::error (const std::string& m)
e8b86af8 677{
e8b86af8
AD
678 throw std::runtime_error (m);
679}
cff92661
AD
680
681int
682main (int argc, const char *argv[])
683{
25a6ad2f
AD
684 switch (argc)
685 {
686 case 2:
687 input = argv[1];
688 break;
689 case 3:
2c08dc50 690 assert (std::string(argv[1]) == "--debug");
25a6ad2f
AD
691 debug = 1;
692 input = argv[2];
693 break;
694 default:
695 abort ();
696 }
697
cff92661 698 yy::parser parser;
25a6ad2f 699 debug |= !!getenv ("YYDEBUG");
cff92661
AD
700 parser.set_debug_level (debug);
701 int res = 2;
702 try
703 {
704 res = parser.parse ();
705 }
706 catch (const std::exception& e)
707 {
708 std::cerr << "exception caught: " << e.what () << std::endl;
709 }
710 catch (...)
711 {
712 std::cerr << "unknown exception caught" << std::endl;
713 }
e8b86af8
AD
714 Object::log (YY_NULL, "end");
715 assert (Object::empty());
cff92661
AD
716 return res;
717}
718]])
e8b86af8 719AT_BISON_CHECK([[-o input.cc --report=all input.yy]])
cff92661
AD
720AT_COMPILE_CXX([[input]])
721
722AT_PARSER_CHECK([[./input aaaas]], [[2]], [[]],
a2642464 723[[exception caught: reduction
cff92661
AD
724]])
725
726AT_PARSER_CHECK([[./input aaaal]], [[2]], [[]],
a2642464
AD
727[[exception caught: yylex
728]])
729
730AT_PARSER_CHECK([[./input i]], [[2]], [[]],
731[[exception caught: initial-action
cff92661
AD
732]])
733
25a6ad2f
AD
734AT_PARSER_CHECK([[./input aaaap]])
735
736AT_PARSER_CHECK([[./input --debug aaaap]], [[2]], [[]], [[stderr]])
ebbc76d0 737AT_CHECK([[grep '^exception caught: printer$' stderr]], [], [ignore])
25a6ad2f 738
e8b86af8
AD
739AT_PARSER_CHECK([[./input aaaae]], [[2]], [[]],
740[[exception caught: syntax error
741]])
742
743AT_PARSER_CHECK([[./input aaaaE]], [[2]], [[]],
744[[exception caught: syntax error, unexpected $end, expecting 'a'
745]])
746
747AT_PARSER_CHECK([[./input aaaaT]], [[1]])
748
749# There is error-recovery, so exit success.
750AT_PARSER_CHECK([[./input aaaaR]], [[0]])
751
cff92661
AD
752AT_BISON_OPTION_POPDEFS
753
754AT_CLEANUP