1 # Bison Regressions. -*- Autotest -*-
3 # Copyright (C) 2001-2015, 2018-2022 Free Software Foundation, Inc.
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.
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.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
18 AT_BANNER([[Regression tests.]])
21 ## ------------------ ##
22 ## Trivial grammars. ##
23 ## ------------------ ##
25 AT_SETUP([Trivial grammars])
27 AT_BISON_OPTION_PUSHDEFS
28 AT_DATA_GRAMMAR([input.y],
30 ]AT_YYERROR_DECLARE_EXTERN[
31 ]AT_YYLEX_DECLARE_EXTERN[
35 %define parse.error verbose
41 AT_BISON_OPTION_POPDEFS
43 AT_BISON_CHECK([-o input.c input.y])
45 AT_COMPILE([input.o], [-DYYDEBUG -c input.c])
51 ## ----------------- ##
52 ## YYSTYPE typedef. ##
53 ## ----------------- ##
55 AT_SETUP([YYSTYPE typedef])
57 AT_BISON_OPTION_PUSHDEFS
58 AT_DATA_GRAMMAR([input.y],
60 ]AT_YYERROR_DECLARE_EXTERN[
61 ]AT_YYLEX_DECLARE_EXTERN[
62 typedef union { char const *val; } YYSTYPE;
69 program: { $$ = ""; };
71 AT_BISON_OPTION_POPDEFS
73 AT_BISON_CHECK([-o input.c input.y])
80 ## ------------------------------------- ##
81 ## Early token definitions with --yacc. ##
82 ## ------------------------------------- ##
85 AT_SETUP([Early token definitions with --yacc])
87 # Found in GCJ: they expect the tokens to be defined before the user
88 # prologue, so that they can use the token definitions in it.
90 AT_BISON_OPTION_PUSHDEFS([%yacc])
92 # Not AT_DATA_GRAMMAR, which uses %code, which is not supported by Yacc.
95 ]AT_YYERROR_DECLARE_EXTERN[
96 ]AT_YYLEX_DECLARE_EXTERN[
105 # error "MY_TOKEN not defined."
113 AT_BISON_OPTION_POPDEFS
115 AT_BISON_CHECK([--yacc -o input.c input.y])
116 AT_COMPILE([input.o])
122 ## ---------------------------------------- ##
123 ## Early token definitions without --yacc. ##
124 ## ---------------------------------------- ##
127 AT_SETUP([Early token definitions without --yacc])
129 # Found in GCJ: they expect the tokens to be defined before the user
130 # prologue, so that they can use the token definitions in it.
132 AT_BISON_OPTION_PUSHDEFS
133 AT_DATA_GRAMMAR([input.y],
135 ]AT_YYERROR_DECLARE_EXTERN[
136 ]AT_YYLEX_DECLARE_EXTERN[
137 void print_my_token (void);
147 print_my_token (void)
149 enum yytokentype tok1 = MY_TOKEN;
150 yytoken_kind_t tok2 = MY_TOKEN;
151 printf ("%d, %d\n", tok1, tok2);
159 AT_BISON_OPTION_POPDEFS
161 AT_BISON_CHECK([-o input.c input.y])
162 AT_COMPILE([input.o])
168 ## ---------------- ##
169 ## Braces parsing. ##
170 ## ---------------- ##
173 AT_SETUP([Braces parsing])
175 AT_BISON_OPTION_PUSHDEFS
177 [[/* Bison used to swallow the character after '}'. */
180 exp: { tests = {{{{{{{{{{}}}}}}}}}}; };
183 AT_BISON_OPTION_POPDEFS
185 AT_BISON_CHECK([-v -o input.c input.y])
187 AT_CHECK([grep 'tests = {{{{{{{{{{}}}}}}}}}};' input.c], 0, [ignore])
192 ## ------------------- ##
193 ## Rule Line Numbers. ##
194 ## ------------------- ##
196 AT_SETUP([Rule Line Numbers])
198 AT_KEYWORDS([report])
200 AT_BISON_OPTION_PUSHDEFS
230 AT_BISON_OPTION_POPDEFS
232 AT_BISON_CHECK([-o input.c -v input.y])
234 # Check the contents of the report.
235 AT_CHECK([cat input.output], [],
249 Terminals, with rules where they appear
258 Nonterminals, with rules where they appear
275 0 $accept: . expr $end
277 'a' shift, and go to state 1
279 $default reduce using rule 3 ($@2)
287 2 expr: 'a' . $@1 'b'
289 $default reduce using rule 1 ($@1)
296 0 $accept: expr . $end
298 $end shift, and go to state 5
305 'c' shift, and go to state 6
310 2 expr: 'a' $@1 . 'b'
312 'b' shift, and go to state 7
317 0 $accept: expr $end .
326 $default reduce using rule 4 (expr)
331 2 expr: 'a' $@1 'b' .
333 $default reduce using rule 2 (expr)
340 ## ---------------------- ##
341 ## Mixing %token styles. ##
342 ## ---------------------- ##
345 AT_SETUP([Mixing %token styles])
347 # Taken from the documentation.
349 [[%token <operator> OR "||"
350 %token <operator> LE 134 "<="
357 AT_BISON_CHECK([-v -Wall -o input.c input.y], 0, [],
358 [[input.y:3.1-5: warning: useless precedence and associativity for "||" [-Wprecedence]
359 input.y:3.1-5: warning: useless precedence and associativity for "<=" [-Wprecedence]
366 ## ------------------- ##
367 ## Token definitions. ##
368 ## ------------------- ##
370 m4_pushdef([AT_TEST],
371 [AT_SETUP([Token definitions: $1])
373 AT_BISON_OPTION_PUSHDEFS([$1])
376 # Clang chokes on some of our comments, because it tries to "parse"
377 # some documentation directives in the comments:
379 # input.c:131:48: error: '\a' command does not have a valid word argument [-Werror,-Wdocumentation]
380 # SPECIAL = 261 /* "\\'?\"\a\b\f\n\r\t\v\001\201\001\201??!" */
382 AT_DATA_GRAMMAR([input.y],
384 #if defined __clang__ && 10 <= __clang_major__
385 # pragma clang diagnostic ignored "-Wdocumentation"
392 %token MYEOF 0 "end of file"
393 %token 'a' "a" // Bison managed, when fed with '%token 'f' "f"' to #define 'f'!
397 %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
398 %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
400 exp: ]AT_ERROR_VERBOSE_IF(["\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"], ["∃¬∩∪∀"])[;
403 ]AT_YYLEX_DEFINE(["a"])[
407 # Checking the warning message guarantees that the trigraph "??!" isn't
408 # unnecessarily escaped here even though it would need to be if encoded in a
409 # C-string literal. Also notice that unnecessary escaping, such as "\?", from
410 # the user specification is eliminated.
411 AT_BISON_CHECK([-fcaret -o input.c input.y], [[0]], [[]],
412 [[input.y:26.8-14: warning: symbol SPECIAL redeclared [-Wother]
413 26 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
415 input.y:25.8-14: note: previous declaration
416 25 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
418 input.y:26.16-63: warning: symbol "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!" used more than once as a literal string [-Wother]
419 26 | %token SPECIAL "\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"
420 | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
425 # Checking the error message here guarantees that yytname, which does contain
426 # C-string literals, does have the trigraph escaped correctly. Thus, the
427 # symbol name reported by the parser is exactly the same as that reported by
429 AT_PARSER_CHECK([input], 1, [],
430 [[syntax error, unexpected a, expecting ]AT_ERROR_VERBOSE_IF([["\\\'\?\"\a\b\f\n\r\t\v\001\201\x001\x000081??!"]], [[∃¬∩∪∀]])[
433 AT_BISON_OPTION_POPDEFS
437 AT_TEST([%define parse.error detailed])
438 AT_TEST([%define parse.error verbose])
442 ## -------------------- ##
443 ## Characters Escapes. ##
444 ## -------------------- ##
447 AT_SETUP([Characters Escapes])
449 AT_BISON_OPTION_PUSHDEFS
450 AT_DATA_GRAMMAR([input.y],
452 ]AT_YYERROR_DECLARE_EXTERN[
453 ]AT_YYLEX_DECLARE_EXTERN[
459 | '"' "'" /* Pacify font-lock-mode: ". */
463 AT_BISON_OPTION_POPDEFS
465 AT_BISON_CHECK([-o input.c input.y])
466 AT_COMPILE([input.o])
475 # The generation of the reduction was once wrong in Bison, and made it
476 # miss some reductions. In the following test case, the reduction on
477 # 'undef_id_tok' in state 1 was missing. This is stripped down from
478 # the actual web2c.y.
480 AT_SETUP([Web2c Report])
482 AT_KEYWORDS([report])
485 [[%token undef_id_tok const_id_tok
487 %start CONST_DEC_PART
496 | CONST_DEC_LIST CONST_DEC
500 { } undef_id_tok '=' const_id_tok ';'
505 AT_BISON_CHECK([-v input.y])
506 AT_CHECK([cat input.output], 0,
509 0 $accept: CONST_DEC_PART $end
511 1 CONST_DEC_PART: CONST_DEC_LIST
513 2 CONST_DEC_LIST: CONST_DEC
514 3 | CONST_DEC_LIST CONST_DEC
518 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';'
521 Terminals, with rules where they appear
531 Nonterminals, with rules where they appear
551 0 $accept: . CONST_DEC_PART $end
553 $default reduce using rule 4 ($@1)
555 CONST_DEC_PART go to state 1
556 CONST_DEC_LIST go to state 2
557 CONST_DEC go to state 3
563 0 $accept: CONST_DEC_PART . $end
565 $end shift, and go to state 5
570 1 CONST_DEC_PART: CONST_DEC_LIST .
571 3 CONST_DEC_LIST: CONST_DEC_LIST . CONST_DEC
573 undef_id_tok reduce using rule 4 ($@1)
574 $default reduce using rule 1 (CONST_DEC_PART)
576 CONST_DEC go to state 6
582 2 CONST_DEC_LIST: CONST_DEC .
584 $default reduce using rule 2 (CONST_DEC_LIST)
589 5 CONST_DEC: $@1 . undef_id_tok '=' const_id_tok ';'
591 undef_id_tok shift, and go to state 7
596 0 $accept: CONST_DEC_PART $end .
603 3 CONST_DEC_LIST: CONST_DEC_LIST CONST_DEC .
605 $default reduce using rule 3 (CONST_DEC_LIST)
610 5 CONST_DEC: $@1 undef_id_tok . '=' const_id_tok ';'
612 '=' shift, and go to state 8
617 5 CONST_DEC: $@1 undef_id_tok '=' . const_id_tok ';'
619 const_id_tok shift, and go to state 9
624 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok . ';'
626 ';' shift, and go to state 10
631 5 CONST_DEC: $@1 undef_id_tok '=' const_id_tok ';' .
633 $default reduce using rule 5 (CONST_DEC)
639 ## --------------- ##
641 ## --------------- ##
643 # The generation of the mapping 'state -> action' was once wrong in
644 # extremely specific situations. web2c.y exhibits this situation.
645 # Below is a stripped version of the grammar. It looks like one can
646 # simplify it further, but just don't: it is tuned to exhibit a bug,
647 # which disappears when applying sane grammar transformations.
649 # It used to be wrong on yydefact only:
651 # static const yytype_uint8 yydefact[] =
653 # - 2, 0, 1, 0, 0, 2, 3, 2, 5, 4,
654 # + 2, 0, 1, 0, 0, 0, 3, 2, 5, 4,
658 # but let's check all the tables.
661 AT_SETUP([Web2c Actions])
663 AT_KEYWORDS([report])
667 statement: struct_stat;
668 struct_stat: %empty | if else;
669 if: "if" "const" "then" statement;
670 else: "else" statement;
674 AT_BISON_CHECK([-v -o input.c input.y])
676 # Check only the tables.
677 [sed -n 's/ *$//;/^static const.*\[] =/,/^}/p;/#define YY.*NINF/p' input.c >tables.c]
679 AT_CHECK([[cat tables.c]], 0,
680 [[static const yytype_int8 yytranslate[] =
682 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
683 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
684 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
685 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
686 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
687 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
688 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
689 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
690 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
691 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
692 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
693 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
694 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
695 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
696 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
697 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
698 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
699 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
700 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
701 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
702 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
703 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
704 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
705 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
706 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
707 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
710 static const yytype_int8 yyrline[] =
714 static const char *const yytname[] =
716 "\"end of file\"", "error", "\"invalid token\"", "\"if\"", "\"const\"",
717 "\"then\"", "\"else\"", "$accept", "statement", "struct_stat", "if",
720 #define YYPACT_NINF (-8)
721 #define YYTABLE_NINF (-1)
722 static const yytype_int8 yypact[] =
724 -2, -1, 4, -8, 0, 2, -8, -2, -8, -2,
727 static const yytype_int8 yydefact[] =
729 3, 0, 0, 2, 0, 0, 1, 3, 4, 3,
732 static const yytype_int8 yypgoto[] =
736 static const yytype_int8 yydefgoto[] =
740 static const yytype_int8 yytable[] =
742 10, 1, 11, 5, 6, 0, 7, 9
744 static const yytype_int8 yycheck[] =
746 7, 3, 9, 4, 0, -1, 6, 5
748 static const yytype_int8 yystos[] =
750 0, 3, 8, 9, 10, 4, 0, 6, 11, 5,
753 static const yytype_int8 yyr1[] =
755 0, 7, 8, 9, 9, 10, 11
757 static const yytype_int8 yyr2[] =
766 ## ---------------- ##
767 ## Useless Tokens. ##
768 ## ---------------- ##
770 # In some extreme situations, with lots of useless tokens, Bison was
771 # numbering them incorrectly, which resulted in a broken grammar.
772 # <https://lists.gnu.org/r/bison-patches/2021-03/msg00001.html>
773 # commit a774839ca873d1082f79ba3c4eecc1e242a28ce1.
775 # To track this failure, compare the tables between an incorrect
776 # version of Bison (e.g., 3.7.5), and a correct one:
778 # LC_ALL=C /usr/local/stow/bison-3.7.5/bin/bison input.y -o old.c &&
779 # LC_ALL=C bison input.y -o new.c &&
780 # sed -n 's/ *$//;/^static const.*\[] =/,/^}/p' old.c >old.tables &&
781 # sed -n 's/ *$//;/^static const.*\[] =/,/^}/p' new.c >new.tables &&
782 # diff old.tables new.tables
784 # The following Ruby script normalizes token and nterm names.
786 # #! /usr/bin/env ruby
793 # ARGV.each do |file|
794 # s = StringScanner.new File.read(file)
798 # when s.scan(/%\w+/)
800 # when s.scan(/[A-Z_0-9]+/)
801 # tokens[s.matched] ||= 'T%02d' % tokens.size
802 # when s.scan(/[a-z_0-9]+/)
803 # nterms[s.matched] ||= 'n%02d' % nterms.size
804 # when s.scan(/.|\n/)
807 # raise "error: #{s.rest}"
812 AT_SETUP([Useless Tokens])
816 T00 T01 T02 T03 T04 T05 T06 T07 T08 T09 T10 T11 T12 T13 T14 T15 T16
817 T17 T18 T19 T20 T21 T22 T23 T24 T25 T26 T27 T28 T29 T30 T31 T32 T33
818 T34 T35 T36 T37 T38 T39 T40 T41 T42 T43 T44 T45 T46 T47 T48 T49 T50
819 T51 T52 T53 T54 T55 T56 T57 T58 T59 T60 T61 T62 T63 T64 T65 T66 T67
820 T68 T69 T70 T71 T72 T73 T74 T75 T76 T77 T78 T79 T80 T81 T82 T83 T84
821 T85 T86 T87 T88 T89 T90
826 n01: T77 T88 n02 T89;
827 n02: n03 n02 | %empty;
828 n03: T16 T88 n04 T89 | T79 T88 n05 T89 | T78 T88 n06 T89 | T81 T88 n07 T89 | T82 T88 n05 T89 | T83 T88 n05 T89 | T84 T88 n05 T89 | T80 T88 n08 T89 | n09;
829 n04: n10 n04 | %empty;
834 n09: T30 T88 n05 T89;
835 n11: n13 n11 | %empty;
836 n13: T85 T88 n05 T89 | T86 T88 n08 T89;
842 n17: T07 T88 n19 T89;
845 n21: T13 T88 n22 T89;
848 n25: n26 T90 n25 | n27 T90 n25;
852 n30: T02 T88 n05 T89;
853 n31: T04 T88 n32 T89;
856 n27: T03 T88 n34 T89;
858 n36: T05 T88 n34 T89 | n36 T06 T88 n34 T89;
860 n37: T16 T88 n38 T89 T90;
862 n39: n05 | T58 T88 n05 T89;
877 n12: n05 n12 | %empty;
880 n55: T15 T88 n05 T89;
884 n59: T13 T88 n22 T89;
885 n60: T75 T88 n22 T89;
886 n61: T18 T88 n05 T89;
887 n62: T76 T88 n46 T89;
889 n64: T14 T88 n22 T89;
890 n65: T10 T88 n42 T89;
892 n67: T08 T88 n05 T89;
893 n68: T11 T88 n42 T89;
894 n69: T17 T88 n05 T89;
896 n71: T16 T88 n72 T89;
898 n73: T24 T88 n48 T89;
899 n74: T12 T88 n05 T89;
900 n75: T09 T88 n05 T89;
902 n77: T64 T88 n78 T89;
904 n79: T66 T88 n05 n40 T89;
907 n82: T69 T88 n22 T89;
908 n83: T47 T88 n05 T89;
912 AT_BISON_CHECK([-Wno-other -o input.c input.y])
914 # Check only the tables.
915 [sed -n 's/ *$//;/^static const.*\[] =/,/^}/p;/#define YY.*NINF/p' input.c >tables.c]
917 AT_CHECK([[cat tables.c]], 0,
918 [[static const yytype_int8 yytranslate[] =
920 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
921 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
922 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
923 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
924 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
925 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
926 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
927 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
928 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
929 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
930 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
931 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
932 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
933 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
934 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
935 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
936 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
937 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
938 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
939 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
940 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
941 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
942 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
943 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
944 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
945 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
946 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
947 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
948 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
949 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
950 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
951 55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
952 65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
953 75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
954 85, 86, 87, 88, 89, 90, 91, 92, 93
956 static const yytype_int8 yyrline[] =
958 0, 11, 11, 12, 13, 13, 14, 14, 14, 14,
959 14, 14, 14, 14, 14, 15, 15, 16, 16, 17,
960 18, 18, 19, 20, 21, 21, 22, 22, 23, 63,
963 static const char *const yytname[] =
965 "\"end of file\"", "error", "\"invalid token\"", "T00", "T01", "T02",
966 "T03", "T04", "T05", "T06", "T07", "T08", "T09", "T10", "T11", "T12",
967 "T13", "T14", "T15", "T16", "T17", "T18", "T19", "T20", "T21", "T22",
968 "T23", "T24", "T25", "T26", "T27", "T28", "T29", "T30", "T31", "T32",
969 "T33", "T34", "T35", "T36", "T37", "T38", "T39", "T40", "T41", "T42",
970 "T43", "T44", "T45", "T46", "T47", "T48", "T49", "T50", "T51", "T52",
971 "T53", "T54", "T55", "T56", "T57", "T58", "T59", "T60", "T61", "T62",
972 "T63", "T64", "T65", "T66", "T67", "T68", "T69", "T70", "T71", "T72",
973 "T73", "T74", "T75", "T76", "T77", "T78", "T79", "T80", "T81", "T82",
974 "T83", "T84", "T85", "T86", "T87", "T88", "T89", "T90", "$accept", "n00",
975 "n01", "n02", "n03", "n04", "n05", "n06", "n07", "n08", "n09", "n11",
976 "n13", "n10", "n12", YY_NULLPTR
978 #define YYPACT_NINF (-78)
979 #define YYTABLE_NINF (-1)
980 static const yytype_int8 yypact[] =
982 -2, -77, 11, -73, -78, -78, -19, -71, -69, -68,
983 -67, -66, -65, -64, -63, -62, -61, -19, -78, -49,
984 -49, -49, -49, -49, -51, -49, -49, -49, -78, -78,
985 -78, -78, -60, -78, -49, -59, -58, -78, -57, -49,
986 -56, -78, -52, -48, -78, -50, -78, -72, -47, -46,
987 -45, -78, -78, -78, -78, -78, -78, -78, -49, -49,
988 -78, -78, -78, -78, -78, -44, -43, -78, -78
990 static const yytype_int8 yydefact[] =
992 0, 0, 0, 0, 2, 1, 5, 0, 0, 0,
993 0, 0, 0, 0, 0, 0, 0, 5, 14, 16,
994 0, 0, 0, 30, 25, 0, 0, 0, 3, 4,
995 17, 18, 0, 28, 16, 0, 0, 19, 0, 30,
996 0, 22, 0, 0, 20, 0, 21, 25, 0, 0,
997 0, 6, 15, 23, 8, 7, 29, 13, 0, 30,
998 9, 24, 10, 11, 12, 0, 0, 26, 27
1000 static const yytype_int8 yypgoto[] =
1002 -78, -78, -78, 2, -78, -4, -18, -78, -78, -15,
1005 static const yytype_int8 yydefgoto[] =
1007 0, 2, 4, 16, 17, 32, 33, 36, 45, 40,
1010 static const yytype_int8 yytable[] =
1012 7, 1, 35, 3, 38, 39, 44, 48, 49, 50,
1013 30, 5, 30, 31, 8, 31, 42, 43, 6, 29,
1014 19, 39, 20, 21, 22, 23, 24, 25, 26, 27,
1015 52, 28, 51, 53, 54, 55, 57, 42, 43, 58,
1016 65, 39, 60, 59, 66, 62, 63, 64, 67, 68,
1017 61, 37, 56, 0, 0, 0, 0, 0, 0, 0,
1018 0, 0, 9, 10, 11, 12, 13, 14, 15
1020 static const yytype_int8 yycheck[] =
1022 19, 3, 20, 80, 22, 23, 24, 25, 26, 27,
1023 61, 0, 61, 64, 33, 64, 88, 89, 91, 17,
1024 91, 39, 91, 91, 91, 91, 91, 91, 91, 91,
1025 34, 92, 92, 92, 92, 92, 92, 88, 89, 91,
1026 58, 59, 92, 91, 59, 92, 92, 92, 92, 92,
1027 47, 21, 39, -1, -1, -1, -1, -1, -1, -1,
1028 -1, -1, 81, 82, 83, 84, 85, 86, 87
1030 static const yytype_int8 yystos[] =
1032 0, 3, 95, 80, 96, 0, 91, 19, 33, 81,
1033 82, 83, 84, 85, 86, 87, 97, 98, 104, 91,
1034 91, 91, 91, 91, 91, 91, 91, 91, 92, 97,
1035 61, 64, 99, 100, 107, 100, 101, 107, 100, 100,
1036 103, 108, 88, 89, 100, 102, 105, 106, 100, 100,
1037 100, 92, 99, 92, 92, 92, 108, 92, 91, 91,
1038 92, 105, 92, 92, 92, 100, 103, 92, 92
1040 static const yytype_int8 yyr1[] =
1042 0, 94, 95, 96, 97, 97, 98, 98, 98, 98,
1043 98, 98, 98, 98, 98, 99, 99, 100, 100, 101,
1044 102, 102, 103, 104, 105, 105, 106, 106, 107, 108,
1047 static const yytype_int8 yyr2[] =
1049 0, 2, 2, 4, 2, 0, 4, 4, 4, 4,
1050 4, 4, 4, 4, 1, 2, 0, 1, 1, 1,
1051 1, 1, 1, 4, 2, 0, 4, 4, 1, 2,
1060 ## ------------------------- ##
1061 ## yycheck Bound Violation. ##
1062 ## ------------------------- ##
1065 # _AT_DATA_DANCER_Y(BISON-OPTIONS)
1066 # --------------------------------
1067 # The following grammar, taken from Andrew Suffield's GPL'd implementation
1068 # of DGMTP, the Dancer Generic Message Transport Protocol, used to violate
1069 # yycheck's bounds where issuing a verbose error message. Keep this test
1070 # so that possible bound checking compilers could check all the skeletons.
1071 m4_define([_AT_DATA_DANCER_Y],
1072 [AT_DATA_GRAMMAR([dancer.y],
1075 ]AT_YYERROR_DECLARE[
1079 %token ARROW INVALID NUMBER STRING DATA
1081 %define parse.error verbose
1082 /* Grammar follows */
1087 header: '<' from ARROW to '>' type ':'
1088 | '<' ARROW to '>' type ':'
1122 ]AT_YYLEX_DEFINE([":"])[
1125 ])# _AT_DATA_DANCER_Y
1128 # AT_CHECK_DANCER(BISON-OPTIONS)
1129 # ------------------------------
1130 # Generate the grammar, compile it, run it.
1131 m4_define([AT_CHECK_DANCER],
1132 [AT_SETUP([Dancer $1])
1133 AT_BISON_OPTION_PUSHDEFS([$1])
1134 _AT_DATA_DANCER_Y([$1])
1135 AT_FULL_COMPILE([dancer])
1136 AT_PARSER_CHECK([dancer], 1, [],
1137 [syntax error, unexpected ':'
1139 AT_BISON_OPTION_POPDEFS
1144 AT_CHECK_DANCER([%glr-parser])
1145 AT_CHECK_DANCER([%skeleton "lalr1.cc"])
1148 ## ------------------------------------------ ##
1149 ## Diagnostic that expects two alternatives. ##
1150 ## ------------------------------------------ ##
1153 # _AT_DATA_EXPECT2_Y(BISON-OPTIONS)
1154 # --------------------------------
1155 m4_define([_AT_DATA_EXPECT2_Y],
1156 [AT_DATA_GRAMMAR([expect2.y],
1158 static int yylex (AT_LALR1_CC_IF([int *], [void]));
1159 AT_LALR1_CC_IF([[#include <cstdlib>]],
1161 ]AT_YYERROR_DECLARE])[
1164 %define parse.error verbose
1171 | program error ';';
1183 return parser.parse ();
1189 yylex (]AT_LALR1_CC_IF([int *lval], [void])[)
1191 static int const tokens[] =
1195 static size_t toknum;
1196 ]AT_LALR1_CC_IF([*lval = 0; /* Pacify GCC. */])[
1197 assert (toknum < sizeof tokens / sizeof *tokens);
1198 return tokens[toknum++];
1202 ])# _AT_DATA_EXPECT2_Y
1205 # AT_CHECK_EXPECT2(BISON-OPTIONS)
1206 # -------------------------------
1207 # Generate the grammar, compile it, run it.
1208 m4_define([AT_CHECK_EXPECT2],
1209 [AT_SETUP([Expecting two tokens $1])
1210 AT_BISON_OPTION_PUSHDEFS([$1])
1211 _AT_DATA_EXPECT2_Y([$1])
1212 AT_FULL_COMPILE([expect2])
1213 AT_PARSER_CHECK([expect2], 1, [],
1214 [syntax error, unexpected '+', expecting A or B
1216 AT_BISON_OPTION_POPDEFS
1221 AT_CHECK_EXPECT2([%glr-parser])
1222 AT_CHECK_EXPECT2([%skeleton "lalr1.cc"])
1226 ## --------------------------------------------- ##
1227 ## Braced code in declaration in rules section. ##
1228 ## --------------------------------------------- ##
1230 AT_SETUP([Braced code in declaration in rules section])
1232 # Bison once mistook braced code in a declaration in the rules section to be a
1234 AT_BISON_OPTION_PUSHDEFS([%debug])
1235 AT_DATA_GRAMMAR([input.y],
1237 ]AT_YYERROR_DECLARE[
1241 %define parse.error verbose
1246 printf ("Bison would once convert this action to a midrule because of the"
1247 " subsequent braced code.\n");
1251 %destructor { fprintf (stderr, "DESTRUCTOR\n"); } 'a';
1252 %printer { fprintf (yyo, "PRINTER"); } 'a';
1256 ]AT_YYLEX_DEFINE(["a"])[
1259 AT_BISON_OPTION_POPDEFS
1261 AT_BISON_CHECK([-o input.c input.y])
1263 AT_PARSER_CHECK([input --debug], 1,
1264 [[Bison would once convert this action to a midrule because of the subsequent braced code.
1269 Reducing stack by rule 1 (line 20):
1270 -> $$ = nterm start ()
1274 Next token is token 'a' (PRINTER)
1275 syntax error, unexpected 'a', expecting end of file
1276 Error: popping nterm start ()
1278 Cleanup: discarding lookahead token 'a' (PRINTER)
1287 ## --------------------------------- ##
1288 ## String alias declared after use. ##
1289 ## --------------------------------- ##
1291 AT_SETUP([String alias declared after use])
1293 # Bison once incorrectly asserted that the symbol number for either a token or
1294 # its alias was the highest symbol number so far at the point of the alias
1295 # declaration. That was true unless the declaration appeared after their first
1296 # uses and other tokens appeared in between.
1304 AT_BISON_CHECK([-o input.c input.y])
1310 ## -------------------------------- ##
1311 ## Extra lookahead sets in report. ##
1312 ## -------------------------------- ##
1314 AT_SETUP([[Extra lookahead sets in report]])
1316 # Bison prints each reduction's lookahead set only next to the associated
1317 # state's one item that (1) is associated with the same rule as the reduction
1318 # and (2) has its dot at the end of its RHS. Previously, Bison also
1319 # erroneously printed the lookahead set next to all of the state's other items
1320 # associated with the same rule. This bug affected only the '.output' file and
1321 # not the generated parser source code.
1323 AT_DATA([[input.y]],
1325 start: a | 'a' a 'a' ;
1329 AT_BISON_CHECK([[--report=all input.y]])
1330 AT_CHECK([[sed -n '/^State 1$/,/^State 2$/p' input.output]], [[0]],
1333 2 start: 'a' . a 'a'
1337 'a' shift, and go to state 4
1339 $default reduce using rule 3 (a)
1351 ## ---------------------------------------- ##
1352 ## Token number in precedence declaration. ##
1353 ## ---------------------------------------- ##
1355 AT_SETUP([[Token number in precedence declaration]])
1357 # POSIX says token numbers can be declared in %left, %right, and %nonassoc, but
1358 # we lost this in Bison 1.50.
1359 AT_BISON_OPTION_PUSHDEFS
1360 AT_DATA_GRAMMAR([input.y],
1362 ]AT_YYERROR_DECLARE[
1365 %define parse.error verbose
1366 %token TK_ALIAS 3 "tok alias"
1368 %left TK1 1 TK2 2 "tok alias"
1373 TK1 sr_conflict "tok alias"
1384 ]AT_YYLEX_DEFINE([{ 1, 2, 3, 0 }])[
1388 AT_BISON_CHECK([[-Wall -o input.c input.y]], [[0]],,
1389 [[input.y:24.5-19: warning: rule useless in parser due to conflicts [-Wother]
1390 input.y:28.5-19: warning: rule useless in parser due to conflicts [-Wother]
1391 input.y:18.1-5: warning: useless precedence and associativity for TK1 [-Wprecedence]
1393 AT_COMPILE([[input]])
1394 AT_PARSER_CHECK([[input]])
1395 AT_BISON_OPTION_POPDEFS
1401 ## --------------------------- ##
1402 ## parse-gram.y: LALR = IELR. ##
1403 ## --------------------------- ##
1405 # If parse-gram.y's LALR and IELR parser tables ever begin to differ, we
1406 # need to fix parse-gram.y or start using IELR.
1408 AT_SETUP([[parse-gram.y: LALR = IELR]])
1410 # Avoid tests/bison's dark magic by processing a local copy of the
1411 # grammar. Avoid differences in synclines by telling bison that the
1412 # output files have the same name.
1413 [cp $abs_top_srcdir/src/parse-gram.y input.y]
1414 AT_BISON_CHECK([[-o input.c -Dlr.type=lalr input.y]])
1416 AT_CAPTURE_FILE([lalr.c])
1417 AT_BISON_CHECK([[-o input.c -Dlr.type=ielr input.y]])
1419 AT_CAPTURE_FILE([ielr.c])
1420 AT_CHECK([[diff lalr.c ielr.c]], [[0]])
1426 ## -------------------------------------------- ##
1427 ## parse.error=verbose and YYSTACK_USE_ALLOCA. ##
1428 ## -------------------------------------------- ##
1430 AT_SETUP([[parse.error=verbose and YYSTACK_USE_ALLOCA]])
1432 AT_BISON_OPTION_PUSHDEFS
1433 AT_DATA_GRAMMAR([input.y],
1435 ]AT_YYERROR_DECLARE[
1437 #define YYSTACK_USE_ALLOCA 1
1440 %define parse.error verbose
1444 start: check syntax_error syntax_error ;
1448 if (128 < sizeof yymsgbuf)
1451 "The initial size of yymsgbuf in yyparse has increased\n"
1452 "since this test group was last updated. As a result,\n"
1453 "this test group may no longer manage to induce a\n"
1454 "reallocation of the syntax error message buffer.\n"
1455 "This test group must be adjusted to produce a longer\n"
1456 "error message.\n");
1462 // Induce a syntax error message whose total length is more than
1463 // sizeof yymsgbuf in yyparse. Each token here is 64 bytes.
1465 "123456789112345678921234567893123456789412345678951234567896123A"
1466 | "123456789112345678921234567893123456789412345678951234567896123B"
1473 /* Induce two syntax error messages (which requires full error
1474 recovery by shifting 3 tokens) in order to detect any loss of the
1475 reallocated buffer. */
1476 ]AT_YYLEX_DEFINE(["abc"])[
1479 AT_BISON_OPTION_POPDEFS
1481 AT_BISON_CHECK([[-o input.c input.y]])
1482 AT_COMPILE([[input]])
1483 AT_PARSER_CHECK([[input]], [[1]], [],
1484 [[syntax error, unexpected 'a', expecting 123456789112345678921234567893123456789412345678951234567896123A or 123456789112345678921234567893123456789412345678951234567896123B
1485 syntax error, unexpected end of file, expecting 123456789112345678921234567893123456789412345678951234567896123A or 123456789112345678921234567893123456789412345678951234567896123B
1492 ## ------------------------------ ##
1493 ## parse.error=verbose overflow. ##
1494 ## ------------------------------ ##
1496 # Imagine the case where YYSTACK_ALLOC_MAXIMUM = YYSIZE_MAXIMUM and an
1497 # invocation of yysyntax_error has caused yymsg_alloc to grow to exactly
1498 # YYSTACK_ALLOC_MAXIMUM (perhaps because the normal doubling of size had
1499 # to be clipped to YYSTACK_ALLOC_MAXIMUM). In an old version of yacc.c,
1500 # a subsequent invocation of yysyntax_error that overflows during its
1501 # size calculation would return YYSIZE_MAXIMUM to yyparse. Then,
1502 # yyparse would invoke yyerror using the old contents of yymsg.
1504 AT_SETUP([[parse.error=verbose overflow]])
1506 AT_BISON_OPTION_PUSHDEFS
1507 AT_DATA_GRAMMAR([input.y],
1509 ]AT_YYERROR_DECLARE[
1512 /* This prevents this test case from having to induce error messages
1513 large enough to overflow size_t. */
1514 #define YYSIZE_T unsigned char
1516 /* Bring in malloc and set EXIT_SUCCESS so yacc.c doesn't try to
1517 provide a malloc prototype using our YYSIZE_T. */
1519 #ifndef EXIT_SUCCESS
1520 # define EXIT_SUCCESS 0
1523 /* Max depth is usually much smaller than YYSTACK_ALLOC_MAXIMUM, and
1524 we don't want gcc to warn everywhere this constant would be too big
1525 to make sense for our YYSIZE_T. */
1526 #define YYMAXDEPTH 100
1529 %define parse.error verbose
1533 start: syntax_error1 check syntax_error2 check syntax_error3;
1535 // Induce a syntax error message whose total length causes yymsg in
1536 // yyparse to be reallocated to size YYSTACK_ALLOC_MAXIMUM, which
1537 // should be 255. Each token here is 64 bytes.
1539 "123456789112345678921234567893123456789412345678951234567896123A"
1540 | "123456789112345678921234567893123456789412345678951234567896123B"
1541 | "123456789112345678921234567893123456789412345678951234567896123C"
1547 if (yymsg_alloc != YYSTACK_ALLOC_MAXIMUM
1548 || YYSTACK_ALLOC_MAXIMUM != YYSIZE_MAXIMUM
1549 || YYSIZE_MAXIMUM != 255)
1552 "The assumptions of this test group are no longer\n"
1553 "valid, so it may no longer catch the error it was\n"
1554 "designed to catch. Specifically, the following\n"
1555 "values should all be 255:\n\n");
1556 fprintf (stderr, " yymsg_alloc = %d\n", yymsg_alloc);
1557 fprintf (stderr, " YYSTACK_ALLOC_MAXIMUM = %d\n",
1558 YYSTACK_ALLOC_MAXIMUM);
1559 fprintf (stderr, " YYSIZE_MAXIMUM = %d\n", YYSIZE_MAXIMUM);
1565 // We used to overflow memory here because the first four "expected"
1566 // tokens plus rest of the error message is greater that 255 bytes.
1567 // However there are *five* expected tokens here, so anyway we will
1568 // *not* display these tokens. So the message fits, no overflow.
1570 "123456789112345678921234567893123456789412345678951234567896123A"
1571 | "123456789112345678921234567893123456789412345678951234567896123B"
1572 | "123456789112345678921234567893123456789412345678951234567896123C"
1573 | "123456789112345678921234567893123456789412345678951234567896123D"
1574 | "123456789112345678921234567893123456789412345678951234567896123E"
1581 "123456789112345678921234567893123456789412345678951234567896123A"
1582 | "123456789112345678921234567893123456789412345678951234567896123B"
1583 | "123456789112345678921234567893123456789412345678951234567896123C"
1584 | "123456789112345678921234567893123456789412345678951234567896123D"
1590 /* Induce two syntax error messages (which requires full error
1591 recovery by shifting 3 tokens). */
1592 ]AT_YYLEX_DEFINE(["abcdef"])[
1596 /* Push parsers throw away the message buffer between tokens, so skip
1597 this test under maintainer-push-check. */
1604 AT_BISON_CHECK([[-o input.c input.y]])
1606 # gcc warns about tautologies and fallacies involving comparisons for
1607 # unsigned char. However, it doesn't produce these same warnings for
1608 # size_t and many other types when the warnings would seem to make just
1609 # as much sense. We ignore the warnings.
1610 [CFLAGS="$NO_WERROR_CFLAGS"]
1611 AT_COMPILE([[input]])
1613 AT_PARSER_CHECK([[input]], [[2]], [],
1614 [[syntax error, unexpected 'a', expecting 123456789112345678921234567893123456789412345678951234567896123A or 123456789112345678921234567893123456789412345678951234567896123B or 123456789112345678921234567893123456789412345678951234567896123C
1615 syntax error, unexpected 'd'
1619 AT_BISON_OPTION_POPDEFS
1624 ## ------------------------ ##
1625 ## LAC: Exploratory stack. ##
1626 ## ------------------------ ##
1628 AT_SETUP([[LAC: Exploratory stack]])
1631 m4_pushdef([AT_LAC_CHECK], [
1633 AT_BISON_OPTION_PUSHDEFS([%debug $1])
1635 AT_DATA_GRAMMAR([input.y],
1637 [d], [[%define api.symbol.prefix {SYM_}
1639 [java], [[%code imports {
1640 import java.io.IOException;
1645 ]AT_YYLEX_DEFINE(["bbbbc"])[
1649 #include <stdio.h> /* printf */
1650 ]AT_YYERROR_DECLARE[
1656 %define parse.error verbose
1661 // default reductions in inconsistent states
1662 // v v v v v v v v v v v v v v
1663 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 ;
1667 A: 'a' | %empty { ]AT_JAVA_IF([System.out.print], [printf])[ ("inconsistent default reduction\n"); } ;
1669 C: %empty { ]AT_JAVA_IF([System.out.print], [printf])[ ("consistent default reduction\n"); } ;
1674 ]AT_YYLEX_DEFINE(["bbbbc"])[
1680 AT_FULL_COMPILE([[input]], [], [], [],
1681 [[-Dparse.lac=full]AT_C_IF([ \
1682 -Dparse.lac.es-capacity-initial=1 \
1683 -Dparse.lac.memory-trace=full])])
1685 AT_PARSER_CHECK([[input --debug > stdout.txt 2> stderr.txt]], [[1]])
1687 # Make sure syntax error doesn't forget that 'a' is expected. It would
1688 # be forgotten without lookahead correction.
1689 AT_CHECK([[grep 'syntax error,' stderr.txt]], [[0]],
1690 [[syntax error, unexpected 'c', expecting 'a' or 'b'
1693 # Check number of default reductions in inconsistent states to be sure
1694 # syntax error is detected before unnecessary reductions are performed.
1695 AT_PERL_CHECK([[-0777 -ne 'print s/inconsistent default reduction//g;' stdout.txt]],
1698 # Check number of default reductions in consistent states to be sure
1699 # it is performed before the syntax error is detected.
1700 AT_PERL_CHECK([[-0777 -ne 'print s/\bconsistent default reduction//g;' stdout.txt]],
1704 # Check number of reallocs to be sure reallocated memory isn't somehow
1705 # lost between LAC invocations.
1706 AT_PERL_CHECK([[-0777 -ne 'print s/\(realloc//g;' < stderr.txt]], [[0]], [[3]])
1709 AT_BISON_OPTION_POPDEFS
1713 AT_LAC_CHECK([[%define api.push-pull pull]])
1714 AT_LAC_CHECK([[%define api.push-pull pull %define api.pure]])
1715 AT_LAC_CHECK([[%define api.push-pull both]])
1716 AT_LAC_CHECK([[%define api.push-pull both %define api.pure]])
1719 AT_LAC_CHECK([[%skeleton "lalr1.cc"]])
1722 # FIXME: does not work. lalr1.d cannot work with literal chars,
1723 # and AT_YYLEX_DEFINE(d) is incorrect.
1724 # AT_LAC_CHECK([[%skeleton "lalr1.d"]])
1727 AT_LAC_CHECK([[%skeleton "lalr1.java"]])
1729 m4_popdef([AT_LAC_CHECK])
1735 ## ------------------------ ##
1736 ## LAC: Memory exhaustion. ##
1737 ## ------------------------ ##
1739 AT_SETUP([[LAC: Memory exhaustion]])
1742 m4_pushdef([AT_LAC_CHECK],
1743 [AT_BISON_OPTION_PUSHDEFS([%debug])
1744 AT_DATA_GRAMMAR([input.y],
1746 ]AT_YYERROR_DECLARE[
1748 #define YYMAXDEPTH 8
1751 %define parse.error verbose
1755 S: A A A A A A A A A ;
1760 ]AT_YYLEX_DEFINE(["$1"])[
1764 AT_FULL_COMPILE([input], [], [], [],
1765 [[-Dparse.lac=full -Dparse.lac.es-capacity-initial=1]])
1766 AT_COMPILE([[input]])
1767 AT_BISON_OPTION_POPDEFS
1770 # Check for memory exhaustion during parsing.
1772 AT_PARSER_CHECK([[input --debug]], [[2]], [],
1777 Now at end of input.
1778 LAC: initial context established for "end of file"
1779 LAC: checking lookahead "end of file": R2 G3 R2 G5 R2 G6 R2 G7 R2 G8 R2 G9 R2 G10 R2 G11 R2 (max size exceeded)
1781 Cleanup: discarding lookahead token "end of file" ()
1785 # Induce an immediate syntax error with an undefined token, and check
1786 # for memory exhaustion while building syntax error message.
1787 AT_LAC_CHECK([z], [[0]])
1788 AT_PARSER_CHECK([[input --debug]], [[2]], [],
1793 Next token is token "invalid token" ()
1794 LAC: initial context established for "invalid token"
1795 LAC: checking lookahead "invalid token": Always Err
1796 Constructing syntax error message
1797 LAC: checking lookahead "end of file": R2 G3 R2 G5 R2 G6 R2 G7 R2 G8 R2 G9 R2 G10 R2 G11 R2 (max size exceeded)
1800 Cleanup: discarding lookahead token "invalid token" ()
1804 m4_popdef([AT_LAC_CHECK])
1809 ## ---------------------- ##
1810 ## Lex and parse params. ##
1811 ## ---------------------- ##
1815 # Check that the identifier of the params is properly fetched
1816 # even when there are trailing blanks.
1818 m4_pushdef([AT_TEST],
1819 [AT_SETUP([[Lex and parse params: $1]])
1821 ## FIXME: Improve parsing of parse-param.
1822 AT_BISON_OPTION_PUSHDEFS([%locations %skeleton "$1" %parse-param { int x } %parse-param { int y }])
1824 AT_DATA_GRAMMAR([input.y],
1828 %union { int ival; }
1829 %parse-param { int x }
1830 // Spaces, tabs, and new lines.
1838 #include <stdio.h> /* printf. */
1839 ]AT_YYERROR_DECLARE[
1844 exp: 'a' { printf ("x: %d, y: %d\n", x, y); };
1847 ]AT_YYLEX_DEFINE(["a"])[
1851 yyparse (int x, int y)
1853 yy::parser parser(x, y);
1854 return parser.parse ();
1861 return yyparse(1, 2);
1865 AT_FULL_COMPILE([input])
1866 AT_PARSER_CHECK([input], 0, [[x: 1, y: 2
1868 AT_BISON_OPTION_POPDEFS
1873 ## FIXME: test Java, and iterate over skeletons.
1880 m4_popdef([AT_TEST])
1883 ## ----------------------- ##
1884 ## stdio.h is not needed. ##
1885 ## ----------------------- ##
1887 # At some point, by accident, yy_location_print_ was using fprintf and
1888 # FILE which are from stdio.h, which we do not require.
1889 AT_SETUP([[stdio.h is not needed]])
1891 AT_BISON_OPTION_PUSHDEFS
1893 AT_DATA_GRAMMAR([input.y],
1897 static int yylex (void) { return 0; }
1898 static void yyerror (const char* msg) { (void) msg; }
1906 AT_FULL_COMPILE([input])
1908 AT_BISON_OPTION_POPDEFS