]> git.saurik.com Git - bison.git/blob - tests/regression.at
tests: factor the declaration/definition of yyerror and yylex.
[bison.git] / tests / regression.at
1 # Bison Regressions. -*- Autotest -*-
2
3 # Copyright (C) 2001-2012 Free Software Foundation, Inc.
4
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
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.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 AT_BANNER([[Regression tests.]])
19
20
21 ## ------------------ ##
22 ## Trivial grammars. ##
23 ## ------------------ ##
24
25 AT_SETUP([Trivial grammars])
26
27 AT_DATA_GRAMMAR([input.y],
28 [[%{
29 ]AT_YYERROR_DECLARE_EXTERN[
30 ]AT_YYLEX_DECLARE_EXTERN[
31 #define YYSTYPE int *
32 %}
33
34 %error-verbose
35
36 %%
37
38 program: 'x';
39 ]])
40
41 AT_BISON_CHECK([-o input.c input.y])
42 AT_COMPILE([input.o], [-c input.c])
43 AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
44
45 AT_CLEANUP
46
47
48
49 ## ----------------- ##
50 ## YYSTYPE typedef. ##
51 ## ----------------- ##
52
53 AT_SETUP([YYSTYPE typedef])
54
55 AT_DATA_GRAMMAR([input.y],
56 [[%{
57 ]AT_YYERROR_DECLARE_EXTERN[
58 ]AT_YYLEX_DECLARE_EXTERN[
59 typedef union { char const *val; } YYSTYPE;
60 %}
61
62 %type <val> program
63
64 %%
65
66 program: { $$ = ""; };
67 ]])
68
69 AT_BISON_CHECK([-o input.c input.y])
70 AT_COMPILE([input.o], [-c input.c])
71
72 AT_CLEANUP
73
74
75
76 ## ------------------------------------- ##
77 ## Early token definitions with --yacc. ##
78 ## ------------------------------------- ##
79
80
81 AT_SETUP([Early token definitions with --yacc])
82
83 # Found in GCJ: they expect the tokens to be defined before the user
84 # prologue, so that they can use the token definitions in it.
85
86 AT_DATA_GRAMMAR([input.y],
87 [[%{
88 ]AT_YYERROR_DECLARE_EXTERN[
89 ]AT_YYLEX_DECLARE_EXTERN[
90 %}
91
92 %union
93 {
94 int val;
95 };
96 %{
97 #ifndef MY_TOKEN
98 # error "MY_TOKEN not defined."
99 #endif
100 %}
101 %token MY_TOKEN
102 %%
103 exp: MY_TOKEN;
104 %%
105 ]])
106
107 AT_BISON_CHECK([-y -o input.c input.y])
108 AT_COMPILE([input.o], [-c input.c])
109
110 AT_CLEANUP
111
112
113
114 ## ---------------------------------------- ##
115 ## Early token definitions without --yacc. ##
116 ## ---------------------------------------- ##
117
118
119 AT_SETUP([Early token definitions without --yacc])
120
121 # Found in GCJ: they expect the tokens to be defined before the user
122 # prologue, so that they can use the token definitions in it.
123
124 AT_DATA_GRAMMAR([input.y],
125 [[%{
126 #include <stdio.h>
127 ]AT_YYERROR_DECLARE_EXTERN[
128 ]AT_YYLEX_DECLARE_EXTERN[
129 void print_my_token (void);
130 %}
131
132 %union
133 {
134 int val;
135 };
136 %{
137 void
138 print_my_token (void)
139 {
140 enum yytokentype my_token = MY_TOKEN;
141 printf ("%d\n", my_token);
142 }
143 %}
144 %token MY_TOKEN
145 %%
146 exp: MY_TOKEN;
147 %%
148 ]])
149
150 AT_BISON_CHECK([-o input.c input.y])
151 AT_COMPILE([input.o], [-c input.c])
152
153 AT_CLEANUP
154
155
156
157 ## ---------------- ##
158 ## Braces parsing. ##
159 ## ---------------- ##
160
161
162 AT_SETUP([Braces parsing])
163
164 AT_DATA([input.y],
165 [[/* Bison used to swallow the character after '}'. */
166
167 %%
168 exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
169 %%
170 ]])
171
172 AT_BISON_CHECK([-v -o input.c input.y])
173
174 AT_CHECK([grep 'tests = {{{{{{{{{{}}}}}}}}}};' input.c], 0, [ignore])
175
176 AT_CLEANUP
177
178
179 ## ------------------ ##
180 ## Duplicate string. ##
181 ## ------------------ ##
182
183
184 AT_SETUP([Duplicate string])
185
186 AT_DATA([input.y],
187 [[/* 'Bison -v' used to dump core when two tokens are defined with the same
188 string, as LE and GE below. */
189
190 %token NUM
191 %token LE "<="
192 %token GE "<="
193
194 %%
195 exp: '(' exp ')' | NUM ;
196 %%
197 ]])
198
199 AT_BISON_CHECK([-v -o input.c input.y], 0, [],
200 [[input.y:6.8-14: warning: symbol "<=" used more than once as a literal string
201 ]])
202
203 AT_CLEANUP
204
205
206 ## ------------------- ##
207 ## Rule Line Numbers. ##
208 ## ------------------- ##
209
210 AT_SETUP([Rule Line Numbers])
211
212 AT_KEYWORDS([report])
213
214 AT_DATA([input.y],
215 [[%%
216 expr:
217 'a'
218
219 {
220
221 }
222
223 'b'
224
225 {
226
227 }
228
229 |
230
231
232 {
233
234
235 }
236
237 'c'
238
239 {
240
241 };
242 ]])
243
244 AT_BISON_CHECK([-o input.c -v input.y])
245
246 # Check the contents of the report.
247 AT_CHECK([cat input.output], [],
248 [[Grammar
249
250 0 $accept: expr $end
251
252 1 $@1: /* empty */
253
254 2 expr: 'a' $@1 'b'
255
256 3 $@2: /* empty */
257
258 4 expr: $@2 'c'
259
260
261 Terminals, with rules where they appear
262
263 $end (0) 0
264 'a' (97) 2
265 'b' (98) 2
266 'c' (99) 4
267 error (256)
268
269
270 Nonterminals, with rules where they appear
271
272 $accept (6)
273 on left: 0
274 expr (7)
275 on left: 2 4, on right: 0
276 $@1 (8)
277 on left: 1, on right: 2
278 $@2 (9)
279 on left: 3, on right: 4
280
281
282 state 0
283
284 0 $accept: . expr $end
285
286 'a' shift, and go to state 1
287
288 $default reduce using rule 3 ($@2)
289
290 expr go to state 2
291 $@2 go to state 3
292
293
294 state 1
295
296 2 expr: 'a' . $@1 'b'
297
298 $default reduce using rule 1 ($@1)
299
300 $@1 go to state 4
301
302
303 state 2
304
305 0 $accept: expr . $end
306
307 $end shift, and go to state 5
308
309
310 state 3
311
312 4 expr: $@2 . 'c'
313
314 'c' shift, and go to state 6
315
316
317 state 4
318
319 2 expr: 'a' $@1 . 'b'
320
321 'b' shift, and go to state 7
322
323
324 state 5
325
326 0 $accept: expr $end .
327
328 $default accept
329
330
331 state 6
332
333 4 expr: $@2 'c' .
334
335 $default reduce using rule 4 (expr)
336
337
338 state 7
339
340 2 expr: 'a' $@1 'b' .
341
342 $default reduce using rule 2 (expr)
343 ]])
344
345 AT_CLEANUP
346
347
348
349 ## ---------------------- ##
350 ## Mixing %token styles. ##
351 ## ---------------------- ##
352
353
354 AT_SETUP([Mixing %token styles])
355
356 # Taken from the documentation.
357 AT_DATA([input.y],
358 [[%token <operator> OR "||"
359 %token <operator> LE 134 "<="
360 %left OR "<="
361 %%
362 exp: ;
363 %%
364 ]])
365
366 AT_BISON_CHECK([-v -o input.c input.y])
367
368 AT_CLEANUP
369
370
371
372 ## ---------------- ##
373 ## Invalid inputs. ##
374 ## ---------------- ##
375
376
377 AT_SETUP([Invalid inputs])
378
379 AT_DATA([input.y],
380 [[%%
381 ?
382 default: 'a' }
383 %&
384 %a-does-not-exist
385 %-
386 %{
387 ]])
388
389 AT_BISON_CHECK([input.y], [1], [],
390 [[input.y:2.1: invalid character: '?'
391 input.y:3.14: invalid character: '}'
392 input.y:4.1: invalid character: '%'
393 input.y:4.2: invalid character: '&'
394 input.y:5.1-17: invalid directive: '%a-does-not-exist'
395 input.y:6.1: invalid character: '%'
396 input.y:6.2: invalid character: '-'
397 input.y:7.1-8.0: missing '%}' at end of file
398 input.y:7.1-8.0: syntax error, unexpected %{...%}
399 ]])
400
401 AT_CLEANUP
402
403
404 AT_SETUP([Invalid inputs with {}])
405
406 AT_DATA([input.y],
407 [[
408 %destructor
409 %initial-action
410 %lex-param
411 %parse-param
412 %printer
413 %union
414 ]])
415
416 AT_BISON_CHECK([input.y], [1], [],
417 [[input.y:3.1-15: syntax error, unexpected %initial-action, expecting {...}
418 ]])
419
420 AT_CLEANUP
421
422
423
424 ## ------------------- ##
425 ## Token definitions. ##
426 ## ------------------- ##
427
428
429 AT_SETUP([Token definitions])
430
431 # Bison managed, when fed with '%token 'f' "f"' to #define 'f'!
432 AT_DATA_GRAMMAR([input.y],
433 [%{
434 #include <stdlib.h>
435 #include <stdio.h>
436 ]AT_YYERROR_DECLARE[
437 ]AT_YYLEX_DECLARE[
438 %}
439 [%error-verbose
440 %token MYEOF 0 "end of file"
441 %token 'a' "a"
442 %token B_TOKEN "b"
443 %token C_TOKEN 'c'
444 %token 'd' D_TOKEN
445 %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
446 %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
447 %%
448 exp: "a" "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!";
449 %%
450 void
451 yyerror (char const *s)
452 {
453 fprintf (stderr, "%s\n", s);
454 }
455
456 int
457 yylex (void)
458 {
459 static int called;
460 if (called++)
461 abort ();
462 return SPECIAL;
463 }
464
465 int
466 main (void)
467 {
468 return yyparse ();
469 }
470 ]])
471
472 # Checking the warning message guarantees that the trigraph "??!" isn't
473 # unnecessarily escaped here even though it would need to be if encoded in a
474 # C-string literal. Also notice that unnecessary escaping, such as "\?", from
475 # the user specification is eliminated.
476 AT_BISON_CHECK([-o input.c input.y], [[0]], [[]],
477 [[input.y:22.8-14: warning: symbol SPECIAL redeclared
478 input.y:22.8-63: warning: symbol "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" used more than once as a literal string
479 ]])
480 AT_COMPILE([input])
481
482 # Checking the error message here guarantees that yytname, which does contain
483 # C-string literals, does have the trigraph escaped correctly. Thus, the
484 # symbol name reported by the parser is exactly the same as that reported by
485 # Bison itself.
486 AT_DATA([experr],
487 [[syntax error, unexpected "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!", expecting a
488 ]])
489 AT_PARSER_CHECK([./input], 1, [], [experr])
490 AT_CLEANUP
491
492
493
494 ## -------------------- ##
495 ## Characters Escapes. ##
496 ## -------------------- ##
497
498
499 AT_SETUP([Characters Escapes])
500
501 AT_BISON_OPTION_PUSHDEFS
502 AT_DATA_GRAMMAR([input.y],
503 [%{
504 ]AT_YYERROR_DECLARE_EXTERN[
505 ]AT_YYLEX_DECLARE_EXTERN[
506 %}
507 [%%
508 exp:
509 '\'' "\'"
510 | '\"' "\""
511 | '"' "'" /* Pacify font-lock-mode: ". */
512 ;
513 ]])
514
515 AT_BISON_OPTION_POPDEFS
516
517 AT_BISON_CHECK([-o input.c input.y])
518 AT_COMPILE([input.o], [-c input.c])
519 AT_CLEANUP
520
521
522
523 ## -------------- ##
524 ## Web2c Report. ##
525 ## -------------- ##
526
527 # The generation of the reduction was once wrong in Bison, and made it
528 # miss some reductions. In the following test case, the reduction on
529 # 'undef_id_tok' in state 1 was missing. This is stripped down from
530 # the actual web2c.y.
531
532 AT_SETUP([Web2c Report])
533
534 AT_KEYWORDS([report])
535
536 AT_DATA([input.y],
537 [[%token undef_id_tok const_id_tok
538
539 %start CONST_DEC_PART
540 \f
541 %%
542 CONST_DEC_PART:
543 CONST_DEC_LIST
544 ;
545
546 CONST_DEC_LIST:
547 CONST_DEC
548 | CONST_DEC_LIST CONST_DEC
549 ;
550
551 CONST_DEC:
552 { } undef_id_tok '=' const_id_tok ';'
553 ;
554 %%
555 ]])
556
557 AT_BISON_CHECK([-v input.y])
558 AT_CHECK([cat input.output], 0,
559 [[Grammar
560
561 0 $accept: CONST_DEC_PART $end
562
563 1 CONST_DEC_PART: CONST_DEC_LIST
564
565 2 CONST_DEC_LIST: CONST_DEC
566 3 | CONST_DEC_LIST CONST_DEC
567
568 4 $@1: /* empty */
569
570 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';'
571
572
573 Terminals, with rules where they appear
574
575 $end (0) 0
576 ';' (59) 5
577 '=' (61) 5
578 error (256)
579 undef_id_tok (258) 5
580 const_id_tok (259) 5
581
582
583 Nonterminals, with rules where they appear
584
585 $accept (7)
586 on left: 0
587 CONST_DEC_PART (8)
588 on left: 1, on right: 0
589 CONST_DEC_LIST (9)
590 on left: 2 3, on right: 1 3
591 CONST_DEC (10)
592 on left: 5, on right: 2 3
593 $@1 (11)
594 on left: 4, on right: 5
595
596
597 state 0
598
599 0 $accept: . CONST_DEC_PART $end
600
601 $default reduce using rule 4 ($@1)
602
603 CONST_DEC_PART go to state 1
604 CONST_DEC_LIST go to state 2
605 CONST_DEC go to state 3
606 $@1 go to state 4
607
608
609 state 1
610
611 0 $accept: CONST_DEC_PART . $end
612
613 $end shift, and go to state 5
614
615
616 state 2
617
618 1 CONST_DEC_PART: CONST_DEC_LIST .
619 3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC
620
621 undef_id_tok reduce using rule 4 ($@1)
622 $default reduce using rule 1 (CONST_DEC_PART)
623
624 CONST_DEC go to state 6
625 $@1 go to state 4
626
627
628 state 3
629
630 2 CONST_DEC_LIST: CONST_DEC .
631
632 $default reduce using rule 2 (CONST_DEC_LIST)
633
634
635 state 4
636
637 5 CONST_DEC: $@1 . undef_id_tok '=' const_id_tok ';'
638
639 undef_id_tok shift, and go to state 7
640
641
642 state 5
643
644 0 $accept: CONST_DEC_PART $end .
645
646 $default accept
647
648
649 state 6
650
651 3 CONST_DEC_LIST: CONST_DEC_LIST CONST_DEC .
652
653 $default reduce using rule 3 (CONST_DEC_LIST)
654
655
656 state 7
657
658 5 CONST_DEC: $@1 undef_id_tok . '=' const_id_tok ';'
659
660 '=' shift, and go to state 8
661
662
663 state 8
664
665 5 CONST_DEC: $@1 undef_id_tok '=' . const_id_tok ';'
666
667 const_id_tok shift, and go to state 9
668
669
670 state 9
671
672 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok . ';'
673
674 ';' shift, and go to state 10
675
676
677 state 10
678
679 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';' .
680
681 $default reduce using rule 5 (CONST_DEC)
682 ]])
683
684 AT_CLEANUP
685
686
687 ## --------------- ##
688 ## Web2c Actions. ##
689 ## --------------- ##
690
691 # The generation of the mapping 'state -> action' was once wrong in
692 # extremely specific situations. web2c.y exhibits this situation.
693 # Below is a stripped version of the grammar. It looks like one can
694 # simplify it further, but just don't: it is tuned to exhibit a bug,
695 # which disapears when applying sane grammar transformations.
696 #
697 # It used to be wrong on yydefact only:
698 #
699 # static const yytype_uint8 yydefact[] =
700 # {
701 # - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4,
702 # + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4,
703 # 0, 0
704 # };
705 #
706 # but let's check all the tables.
707
708
709 AT_SETUP([Web2c Actions])
710
711 AT_KEYWORDS([report])
712
713 AT_DATA([input.y],
714 [[%%
715 statement: struct_stat;
716 struct_stat: /* empty. */ | if else;
717 if: "if" "const" "then" statement;
718 else: "else" statement;
719 %%
720 ]])
721
722 AT_BISON_CHECK([-v -o input.c input.y])
723
724 # Check only the tables.
725 [sed -n 's/ *$//;/^static const.*\[\] =/,/^}/p' input.c >tables.c]
726
727 AT_CHECK([[cat tables.c]], 0,
728 [[static const yytype_uint8 yytranslate[] =
729 {
730 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
731 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
732 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
733 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
734 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
735 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
736 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
737 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
738 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
739 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
740 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
741 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
742 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
743 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
744 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
745 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
746 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
747 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
748 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
749 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
750 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
751 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
752 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
753 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
754 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
755 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
756 5, 6
757 };
758 static const yytype_uint8 yyprhs[] =
759 {
760 0, 0, 3, 5, 6, 9, 14
761 };
762 static const yytype_int8 yyrhs[] =
763 {
764 8, 0, -1, 9, -1, -1, 10, 11, -1, 3,
765 4, 5, 8, -1, 6, 8, -1
766 };
767 static const yytype_uint8 yyrline[] =
768 {
769 0, 2, 2, 3, 3, 4, 5
770 };
771 static const char *const yytname[] =
772 {
773 "$end", "error", "$undefined", "\"if\"", "\"const\"", "\"then\"",
774 "\"else\"", "$accept", "statement", "struct_stat", "if", "else", YY_NULL
775 };
776 static const yytype_uint16 yytoknum[] =
777 {
778 0, 256, 257, 258, 259, 260, 261
779 };
780 static const yytype_uint8 yyr1[] =
781 {
782 0, 7, 8, 9, 9, 10, 11
783 };
784 static const yytype_uint8 yyr2[] =
785 {
786 0, 2, 1, 0, 2, 4, 2
787 };
788 static const yytype_uint8 yydefact[] =
789 {
790 3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
791 6, 5
792 };
793 static const yytype_int8 yydefgoto[] =
794 {
795 -1, 2, 3, 4, 8
796 };
797 static const yytype_int8 yypact[] =
798 {
799 -2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
800 -8, -8
801 };
802 static const yytype_int8 yypgoto[] =
803 {
804 -8, -7, -8, -8, -8
805 };
806 static const yytype_uint8 yytable[] =
807 {
808 10, 1, 11, 5, 6, 0, 7, 9
809 };
810 static const yytype_int8 yycheck[] =
811 {
812 7, 3, 9, 4, 0, -1, 6, 5
813 };
814 static const yytype_uint8 yystos[] =
815 {
816 0, 3, 8, 9, 10, 4, 0, 6, 11, 5,
817 8, 8
818 };
819 ]])
820
821 AT_CLEANUP
822
823
824 ## ------------------------- ##
825 ## yycheck Bound Violation. ##
826 ## ------------------------- ##
827
828
829 # _AT_DATA_DANCER_Y(BISON-OPTIONS)
830 # --------------------------------
831 # The following grammar, taken from Andrew Suffield's GPL'd implementation
832 # of DGMTP, the Dancer Generic Message Transport Protocol, used to violate
833 # yycheck's bounds where issuing a verbose error message. Keep this test
834 # so that possible bound checking compilers could check all the skeletons.
835 m4_define([_AT_DATA_DANCER_Y],
836 [AT_DATA_GRAMMAR([dancer.y],
837 [%{
838 static int yylex (AT_LALR1_CC_IF([int *], [void]));
839 AT_LALR1_CC_IF([],
840 [#include <stdlib.h>
841 #include <stdio.h>
842 ]AT_YYERROR_DECLARE[])
843 %}
844 $1
845 %token ARROW INVALID NUMBER STRING DATA
846 %defines
847 %verbose
848 %error-verbose
849 /* Grammar follows */
850 %%
851 line: header body
852 ;
853
854 header: '<' from ARROW to '>' type ':'
855 | '<' ARROW to '>' type ':'
856 | ARROW to type ':'
857 | type ':'
858 | '<' '>'
859 ;
860
861 from: DATA
862 | STRING
863 | INVALID
864 ;
865
866 to: DATA
867 | STRING
868 | INVALID
869 ;
870
871 type: DATA
872 | STRING
873 | INVALID
874 ;
875
876 body: /* empty */
877 | body member
878 ;
879
880 member: STRING
881 | DATA
882 | '+' NUMBER
883 | '-' NUMBER
884 | NUMBER
885 | INVALID
886 ;
887 %%
888 AT_LALR1_CC_IF(
889 [/* A C++ error reporting function. */
890 void
891 yy::parser::error (const location&, const std::string& m)
892 {
893 std::cerr << m << std::endl;
894 }
895
896 int
897 yyparse ()
898 {
899 yy::parser parser;
900 #if YYDEBUG
901 parser.set_debug_level (YYDEBUG);
902 #endif
903 return parser.parse ();
904 }
905 ],
906 [static void
907 yyerror (const char *s)
908 {
909 fprintf (stderr, "%s\n", s);
910 }])
911
912 static int
913 yylex (AT_LALR1_CC_IF([int *lval], [void]))
914 [{
915 static int const tokens[] =
916 {
917 ':', -1
918 };
919 static size_t toknum;
920 ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
921 if (! (toknum < sizeof tokens / sizeof *tokens))
922 abort ();
923 return tokens[toknum++];
924 }]
925
926 int
927 main (void)
928 {
929 return yyparse ();
930 }
931 ])
932 ])# _AT_DATA_DANCER_Y
933
934
935 # AT_CHECK_DANCER(BISON-OPTIONS)
936 # ------------------------------
937 # Generate the grammar, compile it, run it.
938 m4_define([AT_CHECK_DANCER],
939 [AT_SETUP([Dancer $1])
940 AT_BISON_OPTION_PUSHDEFS([$1])
941 _AT_DATA_DANCER_Y([$1])
942 AT_BISON_CHECK([-o dancer.c dancer.y])
943 AT_FULL_COMPILE([dancer])
944 AT_PARSER_CHECK([./dancer], 1, [],
945 [syntax error, unexpected ':'
946 ])
947 AT_BISON_OPTION_POPDEFS
948 AT_CLEANUP
949 ])
950
951 AT_CHECK_DANCER()
952 AT_CHECK_DANCER([%glr-parser])
953 AT_CHECK_DANCER([%skeleton "lalr1.cc"])
954
955
956 ## ------------------------------------------ ##
957 ## Diagnostic that expects two alternatives. ##
958 ## ------------------------------------------ ##
959
960
961 # _AT_DATA_EXPECT2_Y(BISON-OPTIONS)
962 # --------------------------------
963 m4_define([_AT_DATA_EXPECT2_Y],
964 [AT_DATA_GRAMMAR([expect2.y],
965 [%{
966 static int yylex (AT_LALR1_CC_IF([int *], [void]));
967 AT_LALR1_CC_IF([],
968 [#include <stdio.h>
969 #include <stdlib.h>
970 ]AT_YYERROR_DECLARE[])
971 %}
972 $1
973 %defines
974 %error-verbose
975 %token A 1000
976 %token B
977
978 %%
979 program: /* empty */
980 | program e ';'
981 | program error ';';
982
983 e: e '+' t | t;
984 t: A | B;
985
986 %%
987 AT_LALR1_CC_IF(
988 [/* A C++ error reporting function. */
989 void
990 yy::parser::error (const location&, const std::string& m)
991 {
992 std::cerr << m << std::endl;
993 }
994
995 int
996 yyparse ()
997 {
998 yy::parser parser;
999 return parser.parse ();
1000 }
1001 ],
1002 [static void
1003 yyerror (const char *s)
1004 {
1005 fprintf (stderr, "%s\n", s);
1006 }])
1007
1008 static int
1009 yylex (AT_LALR1_CC_IF([int *lval], [void]))
1010 [{
1011 static int const tokens[] =
1012 {
1013 1000, '+', '+', -1
1014 };
1015 static size_t toknum;
1016 ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
1017 if (! (toknum < sizeof tokens / sizeof *tokens))
1018 abort ();
1019 return tokens[toknum++];
1020 }]
1021
1022 int
1023 main (void)
1024 {
1025 return yyparse ();
1026 }
1027 ])
1028 ])# _AT_DATA_EXPECT2_Y
1029
1030
1031 # AT_CHECK_EXPECT2(BISON-OPTIONS)
1032 # ------------------------------
1033 # Generate the grammar, compile it, run it.
1034 m4_define([AT_CHECK_EXPECT2],
1035 [AT_SETUP([Expecting two tokens $1])
1036 AT_BISON_OPTION_PUSHDEFS([$1])
1037 _AT_DATA_EXPECT2_Y([$1])
1038 AT_BISON_CHECK([-o expect2.c expect2.y])
1039 AT_FULL_COMPILE([expect2])
1040 AT_PARSER_CHECK([./expect2], 1, [],
1041 [syntax error, unexpected '+', expecting A or B
1042 ])
1043 AT_BISON_OPTION_POPDEFS
1044 AT_CLEANUP
1045 ])
1046
1047 AT_CHECK_EXPECT2()
1048 AT_CHECK_EXPECT2([%glr-parser])
1049 AT_CHECK_EXPECT2([%skeleton "lalr1.cc"])
1050
1051
1052
1053 ## --------------------------------------------- ##
1054 ## Braced code in declaration in rules section. ##
1055 ## --------------------------------------------- ##
1056
1057 AT_SETUP([Braced code in declaration in rules section])
1058
1059 # Bison once mistook braced code in a declaration in the rules section to be a
1060 # rule action.
1061 AT_BISON_OPTION_PUSHDEFS
1062 AT_DATA_GRAMMAR([input.y],
1063 [[%{
1064 #include <stdio.h>
1065 ]AT_YYERROR_DECLARE[
1066 ]AT_YYLEX_DECLARE[
1067 %}
1068
1069 %error-verbose
1070
1071 %%
1072
1073 start:
1074 {
1075 printf ("Bison would once convert this action to a midrule because of the"
1076 " subsequent braced code.\n");
1077 }
1078 ;
1079
1080 %destructor { fprintf (stderr, "DESTRUCTOR\n"); } 'a';
1081 %printer { fprintf (yyoutput, "PRINTER"); } 'a';
1082
1083 %%
1084
1085 ]AT_YYERROR_DEFINE[
1086 static int
1087 yylex (void)
1088 {
1089 return 'a';
1090 }
1091
1092 int
1093 main (void)
1094 {
1095 yydebug = 1;
1096 return !yyparse ();
1097 }
1098 ]])
1099 AT_BISON_OPTION_POPDEFS
1100
1101 AT_BISON_CHECK([-t -o input.c input.y])
1102 AT_COMPILE([input])
1103 AT_PARSER_CHECK([./input], 0,
1104 [[Bison would once convert this action to a midrule because of the subsequent braced code.
1105 ]],
1106 [[Starting parse
1107 Entering state 0
1108 Reducing stack by rule 1 (line 20):
1109 -> $$ = nterm start ()
1110 Stack now 0
1111 Entering state 1
1112 Reading a token: Next token is token 'a' (PRINTER)
1113 syntax error, unexpected 'a', expecting $end
1114 Error: popping nterm start ()
1115 Stack now 0
1116 Cleanup: discarding lookahead token 'a' (PRINTER)
1117 DESTRUCTOR
1118 Stack now 0
1119 ]])
1120
1121 AT_CLEANUP
1122
1123
1124
1125 ## --------------------------------- ##
1126 ## String alias declared after use. ##
1127 ## --------------------------------- ##
1128
1129 AT_SETUP([String alias declared after use])
1130
1131 # Bison once incorrectly asserted that the symbol number for either a token or
1132 # its alias was the highest symbol number so far at the point of the alias
1133 # declaration. That was true unless the declaration appeared after their first
1134 # uses and other tokens appeared in between.
1135
1136 AT_DATA([input.y],
1137 [[%%
1138 start: 'a' "A" 'b';
1139 %token 'a' "A";
1140 ]])
1141
1142 AT_BISON_CHECK([-t -o input.c input.y])
1143
1144 AT_CLEANUP
1145
1146
1147
1148 ## -------------------------------- ##
1149 ## Extra lookahead sets in report. ##
1150 ## -------------------------------- ##
1151
1152 AT_SETUP([[Extra lookahead sets in report]])
1153
1154 # Bison prints each reduction's lookahead set only next to the associated
1155 # state's one item that (1) is associated with the same rule as the reduction
1156 # and (2) has its dot at the end of its RHS. Previously, Bison also
1157 # erroneously printed the lookahead set next to all of the state's other items
1158 # associated with the same rule. This bug affected only the '.output' file and
1159 # not the generated parser source code.
1160
1161 AT_DATA([[input.y]],
1162 [[%%
1163 start: a | 'a' a 'a' ;
1164 a: 'a' ;
1165 ]])
1166
1167 AT_BISON_CHECK([[--report=all input.y]])
1168 AT_CHECK([[sed -n '/^state 1$/,/^state 2$/p' input.output]], [[0]],
1169 [[state 1
1170
1171 2 start: 'a' . a 'a'
1172 3 a: . 'a'
1173 3 | 'a' . [$end]
1174
1175 'a' shift, and go to state 4
1176
1177 $default reduce using rule 3 (a)
1178
1179 a go to state 5
1180
1181
1182 state 2
1183 ]])
1184
1185 AT_CLEANUP
1186
1187
1188
1189 ## ---------------------------------------- ##
1190 ## Token number in precedence declaration. ##
1191 ## ---------------------------------------- ##
1192
1193 AT_SETUP([[Token number in precedence declaration]])
1194
1195 # POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
1196 # we lost this in Bison 1.50.
1197 AT_BISON_OPTION_PUSHDEFS
1198 AT_DATA_GRAMMAR([input.y],
1199 [[%{
1200 #include <stdio.h>
1201 ]AT_YYERROR_DECLARE[
1202 ]AT_YYLEX_DECLARE[
1203 %}
1204
1205 %error-verbose
1206 %right END 0
1207 %left TK1 1 TK2 2 "tok alias" 3
1208
1209 %%
1210
1211 start:
1212 TK1 sr_conflict "tok alias"
1213 | start %prec END
1214 ;
1215 sr_conflict:
1216 TK2
1217 | TK2 "tok alias"
1218 ;
1219
1220 %%
1221
1222 ]AT_YYERROR_DEFINE[
1223 int
1224 yylex (void)
1225 {
1226 static int const input[] = { 1, 2, 3, 0 };
1227 static int const *inputp = input;
1228 return *inputp++;
1229 }
1230
1231 int
1232 main (void)
1233 {
1234 return yyparse ();
1235 }
1236 ]])
1237 AT_BISON_OPTION_POPDEFS
1238
1239 AT_BISON_CHECK([[-o input.c input.y]], [[0]],,
1240 [[input.y:23.5-19: warning: rule useless in parser due to conflicts: start: start
1241 input.y:27.5-19: warning: rule useless in parser due to conflicts: sr_conflict: TK2 "tok alias"
1242 ]])
1243 AT_COMPILE([[input]])
1244 AT_PARSER_CHECK([[./input]])
1245
1246 AT_CLEANUP
1247
1248
1249
1250 ## --------------------------- ##
1251 ## parse-gram.y: LALR = IELR. ##
1252 ## --------------------------- ##
1253
1254 # If parse-gram.y's LALR and IELR parser tables ever begin to differ, we
1255 # need to fix parse-gram.y or start using IELR.
1256
1257 AT_SETUP([[parse-gram.y: LALR = IELR]])
1258
1259 # Avoid differences in synclines by telling bison that the output files
1260 # have the same name.
1261 [cp $abs_top_srcdir/src/parse-gram.y input.y]
1262 AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]])
1263 [mv input.c lalr.c]
1264 AT_CAPTURE_FILE([lalr.c])
1265 AT_BISON_CHECK([[-o input.c -Dlr.type=ielr input.y]])
1266 [mv input.c ielr.c]
1267 AT_CAPTURE_FILE([ielr.c])
1268 AT_CHECK([[diff lalr.c ielr.c]], [[0]])
1269
1270 AT_CLEANUP
1271
1272
1273
1274 ## --------------------------------------- ##
1275 ## %error-verbose and YYSTACK_USE_ALLOCA. ##
1276 ## --------------------------------------- ##
1277
1278 AT_SETUP([[%error-verbose and YYSTACK_USE_ALLOCA]])
1279
1280 AT_BISON_OPTION_PUSHDEFS
1281 AT_DATA_GRAMMAR([input.y],
1282 [[%code {
1283 #include <stdio.h>
1284 ]AT_YYERROR_DECLARE[
1285 ]AT_YYLEX_DECLARE[
1286 #define YYSTACK_USE_ALLOCA 1
1287 }
1288
1289 %error-verbose
1290
1291 %%
1292
1293 start: check syntax_error syntax_error ;
1294
1295 check:
1296 {
1297 if (128 < sizeof yymsgbuf)
1298 {
1299 fprintf (stderr,
1300 "The initial size of yymsgbuf in yyparse has increased\n"
1301 "since this test group was last updated. As a result,\n"
1302 "this test group may no longer manage to induce a\n"
1303 "reallocation of the syntax error message buffer.\n"
1304 "This test group must be adjusted to produce a longer\n"
1305 "error message.\n");
1306 YYABORT;
1307 }
1308 }
1309 ;
1310
1311 // Induce a syntax error message whose total length is more than
1312 // sizeof yymsgbuf in yyparse. Each token here is 64 bytes.
1313 syntax_error:
1314 "123456789112345678921234567893123456789412345678951234567896123A"
1315 | "123456789112345678921234567893123456789412345678951234567896123B"
1316 | error 'a' 'b' 'c'
1317 ;
1318
1319 %%
1320
1321 ]AT_YYERROR_DEFINE[
1322 /* Induce two syntax error messages (which requires full error
1323 recovery by shifting 3 tokens) in order to detect any loss of the
1324 reallocated buffer. */
1325 ]AT_YYLEX_DEFINE([abc])[
1326 int
1327 main (void)
1328 {
1329 return yyparse ();
1330 }
1331 ]])
1332 AT_BISON_OPTION_POPDEFS
1333
1334 AT_BISON_CHECK([[-o input.c input.y]])
1335 AT_COMPILE([[input]])
1336 AT_PARSER_CHECK([[./input]], [[1]], [],
1337 [[syntax error, unexpected 'a', expecting 123456789112345678921234567893123456789412345678951234567896123A or 123456789112345678921234567893123456789412345678951234567896123B
1338 syntax error, unexpected $end, expecting 123456789112345678921234567893123456789412345678951234567896123A or 123456789112345678921234567893123456789412345678951234567896123B
1339 ]])
1340
1341 AT_CLEANUP
1342
1343
1344
1345 ## ------------------------- ##
1346 ## %error-verbose overflow. ##
1347 ## ------------------------- ##
1348
1349 # Imagine the case where YYSTACK_ALLOC_MAXIMUM = YYSIZE_MAXIMUM and an
1350 # invocation of yysyntax_error has caused yymsg_alloc to grow to exactly
1351 # YYSTACK_ALLOC_MAXIMUM (perhaps because the normal doubling of size had
1352 # to be clipped to YYSTACK_ALLOC_MAXIMUM). In an old version of yacc.c,
1353 # a subsequent invocation of yysyntax_error that overflows during its
1354 # size calculation would return YYSIZE_MAXIMUM to yyparse. Then,
1355 # yyparse would invoke yyerror using the old contents of yymsg.
1356
1357 AT_SETUP([[%error-verbose overflow]])
1358 AT_BISON_OPTION_PUSHDEFS
1359 AT_DATA_GRAMMAR([input.y],
1360 [[%code {
1361 #include <stdio.h>
1362 ]AT_YYERROR_DECLARE[
1363 ]AT_YYLEX_DECLARE[
1364
1365 /* This prevents this test case from having to induce error messages
1366 large enough to overflow size_t. */
1367 #define YYSIZE_T unsigned char
1368
1369 /* Bring in malloc and set EXIT_SUCCESS so yacc.c doesn't try to
1370 provide a malloc prototype using our YYSIZE_T. */
1371 #include <stdlib.h>
1372 #ifndef EXIT_SUCCESS
1373 # define EXIT_SUCCESS 0
1374 #endif
1375
1376 /* Max depth is usually much smaller than YYSTACK_ALLOC_MAXIMUM, and
1377 we don't want gcc to warn everywhere this constant would be too big
1378 to make sense for our YYSIZE_T. */
1379 #define YYMAXDEPTH 100
1380 }
1381
1382 %error-verbose
1383
1384 %%
1385
1386 start: syntax_error1 check syntax_error2 ;
1387
1388 // Induce a syntax error message whose total length causes yymsg in
1389 // yyparse to be reallocated to size YYSTACK_ALLOC_MAXIMUM, which
1390 // should be 255. Each token here is 64 bytes.
1391 syntax_error1:
1392 "123456789112345678921234567893123456789412345678951234567896123A"
1393 | "123456789112345678921234567893123456789412345678951234567896123B"
1394 | "123456789112345678921234567893123456789412345678951234567896123C"
1395 | error 'a' 'b' 'c'
1396 ;
1397
1398 check:
1399 {
1400 if (yymsg_alloc != YYSTACK_ALLOC_MAXIMUM
1401 || YYSTACK_ALLOC_MAXIMUM != YYSIZE_MAXIMUM
1402 || YYSIZE_MAXIMUM != 255)
1403 {
1404 fprintf (stderr,
1405 "The assumptions of this test group are no longer\n"
1406 "valid, so it may no longer catch the error it was\n"
1407 "designed to catch. Specifically, the following\n"
1408 "values should all be 255:\n\n");
1409 fprintf (stderr, " yymsg_alloc = %d\n", yymsg_alloc);
1410 fprintf (stderr, " YYSTACK_ALLOC_MAXIMUM = %d\n",
1411 YYSTACK_ALLOC_MAXIMUM);
1412 fprintf (stderr, " YYSIZE_MAXIMUM = %d\n", YYSIZE_MAXIMUM);
1413 YYABORT;
1414 }
1415 }
1416 ;
1417
1418 // Now overflow.
1419 syntax_error2:
1420 "123456789112345678921234567893123456789412345678951234567896123A"
1421 | "123456789112345678921234567893123456789412345678951234567896123B"
1422 | "123456789112345678921234567893123456789412345678951234567896123C"
1423 | "123456789112345678921234567893123456789412345678951234567896123D"
1424 | "123456789112345678921234567893123456789412345678951234567896123E"
1425 ;
1426
1427 %%
1428
1429 ]AT_YYERROR_DEFINE[
1430 /* Induce two syntax error messages (which requires full error
1431 recovery by shifting 3 tokens). */
1432 ]AT_YYLEX_DEFINE([abc])[
1433 int
1434 main (void)
1435 {
1436 /* Push parsers throw away the message buffer between tokens, so skip
1437 this test under maintainer-push-check. */
1438 if (YYPUSH)
1439 return 77;
1440 return yyparse ();
1441 }
1442 ]])
1443
1444 AT_BISON_CHECK([[-o input.c input.y]])
1445
1446 # gcc warns about tautologies and fallacies involving comparisons for
1447 # unsigned char. However, it doesn't produce these same warnings for
1448 # size_t and many other types when the warnings would seem to make just
1449 # as much sense. We ignore the warnings.
1450 [CFLAGS="$NO_WERROR_CFLAGS"]
1451 AT_COMPILE([[input]])
1452
1453 AT_PARSER_CHECK([[./input]], [[2]], [],
1454 [[syntax error, unexpected 'a', expecting 123456789112345678921234567893123456789412345678951234567896123A or 123456789112345678921234567893123456789412345678951234567896123B or 123456789112345678921234567893123456789412345678951234567896123C
1455 syntax error
1456 memory exhausted
1457 ]])
1458 AT_BISON_OPTION_POPDEFS
1459 AT_CLEANUP
1460
1461
1462
1463 ## ------------------------ ##
1464 ## LAC: Exploratory stack. ##
1465 ## ------------------------ ##
1466
1467 AT_SETUP([[LAC: Exploratory stack]])
1468
1469 m4_pushdef([AT_LAC_CHECK], [
1470
1471 AT_BISON_OPTION_PUSHDEFS([$1])
1472
1473 AT_DATA_GRAMMAR([input.y],
1474 [[%code {
1475 #include <stdio.h>
1476 ]AT_YYERROR_DECLARE[
1477 int yylex (]AT_PURE_IF([[YYSTYPE *]], [[void]])[);
1478 }
1479
1480 ]$1[
1481 %error-verbose
1482 %token 'c'
1483
1484 %%
1485
1486 // default reductions in inconsistent states
1487 // v v v v v v v v v v v v v v
1488 S: A B A A B A A A A B A A A A A A A B C C A A A A A A A A A A A A B ;
1489 // ^ ^ ^
1490 // LAC reallocs
1491
1492 A: 'a' | /*empty*/ { printf ("inconsistent default reduction\n"); } ;
1493 B: 'b' ;
1494 C: /*empty*/ { printf ("consistent default reduction\n"); } ;
1495
1496 %%
1497 ]AT_YYERROR_DEFINE[
1498 int
1499 yylex (]AT_PURE_IF([[YYSTYPE *v]], [[void]])[)
1500 {
1501 static char const *input = "bbbbc";]AT_PURE_IF([[
1502 *v = 0;]])[
1503 return *input++;
1504 }
1505
1506 int
1507 main (void)
1508 {
1509 yydebug = 1;
1510 return yyparse ();
1511 }
1512 ]])
1513
1514 AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
1515 -Dparse.lac.memory-trace=full \
1516 -t -o input.c input.y]], [[0]], [],
1517 [[input.y: conflicts: 21 shift/reduce
1518 ]])
1519 AT_COMPILE([[input]])
1520 AT_PARSER_CHECK([[./input > stdout.txt 2> stderr.txt]], [[1]])
1521
1522 # Make sure syntax error doesn't forget that 'a' is expected. It would
1523 # be forgotten without lookahead correction.
1524 AT_CHECK([[grep 'syntax error,' stderr.txt]], [[0]],
1525 [[syntax error, unexpected 'c', expecting 'a' or 'b'
1526 ]])
1527
1528 # Check number of default reductions in inconsistent states to be sure
1529 # syntax error is detected before unnecessary reductions are performed.
1530 AT_CHECK([[perl -0777 -ne 'print s/inconsistent default reduction//g;' \
1531 < stdout.txt || exit 77]], [[0]], [[14]])
1532
1533 # Check number of default reductions in consistent states to be sure
1534 # it is performed before the syntax error is detected.
1535 AT_CHECK([[perl -0777 -ne 'print s/\bconsistent default reduction//g;' \
1536 < stdout.txt || exit 77]], [[0]], [[2]])
1537
1538 # Check number of reallocs to be sure reallocated memory isn't somehow
1539 # lost between LAC invocations.
1540 AT_CHECK([[perl -0777 -ne 'print s/\(realloc//g;' < stderr.txt \
1541 || exit 77]], [[0]], [[3]])
1542
1543 AT_BISON_OPTION_POPDEFS
1544 ])
1545
1546 AT_LAC_CHECK([[%define api.push-pull pull]])
1547 AT_LAC_CHECK([[%define api.push-pull pull %define api.pure]])
1548 AT_LAC_CHECK([[%define api.push-pull both]])
1549 AT_LAC_CHECK([[%define api.push-pull both %define api.pure]])
1550
1551 m4_popdef([AT_LAC_CHECK])
1552
1553 AT_CLEANUP
1554
1555
1556
1557 ## ------------------------ ##
1558 ## LAC: Memory exhaustion. ##
1559 ## ------------------------ ##
1560
1561 AT_SETUP([[LAC: Memory exhaustion]])
1562
1563 m4_pushdef([AT_LAC_CHECK],
1564 [AT_BISON_OPTION_PUSHDEFS
1565 AT_DATA_GRAMMAR([input.y],
1566 [[%code {
1567 #include <stdio.h>
1568 ]AT_YYERROR_DECLARE[
1569 ]AT_YYLEX_DECLARE[
1570 #define YYMAXDEPTH 8
1571 }
1572
1573 %error-verbose
1574
1575 %%
1576
1577 S: A A A A A A A A A ;
1578 A: /*empty*/ | 'a' ;
1579
1580 %%
1581 ]AT_YYERROR_DEFINE[
1582 ]AT_YYLEX_DEFINE([$1])[
1583 int
1584 main (void)
1585 {
1586 yydebug = 1;
1587 return yyparse ();
1588 }
1589 ]])
1590
1591 AT_BISON_CHECK([[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1 \
1592 -t -o input.c input.y]], [[0]], [],
1593 [[input.y: conflicts: 8 shift/reduce
1594 ]])
1595 AT_COMPILE([[input]])
1596 AT_BISON_OPTION_POPDEFS
1597 ])
1598
1599 # Check for memory exhaustion during parsing.
1600 AT_LAC_CHECK([])
1601 AT_PARSER_CHECK([[./input]], [[2]], [],
1602 [[Starting parse
1603 Entering state 0
1604 Reading a token: Now at end of input.
1605 LAC: initial context established for $end
1606 LAC: checking lookahead $end: R2 G3 R2 G5 R2 G6 R2 G7 R2 G8 R2 G9 R2 G10 R2 G11 R2 (max size exceeded)
1607 memory exhausted
1608 Cleanup: discarding lookahead token $end ()
1609 Stack now 0
1610 ]])
1611
1612 # Induce an immediate syntax error with an undefined token, and check
1613 # for memory exhaustion while building syntax error message.
1614 AT_LAC_CHECK([z], [[0]])
1615 AT_PARSER_CHECK([[./input]], [[2]], [],
1616 [[Starting parse
1617 Entering state 0
1618 Reading a token: Next token is token $undefined ()
1619 LAC: initial context established for $undefined
1620 LAC: checking lookahead $undefined: Always Err
1621 Constructing syntax error message
1622 LAC: checking lookahead $end: R2 G3 R2 G5 R2 G6 R2 G7 R2 G8 R2 G9 R2 G10 R2 G11 R2 (max size exceeded)
1623 syntax error
1624 memory exhausted
1625 Cleanup: discarding lookahead token $undefined ()
1626 Stack now 0
1627 ]])
1628
1629 m4_popdef([AT_LAC_CHECK])
1630
1631 AT_CLEANUP