1 /* A Bison parser, made by GNU Bison 3.7.5.297-b46a. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
41 /* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
48 /* Identify Bison output, and Bison version. */
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.7.5.297-b46a"
55 #define YYSKELETON_NAME "yacc.c"
66 /* "%code top" blocks. */
68 /* On column 0 to please syntax-check. */
71 /* Substitute the type names. */
72 #define YYSTYPE GRAM_STYPE
73 #define YYLTYPE GRAM_LTYPE
74 /* Substitute the variable and function names. */
75 #define yyparse gram_parse
76 #define yylex gram_lex
77 #define yyerror gram_error
78 #define yydebug gram_debug
79 #define yynerrs gram_nerrs
84 # define YY_CAST(Type, Val) static_cast<Type> (Val)
85 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
87 # define YY_CAST(Type, Val) ((Type) (Val))
88 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
92 # if defined __cplusplus
93 # if 201103L <= __cplusplus
94 # define YY_NULLPTR nullptr
99 # define YY_NULLPTR ((void*)0)
103 #include "src/parse-gram.h"
107 YYSYMBOL_YYEMPTY
= -2,
108 YYSYMBOL_YYEOF
= 0, /* "end of file" */
109 YYSYMBOL_YYerror
= 1, /* error */
110 YYSYMBOL_YYUNDEF
= 2, /* "invalid token" */
111 YYSYMBOL_STRING
= 3, /* "string" */
112 YYSYMBOL_TSTRING
= 4, /* "translatable string" */
113 YYSYMBOL_PERCENT_TOKEN
= 5, /* "%token" */
114 YYSYMBOL_PERCENT_NTERM
= 6, /* "%nterm" */
115 YYSYMBOL_PERCENT_TYPE
= 7, /* "%type" */
116 YYSYMBOL_PERCENT_DESTRUCTOR
= 8, /* "%destructor" */
117 YYSYMBOL_PERCENT_PRINTER
= 9, /* "%printer" */
118 YYSYMBOL_PERCENT_LEFT
= 10, /* "%left" */
119 YYSYMBOL_PERCENT_RIGHT
= 11, /* "%right" */
120 YYSYMBOL_PERCENT_NONASSOC
= 12, /* "%nonassoc" */
121 YYSYMBOL_PERCENT_PRECEDENCE
= 13, /* "%precedence" */
122 YYSYMBOL_PERCENT_PREC
= 14, /* "%prec" */
123 YYSYMBOL_PERCENT_DPREC
= 15, /* "%dprec" */
124 YYSYMBOL_PERCENT_MERGE
= 16, /* "%merge" */
125 YYSYMBOL_PERCENT_CODE
= 17, /* "%code" */
126 YYSYMBOL_PERCENT_DEFAULT_PREC
= 18, /* "%default-prec" */
127 YYSYMBOL_PERCENT_DEFINE
= 19, /* "%define" */
128 YYSYMBOL_PERCENT_ERROR_VERBOSE
= 20, /* "%error-verbose" */
129 YYSYMBOL_PERCENT_EXPECT
= 21, /* "%expect" */
130 YYSYMBOL_PERCENT_EXPECT_RR
= 22, /* "%expect-rr" */
131 YYSYMBOL_PERCENT_FILE_PREFIX
= 23, /* "%file-prefix" */
132 YYSYMBOL_PERCENT_FLAG
= 24, /* "%<flag>" */
133 YYSYMBOL_PERCENT_GLR_PARSER
= 25, /* "%glr-parser" */
134 YYSYMBOL_PERCENT_HEADER
= 26, /* "%header" */
135 YYSYMBOL_PERCENT_INITIAL_ACTION
= 27, /* "%initial-action" */
136 YYSYMBOL_PERCENT_LANGUAGE
= 28, /* "%language" */
137 YYSYMBOL_PERCENT_NAME_PREFIX
= 29, /* "%name-prefix" */
138 YYSYMBOL_PERCENT_NO_DEFAULT_PREC
= 30, /* "%no-default-prec" */
139 YYSYMBOL_PERCENT_NO_LINES
= 31, /* "%no-lines" */
140 YYSYMBOL_PERCENT_NONDETERMINISTIC_PARSER
= 32, /* "%nondeterministic-parser" */
141 YYSYMBOL_PERCENT_OUTPUT
= 33, /* "%output" */
142 YYSYMBOL_PERCENT_PURE_PARSER
= 34, /* "%pure-parser" */
143 YYSYMBOL_PERCENT_REQUIRE
= 35, /* "%require" */
144 YYSYMBOL_PERCENT_SKELETON
= 36, /* "%skeleton" */
145 YYSYMBOL_PERCENT_START
= 37, /* "%start" */
146 YYSYMBOL_PERCENT_TOKEN_TABLE
= 38, /* "%token-table" */
147 YYSYMBOL_PERCENT_VERBOSE
= 39, /* "%verbose" */
148 YYSYMBOL_PERCENT_YACC
= 40, /* "%yacc" */
149 YYSYMBOL_BRACED_CODE
= 41, /* "{...}" */
150 YYSYMBOL_BRACED_PREDICATE
= 42, /* "%?{...}" */
151 YYSYMBOL_BRACKETED_ID
= 43, /* "[identifier]" */
152 YYSYMBOL_CHAR_LITERAL
= 44, /* "character literal" */
153 YYSYMBOL_COLON
= 45, /* ":" */
154 YYSYMBOL_EPILOGUE
= 46, /* "epilogue" */
155 YYSYMBOL_EQUAL
= 47, /* "=" */
156 YYSYMBOL_ID
= 48, /* "identifier" */
157 YYSYMBOL_ID_COLON
= 49, /* "identifier:" */
158 YYSYMBOL_PERCENT_PERCENT
= 50, /* "%%" */
159 YYSYMBOL_PIPE
= 51, /* "|" */
160 YYSYMBOL_PROLOGUE
= 52, /* "%{...%}" */
161 YYSYMBOL_SEMICOLON
= 53, /* ";" */
162 YYSYMBOL_TAG
= 54, /* "<tag>" */
163 YYSYMBOL_TAG_ANY
= 55, /* "<*>" */
164 YYSYMBOL_TAG_NONE
= 56, /* "<>" */
165 YYSYMBOL_INT_LITERAL
= 57, /* "integer literal" */
166 YYSYMBOL_PERCENT_PARAM
= 58, /* "%param" */
167 YYSYMBOL_PERCENT_UNION
= 59, /* "%union" */
168 YYSYMBOL_PERCENT_EMPTY
= 60, /* "%empty" */
169 YYSYMBOL_YYACCEPT
= 61, /* $accept */
170 YYSYMBOL_input
= 62, /* input */
171 YYSYMBOL_prologue_declarations
= 63, /* prologue_declarations */
172 YYSYMBOL_prologue_declaration
= 64, /* prologue_declaration */
173 YYSYMBOL_65_1
= 65, /* $@1 */
174 YYSYMBOL_params
= 66, /* params */
175 YYSYMBOL_grammar_declaration
= 67, /* grammar_declaration */
176 YYSYMBOL_code_props_type
= 68, /* code_props_type */
177 YYSYMBOL_union_name
= 69, /* union_name */
178 YYSYMBOL_symbol_declaration
= 70, /* symbol_declaration */
179 YYSYMBOL_71_2
= 71, /* $@2 */
180 YYSYMBOL_72_3
= 72, /* $@3 */
181 YYSYMBOL_73_4
= 73, /* $@4 */
182 YYSYMBOL_precedence_declarator
= 74, /* precedence_declarator */
183 YYSYMBOL_75_string_opt
= 75, /* string.opt */
184 YYSYMBOL_76_tag_opt
= 76, /* tag.opt */
185 YYSYMBOL_generic_symlist
= 77, /* generic_symlist */
186 YYSYMBOL_generic_symlist_item
= 78, /* generic_symlist_item */
187 YYSYMBOL_tag
= 79, /* tag */
188 YYSYMBOL_nterm_decls
= 80, /* nterm_decls */
189 YYSYMBOL_token_decls
= 81, /* token_decls */
190 YYSYMBOL_82_token_decl_1
= 82, /* token_decl.1 */
191 YYSYMBOL_token_decl
= 83, /* token_decl */
192 YYSYMBOL_84_int_opt
= 84, /* int.opt */
193 YYSYMBOL_alias
= 85, /* alias */
194 YYSYMBOL_token_decls_for_prec
= 86, /* token_decls_for_prec */
195 YYSYMBOL_87_token_decl_for_prec_1
= 87, /* token_decl_for_prec.1 */
196 YYSYMBOL_token_decl_for_prec
= 88, /* token_decl_for_prec */
197 YYSYMBOL_symbol_decls
= 89, /* symbol_decls */
198 YYSYMBOL_90_symbols_1
= 90, /* symbols.1 */
199 YYSYMBOL_grammar
= 91, /* grammar */
200 YYSYMBOL_rules_or_grammar_declaration
= 92, /* rules_or_grammar_declaration */
201 YYSYMBOL_rules
= 93, /* rules */
202 YYSYMBOL_94_5
= 94, /* $@5 */
203 YYSYMBOL_95_rhses_1
= 95, /* rhses.1 */
204 YYSYMBOL_rhs
= 96, /* rhs */
205 YYSYMBOL_97_named_ref_opt
= 97, /* named_ref.opt */
206 YYSYMBOL_variable
= 98, /* variable */
207 YYSYMBOL_value
= 99, /* value */
208 YYSYMBOL_id
= 100, /* id */
209 YYSYMBOL_id_colon
= 101, /* id_colon */
210 YYSYMBOL_symbol
= 102, /* symbol */
211 YYSYMBOL_string_as_id
= 103, /* string_as_id */
212 YYSYMBOL_104_epilogue_opt
= 104 /* epilogue.opt */
214 typedef enum yysymbol_kind_t yysymbol_kind_t
;
218 /* Unqualified %code blocks. */
223 #include <quotearg.h>
224 #include <vasnprintf.h>
225 #include <xmemdup0.h>
227 #include "complain.h"
228 #include "conflicts.h"
232 #include "named-ref.h"
234 #include "scan-code.h"
235 #include "scan-gram.h"
236 #include "strversion.h"
238 /* Pretend to be at least that version, to check features published
239 in that version while developping it. */
240 static const char* api_version
= "3.8";
242 static int current_prec
= 0;
243 static location current_lhs_loc
;
244 static named_ref
*current_lhs_named_ref
;
245 static symbol
*current_lhs_symbol
;
246 static symbol_class current_class
= unknown_sym
;
248 /** Set the new current left-hand side symbol, possibly common
249 * to several right-hand side parts of rule.
251 static void current_lhs (symbol
*sym
, location loc
, named_ref
*ref
);
253 #define YYLLOC_DEFAULT(Current, Rhs, N) \
254 (Current) = lloc_default (Rhs, N)
255 static YYLTYPE
lloc_default (YYLTYPE
const *, int);
257 #define YY_LOCATION_PRINT(File, Loc) \
258 location_print (Loc, File)
260 /* Strip initial '{' and final '}' (must be first and last characters).
261 Return the result. */
262 static char *strip_braces (char *code
);
264 /* Convert CODE by calling code_props_plain_init if PLAIN, otherwise
265 code_props_symbol_action_init. Calls
266 gram_scanner_last_string_free to release the latest string from
267 the scanner (should be CODE). */
268 static char const *translate_code (char *code
, location loc
, bool plain
);
270 /* Convert CODE by calling code_props_plain_init after having
271 stripped the first and last characters (expected to be '{', and
272 '}'). Calls gram_scanner_last_string_free to release the latest
273 string from the scanner (should be CODE). */
274 static char const *translate_code_braceless (char *code
, location loc
);
276 /* Handle a %header directive. */
277 static void handle_header (char const *value
);
279 /* Handle a %error-verbose directive. */
280 static void handle_error_verbose (location
const *loc
, char const *directive
);
282 /* Handle a %file-prefix directive. */
283 static void handle_file_prefix (location
const *loc
,
284 location
const *dir_loc
,
285 char const *directive
, char const *value
);
287 /* Handle a %language directive. */
288 static void handle_language (location
const *loc
, char const *lang
);
290 /* Handle a %name-prefix directive. */
291 static void handle_name_prefix (location
const *loc
,
292 char const *directive
, char const *value
);
294 /* Handle a %pure-parser directive. */
295 static void handle_pure_parser (location
const *loc
, char const *directive
);
297 /* Handle a %require directive. */
298 static void handle_require (location
const *loc
, char const *version
);
300 /* Handle a %skeleton directive. */
301 static void handle_skeleton (location
const *loc
, char const *skel
);
303 /* Handle a %yacc directive. */
304 static void handle_yacc (location
const *loc
);
306 /* Implementation of yyerror. */
307 static void gram_error (location
const *, char const *);
309 /* A string that describes a char (e.g., 'a' -> "'a'"). */
310 static char const *char_name (char);
312 /* Add style to semantic values in traces. */
313 static void tron (FILE *yyo
);
314 static void troff (FILE *yyo
);
316 /* Interpret a quoted string (such as `"Hello, \"World\"\n\""`).
317 Manages the memory of the result. */
318 static char *unquote (const char *str
);
320 /* Discard the latest unquoted string. */
321 static void unquote_free (char *last_string
);
323 /** Add a lex-param and/or a parse-param.
325 * \param type where to push this formal argument.
326 * \param decl the formal argument. Destroyed.
327 * \param loc the location in the source.
329 static void add_param (param_type type
, char *decl
, location loc
);
330 static param_type current_param
= param_none
;
337 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
338 <limits.h> and (if available) <stdint.h> are included
339 so that the code can choose integer types of a good width. */
341 #ifndef __PTRDIFF_MAX__
342 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
343 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
344 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
349 /* Narrow types that promote to a signed type and that can represent a
350 signed or unsigned integer of at least N bits. In tables they can
351 save space and decrease cache pressure. Promoting to a signed type
352 helps avoid bugs in integer arithmetic. */
354 #ifdef __INT_LEAST8_MAX__
355 typedef __INT_LEAST8_TYPE__ yytype_int8
;
356 #elif defined YY_STDINT_H
357 typedef int_least8_t yytype_int8
;
359 typedef signed char yytype_int8
;
362 #ifdef __INT_LEAST16_MAX__
363 typedef __INT_LEAST16_TYPE__ yytype_int16
;
364 #elif defined YY_STDINT_H
365 typedef int_least16_t yytype_int16
;
367 typedef short yytype_int16
;
370 /* Work around bug in HP-UX 11.23, which defines these macros
371 incorrectly for preprocessor constants. This workaround can likely
372 be removed in 2023, as HPE has promised support for HP-UX 11.23
373 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
374 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
376 # undef UINT_LEAST8_MAX
377 # undef UINT_LEAST16_MAX
378 # define UINT_LEAST8_MAX 255
379 # define UINT_LEAST16_MAX 65535
382 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
383 typedef __UINT_LEAST8_TYPE__ yytype_uint8
;
384 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
385 && UINT_LEAST8_MAX <= INT_MAX)
386 typedef uint_least8_t yytype_uint8
;
387 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
388 typedef unsigned char yytype_uint8
;
390 typedef short yytype_uint8
;
393 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
394 typedef __UINT_LEAST16_TYPE__ yytype_uint16
;
395 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
396 && UINT_LEAST16_MAX <= INT_MAX)
397 typedef uint_least16_t yytype_uint16
;
398 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
399 typedef unsigned short yytype_uint16
;
401 typedef int yytype_uint16
;
405 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
406 # define YYPTRDIFF_T __PTRDIFF_TYPE__
407 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
408 # elif defined PTRDIFF_MAX
410 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
412 # define YYPTRDIFF_T ptrdiff_t
413 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
415 # define YYPTRDIFF_T long
416 # define YYPTRDIFF_MAXIMUM LONG_MAX
421 # ifdef __SIZE_TYPE__
422 # define YYSIZE_T __SIZE_TYPE__
423 # elif defined size_t
424 # define YYSIZE_T size_t
425 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
426 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
427 # define YYSIZE_T size_t
429 # define YYSIZE_T unsigned
433 #define YYSIZE_MAXIMUM \
434 YY_CAST (YYPTRDIFF_T, \
435 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
436 ? YYPTRDIFF_MAXIMUM \
437 : YY_CAST (YYSIZE_T, -1)))
439 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
442 /* Stored state numbers (used for stacks). */
443 typedef yytype_uint8 yy_state_t
;
445 /* State numbers in computations. */
446 typedef int yy_state_fast_t
;
449 # if defined YYENABLE_NLS && YYENABLE_NLS
451 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
452 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
456 # define YY_(Msgid) Msgid
461 # define N_(Msgid) Msgid
465 #ifndef YY_ATTRIBUTE_PURE
466 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
467 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
469 # define YY_ATTRIBUTE_PURE
473 #ifndef YY_ATTRIBUTE_UNUSED
474 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
475 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
477 # define YY_ATTRIBUTE_UNUSED
481 /* Suppress unused-variable warnings by "using" E. */
482 #if ! defined lint || defined __GNUC__
483 # define YY_USE(E) ((void) (E))
485 # define YY_USE(E) /* empty */
488 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
489 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
490 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
491 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
492 _Pragma ("GCC diagnostic push") \
493 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
495 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
496 _Pragma ("GCC diagnostic push") \
497 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
498 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
500 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
501 _Pragma ("GCC diagnostic pop")
503 # define YY_INITIAL_VALUE(Value) Value
505 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
506 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
507 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
509 #ifndef YY_INITIAL_VALUE
510 # define YY_INITIAL_VALUE(Value) /* Nothing. */
513 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
514 # define YY_IGNORE_USELESS_CAST_BEGIN \
515 _Pragma ("GCC diagnostic push") \
516 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
517 # define YY_IGNORE_USELESS_CAST_END \
518 _Pragma ("GCC diagnostic pop")
520 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
521 # define YY_IGNORE_USELESS_CAST_BEGIN
522 # define YY_IGNORE_USELESS_CAST_END
526 #define YY_ASSERT(E) ((void) (0 && (E)))
530 /* The parser invokes alloca or malloc; define the necessary symbols. */
532 # ifdef YYSTACK_ALLOC
533 /* Pacify GCC's 'empty if-body' warning. */
534 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
535 # ifndef YYSTACK_ALLOC_MAXIMUM
536 /* The OS might guarantee only one guard page at the bottom of the stack,
537 and a page size can be as small as 4096 bytes. So we cannot safely
538 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
539 to allow for a few compiler-allocated temporary stack slots. */
540 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
543 # define YYSTACK_ALLOC YYMALLOC
544 # define YYSTACK_FREE YYFREE
545 # ifndef YYSTACK_ALLOC_MAXIMUM
546 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
548 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
549 && ! ((defined YYMALLOC || defined malloc) \
550 && (defined YYFREE || defined free)))
551 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
552 # ifndef EXIT_SUCCESS
553 # define EXIT_SUCCESS 0
557 # define YYMALLOC malloc
558 # if ! defined malloc && ! defined EXIT_SUCCESS
559 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
564 # if ! defined free && ! defined EXIT_SUCCESS
565 void free (void *); /* INFRINGES ON USER NAME SPACE */
569 # define YYCOPY_NEEDED 1
572 #if (! defined yyoverflow \
573 && (! defined __cplusplus \
574 || (defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL \
575 && defined GRAM_STYPE_IS_TRIVIAL && GRAM_STYPE_IS_TRIVIAL)))
577 /* A type that is properly aligned for any stack member. */
580 yy_state_t yyss_alloc
;
585 /* The size of the maximum gap between one aligned stack and the next. */
586 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
588 /* The size of an array large to enough to hold all stacks, each with
590 # define YYSTACK_BYTES(N) \
591 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
592 + YYSIZEOF (YYLTYPE)) \
593 + 2 * YYSTACK_GAP_MAXIMUM)
595 # define YYCOPY_NEEDED 1
597 /* Relocate STACK from its old location to the new one. The
598 local variables YYSIZE and YYSTACKSIZE give the old and new number of
599 elements in the stack, and YYPTR gives the new location of the
600 stack. Advance YYPTR to a properly aligned location for the next
602 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
605 YYPTRDIFF_T yynewbytes; \
606 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
607 Stack = &yyptr->Stack_alloc; \
608 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
609 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
615 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
616 /* Copy COUNT objects from SRC to DST. The source and destination do
619 # if defined __GNUC__ && 1 < __GNUC__
620 # define YYCOPY(Dst, Src, Count) \
621 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
623 # define YYCOPY(Dst, Src, Count) \
627 for (yyi = 0; yyi < (Count); yyi++) \
628 (Dst)[yyi] = (Src)[yyi]; \
633 #endif /* !YYCOPY_NEEDED */
635 /* YYFINAL -- State number of the termination state. */
637 /* YYLAST -- Last index in YYTABLE. */
640 /* YYNTOKENS -- Number of terminals. */
642 /* YYNNTS -- Number of nonterminals. */
644 /* YYNRULES -- Number of rules. */
646 /* YYNSTATES -- Number of states. */
647 #define YYNSTATES 169
649 /* YYMAXUTOK -- Last valid token kind. */
650 #define YYMAXUTOK 315
653 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
654 as returned by yylex, with out-of-bounds checking. */
655 #define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)
658 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
659 static const yytype_int16 yyrline
[] =
661 0, 310, 310, 319, 320, 324, 325, 331, 335, 340,
662 341, 342, 343, 344, 345, 350, 355, 356, 357, 358,
663 359, 360, 360, 361, 362, 363, 364, 365, 366, 367,
664 368, 372, 373, 382, 383, 387, 398, 402, 406, 414,
665 424, 425, 435, 436, 442, 455, 455, 460, 460, 465,
666 465, 470, 480, 481, 482, 483, 488, 489, 493, 494,
667 499, 500, 504, 505, 509, 510, 511, 524, 533, 537,
668 541, 549, 550, 554, 567, 568, 573, 574, 575, 593,
669 597, 601, 609, 611, 616, 623, 633, 637, 641, 649,
670 655, 668, 669, 675, 676, 677, 684, 684, 692, 693,
671 694, 699, 702, 704, 706, 708, 710, 712, 714, 716,
672 718, 723, 724, 733, 757, 758, 759, 760, 772, 774,
673 798, 803, 804, 809, 817, 818
677 /** Accessing symbol of state STATE. */
678 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
681 /* The user-facing name of the symbol whose (internal) number is
682 YYSYMBOL. No bounds checking. */
683 static const char *yysymbol_name (yysymbol_kind_t yysymbol
) YY_ATTRIBUTE_UNUSED
;
686 yysymbol_name (yysymbol_kind_t yysymbol
)
688 static const char *const yy_sname
[] =
690 N_("end of file"), N_("error"), N_("invalid token"), N_("string"),
691 N_("translatable string"), "%token", "%nterm", "%type", "%destructor",
692 "%printer", "%left", "%right", "%nonassoc", "%precedence", "%prec",
693 "%dprec", "%merge", "%code", "%default-prec", "%define",
694 "%error-verbose", "%expect", "%expect-rr", "%file-prefix", "%<flag>",
695 "%glr-parser", "%header", "%initial-action", "%language", "%name-prefix",
696 "%no-default-prec", "%no-lines", "%nondeterministic-parser", "%output",
697 "%pure-parser", "%require", "%skeleton", "%start", "%token-table",
698 "%verbose", "%yacc", "{...}", "%?{...}", N_("[identifier]"),
699 N_("character literal"), ":", N_("epilogue"), "=", N_("identifier"),
700 N_("identifier:"), "%%", "|", "%{...%}", ";", N_("<tag>"), "<*>", "<>",
701 N_("integer literal"), "%param", "%union", "%empty", "$accept", "input",
702 "prologue_declarations", "prologue_declaration", "$@1", "params",
703 "grammar_declaration", "code_props_type", "union_name",
704 "symbol_declaration", "$@2", "$@3", "$@4", "precedence_declarator",
705 "string.opt", "tag.opt", "generic_symlist", "generic_symlist_item",
706 "tag", "nterm_decls", "token_decls", "token_decl.1", "token_decl",
707 "int.opt", "alias", "token_decls_for_prec", "token_decl_for_prec.1",
708 "token_decl_for_prec", "symbol_decls", "symbols.1", "grammar",
709 "rules_or_grammar_declaration", "rules", "$@5", "rhses.1", "rhs",
710 "named_ref.opt", "variable", "value", "id", "id_colon", "symbol",
711 "string_as_id", "epilogue.opt", YY_NULLPTR
713 /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
714 internationalizable. */
715 static yytype_int8 yytranslatable
[] =
717 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
718 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
719 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
720 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
721 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
722 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
725 return (yysymbol
< YYNTOKENS
&& yytranslatable
[yysymbol
]
726 ? _(yy_sname
[yysymbol
])
727 : yy_sname
[yysymbol
]);
731 #define YYPACT_NINF (-148)
733 #define yypact_value_is_default(Yyn) \
734 ((Yyn) == YYPACT_NINF)
736 #define YYTABLE_NINF (-125)
738 #define yytable_value_is_error(Yyn) \
741 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
743 static const yytype_int16 yypact
[] =
745 -148, 13, 113, -148, -27, -148, -148, -148, -148, -148,
746 -148, -148, -148, -148, -33, -148, -21, -148, -29, -26,
747 26, -148, -148, 27, -9, 30, 31, -148, -148, -148,
748 32, -148, 34, 36, 112, -148, -148, -148, 168, -148,
749 -148, -148, -3, -148, -148, 19, -148, 7, -148, -37,
750 -37, 164, -148, 33, -148, 2, -148, -148, -148, -148,
751 -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
752 112, -148, -148, -148, 9, -148, 20, 58, -148, -148,
753 37, 38, -148, 40, 155, 112, 35, 112, -148, 41,
754 -148, -28, 43, -28, -148, 41, -148, 43, 112, 46,
755 112, -148, -148, -148, -148, -148, -148, -148, -148, 44,
756 -148, -148, -148, -148, -148, 50, -148, -148, -148, -148,
757 155, -148, -148, -148, 112, 112, -148, -148, -148, -28,
758 -28, -148, 21, 112, 112, -148, 59, -148, -148, 112,
759 -28, -148, -148, -148, 112, -148, -30, 180, -148, -148,
760 112, 48, 49, 52, 53, -148, -148, -148, 65, 37,
761 180, -148, -148, -148, -148, -148, 37, -148, -148
764 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
765 Performed when YYTABLE does not specify something else to do. Zero
766 means the default is an error. */
767 static const yytype_int8 yydefact
[] =
769 3, 0, 0, 1, 0, 47, 45, 49, 40, 41,
770 52, 53, 54, 55, 0, 36, 0, 10, 0, 0,
771 0, 7, 14, 56, 0, 0, 0, 37, 18, 19,
772 0, 23, 0, 0, 0, 26, 27, 28, 0, 6,
773 30, 21, 42, 4, 5, 0, 33, 0, 29, 0,
774 0, 0, 38, 0, 113, 114, 11, 12, 13, 57,
775 9, 15, 16, 17, 20, 24, 25, 123, 119, 118,
776 34, 121, 89, 122, 0, 120, 0, 0, 91, 93,
777 111, 0, 43, 0, 0, 0, 51, 79, 82, 74,
778 85, 0, 48, 68, 71, 74, 46, 67, 0, 50,
779 86, 39, 116, 117, 115, 8, 90, 95, 94, 0,
780 92, 2, 112, 96, 32, 22, 44, 64, 65, 66,
781 35, 60, 63, 62, 80, 0, 83, 75, 84, 69,
782 0, 72, 76, 87, 0, 125, 0, 31, 61, 81,
783 70, 78, 73, 77, 88, 101, 97, 98, 101, 100,
784 0, 0, 0, 0, 0, 104, 59, 105, 0, 111,
785 99, 106, 107, 108, 109, 110, 111, 102, 103
788 /* YYPGOTO[NTERM-NUM]. */
789 static const yytype_int16 yypgoto
[] =
791 -148, -148, -148, -148, -148, -148, 109, -148, -148, -148,
792 -148, -148, -148, -148, -148, -148, -148, -7, -148, -148,
793 66, -73, -87, 60, -148, -148, -71, -83, -148, -50,
794 -148, 51, -148, -148, -148, -19, -147, -148, -148, -47,
798 /* YYDEFGOTO[NTERM-NUM]. */
799 static const yytype_uint8 yydefgoto
[] =
801 0, 1, 2, 43, 81, 115, 76, 45, 83, 46,
802 50, 49, 51, 47, 60, 158, 120, 121, 122, 96,
803 92, 93, 94, 128, 142, 86, 87, 88, 99, 70,
804 77, 78, 79, 136, 146, 147, 113, 55, 105, 71,
808 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
809 positive, shift that token. If negative, reduce the rule whose
810 number is the opposite. If YYTABLE_NINF, syntax error. */
811 static const yytype_int16 yytable
[] =
813 89, 100, 95, 95, 126, 102, 131, 68, 52, 90,
814 67, 69, 167, 3, 124, 53, 68, 91, 129, 168,
815 69, 148, 106, 149, 67, 141, 48, 54, 56, 58,
816 59, 57, 61, 62, 63, 64, 123, 65, 89, 66,
817 89, 126, 131, 103, 95, 82, 95, 90, 133, 90,
818 104, 68, 106, 131, 139, 69, 126, 140, -124, 74,
819 84, 85, 107, 5, 6, 7, 8, 9, 10, 11,
820 12, 13, 123, 108, 101, 14, 15, 89, 89, 114,
821 112, 116, 95, 95, 144, 106, 90, 90, 27, 125,
822 135, 137, 89, 95, 143, 34, 106, 130, 127, 159,
823 134, 90, 161, 163, 145, 162, 166, 75, 109, 164,
824 165, 44, 159, 138, 4, 67, 97, 42, 5, 6,
825 7, 8, 9, 10, 11, 12, 13, 0, 110, 160,
826 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
827 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
828 34, 35, 36, 37, 0, 132, 68, 0, 67, 0,
829 69, 0, 0, 38, 0, 39, 40, 67, 0, 74,
830 0, 41, 42, 5, 6, 7, 8, 9, 10, 11,
831 12, 13, 0, 67, 0, 14, 15, 0, 0, 0,
832 0, 0, 0, 0, 150, 151, 152, 0, 27, 68,
833 0, 153, 154, 69, 0, 34, 0, 0, 68, 117,
834 118, 119, 69, 0, 0, 0, 0, 75, 98, 0,
835 0, -58, 155, 0, 68, 0, 0, 42, 69, 0,
836 0, 0, 0, 0, 156, 0, 0, 0, 0, 0,
840 static const yytype_int16 yycheck
[] =
842 47, 51, 49, 50, 87, 3, 93, 44, 41, 47,
843 3, 48, 159, 0, 85, 48, 44, 54, 91, 166,
844 48, 51, 70, 53, 3, 4, 53, 48, 57, 3,
845 3, 57, 41, 3, 3, 3, 84, 3, 85, 3,
846 87, 124, 129, 41, 91, 48, 93, 85, 98, 87,
847 48, 44, 100, 140, 125, 48, 139, 130, 0, 1,
848 41, 54, 53, 5, 6, 7, 8, 9, 10, 11,
849 12, 13, 120, 53, 41, 17, 18, 124, 125, 41,
850 43, 41, 129, 130, 134, 133, 124, 125, 30, 54,
851 46, 41, 139, 140, 132, 37, 144, 54, 57, 147,
852 54, 139, 150, 54, 45, 57, 41, 49, 50, 57,
853 57, 2, 160, 120, 1, 3, 50, 59, 5, 6,
854 7, 8, 9, 10, 11, 12, 13, -1, 77, 148,
855 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
856 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
857 37, 38, 39, 40, -1, 95, 44, -1, 3, -1,
858 48, -1, -1, 50, -1, 52, 53, 3, -1, 1,
859 -1, 58, 59, 5, 6, 7, 8, 9, 10, 11,
860 12, 13, -1, 3, -1, 17, 18, -1, -1, -1,
861 -1, -1, -1, -1, 14, 15, 16, -1, 30, 44,
862 -1, 21, 22, 48, -1, 37, -1, -1, 44, 54,
863 55, 56, 48, -1, -1, -1, -1, 49, 54, -1,
864 -1, 41, 42, -1, 44, -1, -1, 59, 48, -1,
865 -1, -1, -1, -1, 54, -1, -1, -1, -1, -1,
869 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
871 static const yytype_int8 yystos
[] =
873 0, 62, 63, 0, 1, 5, 6, 7, 8, 9,
874 10, 11, 12, 13, 17, 18, 19, 20, 21, 22,
875 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
876 33, 34, 35, 36, 37, 38, 39, 40, 50, 52,
877 53, 58, 59, 64, 67, 68, 70, 74, 53, 72,
878 71, 73, 41, 48, 48, 98, 57, 57, 3, 3,
879 75, 41, 3, 3, 3, 3, 3, 3, 44, 48,
880 90, 100, 102, 103, 1, 49, 67, 91, 92, 93,
881 101, 65, 48, 69, 41, 54, 86, 87, 88, 100,
882 103, 54, 81, 82, 83, 100, 80, 81, 54, 89,
883 90, 41, 3, 41, 48, 99, 102, 53, 53, 50,
884 92, 104, 43, 97, 41, 66, 41, 54, 55, 56,
885 77, 78, 79, 102, 87, 54, 88, 57, 84, 82,
886 54, 83, 84, 90, 54, 46, 94, 41, 78, 87,
887 82, 4, 85, 103, 90, 45, 95, 96, 51, 53,
888 14, 15, 16, 21, 22, 42, 54, 60, 76, 102,
889 96, 102, 57, 54, 57, 57, 41, 97, 97
892 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
893 static const yytype_int8 yyr1
[] =
895 0, 61, 62, 63, 63, 64, 64, 64, 64, 64,
896 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
897 64, 65, 64, 64, 64, 64, 64, 64, 64, 64,
898 64, 66, 66, 67, 67, 67, 67, 67, 67, 67,
899 68, 68, 69, 69, 67, 71, 70, 72, 70, 73,
900 70, 70, 74, 74, 74, 74, 75, 75, 76, 76,
901 77, 77, 78, 78, 79, 79, 79, 80, 81, 81,
902 81, 82, 82, 83, 84, 84, 85, 85, 85, 86,
903 86, 86, 87, 87, 88, 88, 89, 89, 89, 90,
904 90, 91, 91, 92, 92, 92, 94, 93, 95, 95,
905 95, 96, 96, 96, 96, 96, 96, 96, 96, 96,
906 96, 97, 97, 98, 99, 99, 99, 99, 100, 100,
907 101, 102, 102, 103, 104, 104
910 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
911 static const yytype_int8 yyr2
[] =
913 0, 2, 4, 0, 2, 1, 1, 1, 3, 2,
914 1, 2, 2, 2, 1, 2, 2, 2, 1, 1,
915 2, 0, 3, 1, 2, 2, 1, 1, 1, 2,
916 1, 2, 1, 1, 2, 3, 1, 1, 2, 3,
917 1, 1, 0, 1, 3, 0, 3, 0, 3, 0,
918 3, 2, 1, 1, 1, 1, 0, 1, 0, 1,
919 1, 2, 1, 1, 1, 1, 1, 1, 1, 2,
920 3, 1, 2, 3, 0, 1, 0, 1, 1, 1,
921 2, 3, 1, 2, 2, 1, 1, 2, 3, 1,
922 2, 1, 2, 1, 2, 2, 0, 5, 1, 3,
923 2, 0, 3, 4, 2, 2, 3, 3, 3, 3,
924 3, 0, 1, 1, 0, 1, 1, 1, 1, 1,
929 enum { YYENOMEM
= -2 };
931 #define yyerrok (yyerrstatus = 0)
932 #define yyclearin (yychar = GRAM_EMPTY)
934 #define YYACCEPT goto yyacceptlab
935 #define YYABORT goto yyabortlab
936 #define YYERROR goto yyerrorlab
937 #define YYNOMEM goto yyexhaustedlab
940 #define YYRECOVERING() (!!yyerrstatus)
942 #define YYBACKUP(Token, Value) \
944 if (yychar == GRAM_EMPTY) \
948 YYPOPSTACK (yylen); \
950 YY_LAC_DISCARD ("YYBACKUP"); \
955 yyerror (&yylloc, YY_("syntax error: cannot back up")); \
960 /* Backward compatibility with an undocumented macro.
961 Use GRAM_error or GRAM_UNDEF. */
962 #define YYERRCODE GRAM_UNDEF
964 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
965 If N is 0, then set CURRENT to the empty location which ends
966 the previous symbol: RHS[0] (always defined). */
968 #ifndef YYLLOC_DEFAULT
969 # define YYLLOC_DEFAULT(Current, Rhs, N) \
973 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
974 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
975 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
976 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
980 (Current).first_line = (Current).last_line = \
981 YYRHSLOC (Rhs, 0).last_line; \
982 (Current).first_column = (Current).last_column = \
983 YYRHSLOC (Rhs, 0).last_column; \
988 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
991 /* Enable debugging if requested. */
995 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
996 # define YYFPRINTF fprintf
999 # define YYDPRINTF(Args) \
1006 /* YYLOCATION_PRINT -- Print the location on the stream.
1007 This macro was not mandated originally: define only if we know
1008 we won't break user code: when these are the locations we know. */
1010 # ifndef YYLOCATION_PRINT
1012 # if defined YY_LOCATION_PRINT
1014 /* Temporary convenience wrapper in case some people defined the
1015 undocumented and private YY_LOCATION_PRINT macros. */
1016 # define YYLOCATION_PRINT(File, Loc) YY_LOCATION_PRINT(File, *(Loc))
1018 # elif defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
1020 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
1024 yy_location_print_ (FILE *yyo
, YYLTYPE
const * const yylocp
)
1027 int end_col
= 0 != yylocp
->last_column
? yylocp
->last_column
- 1 : 0;
1028 if (0 <= yylocp
->first_line
)
1030 res
+= YYFPRINTF (yyo
, "%d", yylocp
->first_line
);
1031 if (0 <= yylocp
->first_column
)
1032 res
+= YYFPRINTF (yyo
, ".%d", yylocp
->first_column
);
1034 if (0 <= yylocp
->last_line
)
1036 if (yylocp
->first_line
< yylocp
->last_line
)
1038 res
+= YYFPRINTF (yyo
, "-%d", yylocp
->last_line
);
1040 res
+= YYFPRINTF (yyo
, ".%d", end_col
);
1042 else if (0 <= end_col
&& yylocp
->first_column
< end_col
)
1043 res
+= YYFPRINTF (yyo
, "-%d", end_col
);
1048 # define YYLOCATION_PRINT yy_location_print_
1050 /* Temporary convenience wrapper in case some people defined the
1051 undocumented and private YY_LOCATION_PRINT macros. */
1052 # define YY_LOCATION_PRINT(File, Loc) YYLOCATION_PRINT(File, &(Loc))
1056 # define YYLOCATION_PRINT(File, Loc) ((void) 0)
1057 /* Temporary convenience wrapper in case some people defined the
1058 undocumented and private YY_LOCATION_PRINT macros. */
1059 # define YY_LOCATION_PRINT YYLOCATION_PRINT
1062 # endif /* !defined YYLOCATION_PRINT */
1065 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
1069 YYFPRINTF (stderr, "%s ", Title); \
1070 yy_symbol_print (stderr, \
1071 Kind, Value, Location); \
1072 YYFPRINTF (stderr, "\n"); \
1077 /*-----------------------------------.
1078 | Print this symbol's value on YYO. |
1079 `-----------------------------------*/
1082 yy_symbol_value_print (FILE *yyo
,
1083 yysymbol_kind_t yykind
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
)
1085 FILE *yyoutput
= yyo
;
1087 YY_USE (yylocationp
);
1090 /* "%code pre-printer" blocks. */
1093 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1096 case YYSYMBOL_STRING
: /* "string" */
1097 { fputs (((*yyvaluep
).STRING
), yyo
); }
1100 case YYSYMBOL_TSTRING
: /* "translatable string" */
1101 { fputs (((*yyvaluep
).TSTRING
), yyo
); }
1104 case YYSYMBOL_PERCENT_ERROR_VERBOSE
: /* "%error-verbose" */
1105 { fputs (((*yyvaluep
).PERCENT_ERROR_VERBOSE
), yyo
); }
1108 case YYSYMBOL_PERCENT_FILE_PREFIX
: /* "%file-prefix" */
1109 { fputs (((*yyvaluep
).PERCENT_FILE_PREFIX
), yyo
); }
1112 case YYSYMBOL_PERCENT_FLAG
: /* "%<flag>" */
1113 { fprintf (yyo
, "%%%s", ((*yyvaluep
).PERCENT_FLAG
)); }
1116 case YYSYMBOL_PERCENT_NAME_PREFIX
: /* "%name-prefix" */
1117 { fputs (((*yyvaluep
).PERCENT_NAME_PREFIX
), yyo
); }
1120 case YYSYMBOL_PERCENT_PURE_PARSER
: /* "%pure-parser" */
1121 { fputs (((*yyvaluep
).PERCENT_PURE_PARSER
), yyo
); }
1124 case YYSYMBOL_BRACED_CODE
: /* "{...}" */
1125 { fputs (((*yyvaluep
).BRACED_CODE
), yyo
); }
1128 case YYSYMBOL_BRACED_PREDICATE
: /* "%?{...}" */
1129 { fputs (((*yyvaluep
).BRACED_PREDICATE
), yyo
); }
1132 case YYSYMBOL_BRACKETED_ID
: /* "[identifier]" */
1133 { fprintf (yyo
, "[%s]", ((*yyvaluep
).BRACKETED_ID
)); }
1136 case YYSYMBOL_CHAR_LITERAL
: /* "character literal" */
1137 { fputs (char_name (((*yyvaluep
).CHAR_LITERAL
)), yyo
); }
1140 case YYSYMBOL_EPILOGUE
: /* "epilogue" */
1141 { fputs (((*yyvaluep
).EPILOGUE
), yyo
); }
1144 case YYSYMBOL_ID
: /* "identifier" */
1145 { fputs (((*yyvaluep
).ID
), yyo
); }
1148 case YYSYMBOL_ID_COLON
: /* "identifier:" */
1149 { fprintf (yyo
, "%s:", ((*yyvaluep
).ID_COLON
)); }
1152 case YYSYMBOL_PROLOGUE
: /* "%{...%}" */
1153 { fputs (((*yyvaluep
).PROLOGUE
), yyo
); }
1156 case YYSYMBOL_TAG
: /* "<tag>" */
1157 { fprintf (yyo
, "<%s>", ((*yyvaluep
).TAG
)); }
1160 case YYSYMBOL_INT_LITERAL
: /* "integer literal" */
1161 { fprintf (yyo
, "%d", ((*yyvaluep
).INT_LITERAL
)); }
1164 case YYSYMBOL_PERCENT_PARAM
: /* "%param" */
1166 switch (((*yyvaluep
).PERCENT_PARAM
))
1168 #define CASE(In, Out) \
1169 case param_ ## In: fputs ("%" #Out, yyo); break
1170 CASE (lex
, lex
-param
);
1171 CASE (parse
, parse
-param
);
1174 case param_none
: aver (false); break;
1179 case YYSYMBOL_code_props_type
: /* code_props_type */
1180 { fprintf (yyo
, "%s", code_props_type_string (((*yyvaluep
).code_props_type
))); }
1183 case YYSYMBOL_75_string_opt
: /* string.opt */
1184 { fputs (((*yyvaluep
).yykind_75
), yyo
); }
1187 case YYSYMBOL_76_tag_opt
: /* tag.opt */
1188 { fputs (((*yyvaluep
).yykind_76
), yyo
); }
1191 case YYSYMBOL_generic_symlist
: /* generic_symlist */
1192 { symbol_list_syms_print (((*yyvaluep
).generic_symlist
), yyo
); }
1195 case YYSYMBOL_generic_symlist_item
: /* generic_symlist_item */
1196 { symbol_list_syms_print (((*yyvaluep
).generic_symlist_item
), yyo
); }
1199 case YYSYMBOL_tag
: /* tag */
1200 { fprintf (yyo
, "<%s>", ((*yyvaluep
).tag
)); }
1203 case YYSYMBOL_nterm_decls
: /* nterm_decls */
1204 { symbol_list_syms_print (((*yyvaluep
).nterm_decls
), yyo
); }
1207 case YYSYMBOL_token_decls
: /* token_decls */
1208 { symbol_list_syms_print (((*yyvaluep
).token_decls
), yyo
); }
1211 case YYSYMBOL_82_token_decl_1
: /* token_decl.1 */
1212 { symbol_list_syms_print (((*yyvaluep
).yykind_82
), yyo
); }
1215 case YYSYMBOL_token_decl
: /* token_decl */
1216 { fprintf (yyo
, "%s", ((*yyvaluep
).token_decl
) ? ((*yyvaluep
).token_decl
)->tag
: "<NULL>"); }
1219 case YYSYMBOL_84_int_opt
: /* int.opt */
1220 { fprintf (yyo
, "%d", ((*yyvaluep
).yykind_84
)); }
1223 case YYSYMBOL_alias
: /* alias */
1224 { fprintf (yyo
, "%s", ((*yyvaluep
).alias
) ? ((*yyvaluep
).alias
)->tag
: "<NULL>"); }
1227 case YYSYMBOL_token_decls_for_prec
: /* token_decls_for_prec */
1228 { symbol_list_syms_print (((*yyvaluep
).token_decls_for_prec
), yyo
); }
1231 case YYSYMBOL_87_token_decl_for_prec_1
: /* token_decl_for_prec.1 */
1232 { symbol_list_syms_print (((*yyvaluep
).yykind_87
), yyo
); }
1235 case YYSYMBOL_token_decl_for_prec
: /* token_decl_for_prec */
1236 { fprintf (yyo
, "%s", ((*yyvaluep
).token_decl_for_prec
) ? ((*yyvaluep
).token_decl_for_prec
)->tag
: "<NULL>"); }
1239 case YYSYMBOL_symbol_decls
: /* symbol_decls */
1240 { symbol_list_syms_print (((*yyvaluep
).symbol_decls
), yyo
); }
1243 case YYSYMBOL_90_symbols_1
: /* symbols.1 */
1244 { symbol_list_syms_print (((*yyvaluep
).yykind_90
), yyo
); }
1247 case YYSYMBOL_variable
: /* variable */
1248 { fputs (((*yyvaluep
).variable
), yyo
); }
1251 case YYSYMBOL_value
: /* value */
1253 switch (((*yyvaluep
).value
).kind
)
1255 case muscle_code
: fprintf (yyo
, "{%s}", ((*yyvaluep
).value
).chars
); break;
1256 case muscle_keyword
: fprintf (yyo
, "%s", ((*yyvaluep
).value
).chars
); break;
1257 case muscle_string
: fprintf (yyo
, "\"%s\"", ((*yyvaluep
).value
).chars
); break;
1262 case YYSYMBOL_id
: /* id */
1263 { fprintf (yyo
, "%s", ((*yyvaluep
).id
) ? ((*yyvaluep
).id
)->tag
: "<NULL>"); }
1266 case YYSYMBOL_id_colon
: /* id_colon */
1267 { fprintf (yyo
, "%s:", ((*yyvaluep
).id_colon
)->tag
); }
1270 case YYSYMBOL_symbol
: /* symbol */
1271 { fprintf (yyo
, "%s", ((*yyvaluep
).symbol
) ? ((*yyvaluep
).symbol
)->tag
: "<NULL>"); }
1274 case YYSYMBOL_string_as_id
: /* string_as_id */
1275 { fprintf (yyo
, "%s", ((*yyvaluep
).string_as_id
) ? ((*yyvaluep
).string_as_id
)->tag
: "<NULL>"); }
1281 YY_IGNORE_MAYBE_UNINITIALIZED_END
1282 /* "%code post-printer" blocks. */
1288 /*---------------------------.
1289 | Print this symbol on YYO. |
1290 `---------------------------*/
1293 yy_symbol_print (FILE *yyo
,
1294 yysymbol_kind_t yykind
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
)
1296 YYFPRINTF (yyo
, "%s %s (",
1297 yykind
< YYNTOKENS
? "token" : "nterm", yysymbol_name (yykind
));
1299 YYLOCATION_PRINT (yyo
, yylocationp
);
1300 YYFPRINTF (yyo
, ": ");
1301 yy_symbol_value_print (yyo
, yykind
, yyvaluep
, yylocationp
);
1302 YYFPRINTF (yyo
, ")");
1305 /*------------------------------------------------------------------.
1306 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1308 `------------------------------------------------------------------*/
1311 yy_stack_print (yy_state_t
*yybottom
, yy_state_t
*yytop
)
1313 YYFPRINTF (stderr
, "Stack now");
1314 for (; yybottom
<= yytop
; yybottom
++)
1316 int yybot
= *yybottom
;
1317 YYFPRINTF (stderr
, " %d", yybot
);
1319 YYFPRINTF (stderr
, "\n");
1322 # define YY_STACK_PRINT(Bottom, Top) \
1325 yy_stack_print ((Bottom), (Top)); \
1329 /*------------------------------------------------.
1330 | Report that the YYRULE is going to be reduced. |
1331 `------------------------------------------------*/
1334 yy_reduce_print (yy_state_t
*yyssp
, YYSTYPE
*yyvsp
, YYLTYPE
*yylsp
,
1337 int yylno
= yyrline
[yyrule
];
1338 int yynrhs
= yyr2
[yyrule
];
1340 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %d):\n",
1342 /* The symbols being reduced. */
1343 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1345 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1346 yy_symbol_print (stderr
,
1347 YY_ACCESSING_SYMBOL (+yyssp
[yyi
+ 1 - yynrhs
]),
1348 &yyvsp
[(yyi
+ 1) - (yynrhs
)],
1349 &(yylsp
[(yyi
+ 1) - (yynrhs
)]));
1350 YYFPRINTF (stderr
, "\n");
1354 # define YY_REDUCE_PRINT(Rule) \
1357 yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
1360 /* Nonzero means print parse trace. It is left uninitialized so that
1361 multiple parsers can coexist. */
1363 #else /* !GRAM_DEBUG */
1364 # define YYDPRINTF(Args) ((void) 0)
1365 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1366 # define YY_STACK_PRINT(Bottom, Top)
1367 # define YY_REDUCE_PRINT(Rule)
1368 #endif /* !GRAM_DEBUG */
1371 /* YYINITDEPTH -- initial size of the parser's stacks. */
1373 # define YYINITDEPTH 200
1376 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1377 if the built-in stack extension method is used).
1379 Do not make this value too large; the results are undefined if
1380 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1381 evaluated with infinite-precision integer arithmetic. */
1384 # define YYMAXDEPTH 10000
1388 /* Given a state stack such that *YYBOTTOM is its bottom, such that
1389 *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
1390 stack, and such that *YYCAPACITY is the maximum number of elements it
1391 can hold without a reallocation, make sure there is enough room to
1392 store YYADD more elements. If not, allocate a new stack using
1393 YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
1394 *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
1395 location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
1396 using YYSTACK_FREE. Return 0 if successful or if no reallocation is
1397 required. Return YYENOMEM if memory is exhausted. */
1399 yy_lac_stack_realloc (YYPTRDIFF_T
*yycapacity
, YYPTRDIFF_T yyadd
,
1401 char const *yydebug_prefix
,
1402 char const *yydebug_suffix
,
1404 yy_state_t
**yybottom
,
1405 yy_state_t
*yybottom_no_free
,
1406 yy_state_t
**yytop
, yy_state_t
*yytop_empty
)
1408 YYPTRDIFF_T yysize_old
=
1409 *yytop
== yytop_empty
? 0 : *yytop
- *yybottom
+ 1;
1410 YYPTRDIFF_T yysize_new
= yysize_old
+ yyadd
;
1411 if (*yycapacity
< yysize_new
)
1413 YYPTRDIFF_T yyalloc
= 2 * yysize_new
;
1414 yy_state_t
*yybottom_new
;
1415 /* Use YYMAXDEPTH for maximum stack size given that the stack
1416 should never need to grow larger than the main state stack
1417 needs to grow without LAC. */
1418 if (YYMAXDEPTH
< yysize_new
)
1420 YYDPRINTF ((stderr
, "%smax size exceeded%s", yydebug_prefix
,
1424 if (YYMAXDEPTH
< yyalloc
)
1425 yyalloc
= YYMAXDEPTH
;
1427 YY_CAST (yy_state_t
*,
1428 YYSTACK_ALLOC (YY_CAST (YYSIZE_T
,
1429 yyalloc
* YYSIZEOF (*yybottom_new
))));
1432 YYDPRINTF ((stderr
, "%srealloc failed%s", yydebug_prefix
,
1436 if (*yytop
!= yytop_empty
)
1438 YYCOPY (yybottom_new
, *yybottom
, yysize_old
);
1439 *yytop
= yybottom_new
+ (yysize_old
- 1);
1441 if (*yybottom
!= yybottom_no_free
)
1442 YYSTACK_FREE (*yybottom
);
1443 *yybottom
= yybottom_new
;
1444 *yycapacity
= yyalloc
;
1449 /* Establish the initial context for the current lookahead if no initial
1450 context is currently established.
1452 We define a context as a snapshot of the parser stacks. We define
1453 the initial context for a lookahead as the context in which the
1454 parser initially examines that lookahead in order to select a
1455 syntactic action. Thus, if the lookahead eventually proves
1456 syntactically unacceptable (possibly in a later context reached via a
1457 series of reductions), the initial context can be used to determine
1458 the exact set of tokens that would be syntactically acceptable in the
1459 lookahead's place. Moreover, it is the context after which any
1460 further semantic actions would be erroneous because they would be
1461 determined by a syntactically unacceptable token.
1463 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
1464 performed in an inconsistent state (which, for the purposes of LAC,
1465 includes consistent states that don't know they're consistent because
1466 their default reductions have been disabled). Iff there is a
1467 lookahead token, it should also be invoked before reporting a syntax
1468 error. This latter case is for the sake of the debugging output.
1470 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
1471 follows. If no initial context is currently established for the
1472 current lookahead, then check if that lookahead can eventually be
1473 shifted if syntactic actions continue from the current context.
1474 Report a syntax error if it cannot. */
1475 #define YY_LAC_ESTABLISH \
1477 if (!yy_lac_established) \
1479 YYDPRINTF ((stderr, \
1480 "LAC: initial context established for %s\n", \
1481 yysymbol_name (yytoken))); \
1482 yy_lac_established = 1; \
1483 switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
1493 /* Discard any previous initial lookahead context because of Event,
1494 which may be a lookahead change or an invalidation of the currently
1495 established initial context for the current lookahead.
1497 The most common example of a lookahead change is a shift. An example
1498 of both cases is syntax error recovery. That is, a syntax error
1499 occurs when the lookahead is syntactically erroneous for the
1500 currently established initial context, so error recovery manipulates
1501 the parser stacks to try to find a new initial context in which the
1502 current lookahead is syntactically acceptable. If it fails to find
1503 such a context, it discards the lookahead. */
1505 # define YY_LAC_DISCARD(Event) \
1507 if (yy_lac_established) \
1509 YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
1511 yy_lac_established = 0; \
1515 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
1518 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
1519 eventually (after perhaps some reductions) be shifted, return 1 if
1520 not, or return YYENOMEM if memory is exhausted. As preconditions and
1521 postconditions: *YYES_CAPACITY is the allocated size of the array to
1522 which *YYES points, and either *YYES = YYESA or *YYES points to an
1523 array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
1524 contents of either array, alter *YYES and *YYES_CAPACITY, and free
1525 any old *YYES other than YYESA. */
1527 yy_lac (yy_state_t
*yyesa
, yy_state_t
**yyes
,
1528 YYPTRDIFF_T
*yyes_capacity
, yy_state_t
*yyssp
, yysymbol_kind_t yytoken
)
1530 yy_state_t
*yyes_prev
= yyssp
;
1531 yy_state_t
*yyesp
= yyes_prev
;
1532 /* Reduce until we encounter a shift and thereby accept the token. */
1533 YYDPRINTF ((stderr
, "LAC: checking lookahead %s:", yysymbol_name (yytoken
)));
1534 if (yytoken
== YYSYMBOL_YYUNDEF
)
1536 YYDPRINTF ((stderr
, " Always Err\n"));
1541 int yyrule
= yypact
[+*yyesp
];
1542 if (yypact_value_is_default (yyrule
)
1543 || (yyrule
+= yytoken
) < 0 || YYLAST
< yyrule
1544 || yycheck
[yyrule
] != yytoken
)
1546 /* Use the default action. */
1547 yyrule
= yydefact
[+*yyesp
];
1550 YYDPRINTF ((stderr
, " Err\n"));
1556 /* Use the action from yytable. */
1557 yyrule
= yytable
[yyrule
];
1558 if (yytable_value_is_error (yyrule
))
1560 YYDPRINTF ((stderr
, " Err\n"));
1565 YYDPRINTF ((stderr
, " S%d\n", yyrule
));
1570 /* By now we know we have to simulate a reduce. */
1571 YYDPRINTF ((stderr
, " R%d", yyrule
- 1));
1573 /* Pop the corresponding number of values from the stack. */
1574 YYPTRDIFF_T yylen
= yyr2
[yyrule
];
1575 /* First pop from the LAC stack as many tokens as possible. */
1576 if (yyesp
!= yyes_prev
)
1578 YYPTRDIFF_T yysize
= yyesp
- *yyes
+ 1;
1590 /* Only afterwards look at the main stack. */
1592 yyesp
= yyes_prev
-= yylen
;
1594 /* Push the resulting state of the reduction. */
1596 yy_state_fast_t yystate
;
1598 const int yylhs
= yyr1
[yyrule
] - YYNTOKENS
;
1599 const int yyi
= yypgoto
[yylhs
] + *yyesp
;
1600 yystate
= (0 <= yyi
&& yyi
<= YYLAST
&& yycheck
[yyi
] == *yyesp
1602 : yydefgoto
[yylhs
]);
1604 if (yyesp
== yyes_prev
)
1607 YY_IGNORE_USELESS_CAST_BEGIN
1608 *yyesp
= YY_CAST (yy_state_t
, yystate
);
1609 YY_IGNORE_USELESS_CAST_END
1613 if (yy_lac_stack_realloc (yyes_capacity
, 1,
1617 yyes
, yyesa
, &yyesp
, yyes_prev
))
1619 YYDPRINTF ((stderr
, "\n"));
1622 YY_IGNORE_USELESS_CAST_BEGIN
1623 *++yyesp
= YY_CAST (yy_state_t
, yystate
);
1624 YY_IGNORE_USELESS_CAST_END
1626 YYDPRINTF ((stderr
, " G%d", yystate
));
1631 /* Context of a parse error. */
1637 YYPTRDIFF_T
*yyes_capacity
;
1638 yysymbol_kind_t yytoken
;
1642 /* Put in YYARG at most YYARGN of the expected tokens given the
1643 current YYCTX, and return the number of tokens stored in YYARG. If
1644 YYARG is null, return the number of expected tokens (guaranteed to
1645 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1646 Return 0 if there are more than YYARGN expected tokens, yet fill
1647 YYARG up to YYARGN. */
1649 yypcontext_expected_tokens (const yypcontext_t
*yyctx
,
1650 yysymbol_kind_t yyarg
[], int yyargn
)
1652 /* Actual size of YYARG. */
1656 for (yyx
= 0; yyx
< YYNTOKENS
; ++yyx
)
1658 yysymbol_kind_t yysym
= YY_CAST (yysymbol_kind_t
, yyx
);
1659 if (yysym
!= YYSYMBOL_YYerror
&& yysym
!= YYSYMBOL_YYUNDEF
)
1660 switch (yy_lac (yyctx
->yyesa
, yyctx
->yyes
, yyctx
->yyes_capacity
, yyctx
->yyssp
, yysym
))
1669 else if (yycount
== yyargn
)
1672 yyarg
[yycount
++] = yysym
;
1675 if (yyarg
&& yycount
== 0 && 0 < yyargn
)
1676 yyarg
[0] = YYSYMBOL_YYEMPTY
;
1683 /* The kind of the lookahead of this context. */
1684 static yysymbol_kind_t
1685 yypcontext_token (const yypcontext_t
*yyctx
) YY_ATTRIBUTE_UNUSED
;
1687 static yysymbol_kind_t
1688 yypcontext_token (const yypcontext_t
*yyctx
)
1690 return yyctx
->yytoken
;
1693 /* The location of the lookahead of this context. */
1695 yypcontext_location (const yypcontext_t
*yyctx
) YY_ATTRIBUTE_UNUSED
;
1698 yypcontext_location (const yypcontext_t
*yyctx
)
1700 return yyctx
->yylloc
;
1703 /* User defined function to report a syntax error. */
1705 yyreport_syntax_error (const yypcontext_t
*yyctx
);
1707 /*-----------------------------------------------.
1708 | Release the memory associated to this symbol. |
1709 `-----------------------------------------------*/
1712 yydestruct (const char *yymsg
,
1713 yysymbol_kind_t yykind
, YYSTYPE
*yyvaluep
, YYLTYPE
*yylocationp
)
1716 YY_USE (yylocationp
);
1719 YY_SYMBOL_PRINT (yymsg
, yykind
, yyvaluep
, yylocationp
);
1721 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1724 case YYSYMBOL_generic_symlist
: /* generic_symlist */
1725 { symbol_list_free (((*yyvaluep
).generic_symlist
)); }
1728 case YYSYMBOL_generic_symlist_item
: /* generic_symlist_item */
1729 { symbol_list_free (((*yyvaluep
).generic_symlist_item
)); }
1732 case YYSYMBOL_nterm_decls
: /* nterm_decls */
1733 { symbol_list_free (((*yyvaluep
).nterm_decls
)); }
1736 case YYSYMBOL_token_decls
: /* token_decls */
1737 { symbol_list_free (((*yyvaluep
).token_decls
)); }
1740 case YYSYMBOL_82_token_decl_1
: /* token_decl.1 */
1741 { symbol_list_free (((*yyvaluep
).yykind_82
)); }
1744 case YYSYMBOL_token_decls_for_prec
: /* token_decls_for_prec */
1745 { symbol_list_free (((*yyvaluep
).token_decls_for_prec
)); }
1748 case YYSYMBOL_87_token_decl_for_prec_1
: /* token_decl_for_prec.1 */
1749 { symbol_list_free (((*yyvaluep
).yykind_87
)); }
1752 case YYSYMBOL_symbol_decls
: /* symbol_decls */
1753 { symbol_list_free (((*yyvaluep
).symbol_decls
)); }
1756 case YYSYMBOL_90_symbols_1
: /* symbols.1 */
1757 { symbol_list_free (((*yyvaluep
).yykind_90
)); }
1763 YY_IGNORE_MAYBE_UNINITIALIZED_END
1778 /* Lookahead token kind. */
1782 /* The semantic value of the lookahead symbol. */
1783 /* Default value used for initialization, for pacifying older GCCs
1784 or non-GCC compilers. */
1785 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
1786 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);
1788 /* Location data for the lookahead symbol. */
1789 static YYLTYPE yyloc_default
1790 # if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
1794 YYLTYPE yylloc
= yyloc_default
;
1796 /* Number of syntax errors so far. */
1799 yy_state_fast_t yystate
= 0;
1800 /* Number of tokens to shift before error messages enabled. */
1801 int yyerrstatus
= 0;
1803 /* Refer to the stacks through separate pointers, to allow yyoverflow
1804 to reallocate them elsewhere. */
1807 YYPTRDIFF_T yystacksize
= YYINITDEPTH
;
1809 /* The state stack: array, bottom, top. */
1810 yy_state_t yyssa
[YYINITDEPTH
];
1811 yy_state_t
*yyss
= yyssa
;
1812 yy_state_t
*yyssp
= yyss
;
1814 /* The semantic value stack: array, bottom, top. */
1815 YYSTYPE yyvsa
[YYINITDEPTH
];
1816 YYSTYPE
*yyvs
= yyvsa
;
1817 YYSTYPE
*yyvsp
= yyvs
;
1819 /* The location stack: array, bottom, top. */
1820 YYLTYPE yylsa
[YYINITDEPTH
];
1821 YYLTYPE
*yyls
= yylsa
;
1822 YYLTYPE
*yylsp
= yyls
;
1824 yy_state_t yyesa
[20];
1825 yy_state_t
*yyes
= yyesa
;
1826 YYPTRDIFF_T yyes_capacity
= 20 < YYMAXDEPTH
? 20 : YYMAXDEPTH
;
1828 /* Whether LAC context is established. A Boolean. */
1829 int yy_lac_established
= 0;
1831 /* The return value of yyparse. */
1833 /* Lookahead symbol kind. */
1834 yysymbol_kind_t yytoken
= YYSYMBOL_YYEMPTY
;
1835 /* The variables used to return semantic value and location from the
1840 /* The locations where the error started and ended. */
1841 YYLTYPE yyerror_range
[3];
1845 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1847 /* The number of symbols on the RHS of the reduced rule.
1848 Keep to zero when no symbol should be popped. */
1851 YYDPRINTF ((stderr
, "Starting parse\n"));
1853 yychar
= GRAM_EMPTY
; /* Cause a token to be read. */
1856 /* User initialization code. */
1858 /* Bison's grammar can initial empty locations, hence a default
1859 location is needed. */
1860 boundary_set (&yylloc
.start
, grammar_file
, 1, 1, 1);
1861 boundary_set (&yylloc
.end
, grammar_file
, 1, 1, 1);
1869 /*------------------------------------------------------------.
1870 | yynewstate -- push a new state, which is found in yystate. |
1871 `------------------------------------------------------------*/
1873 /* In all cases, when you get here, the value and location stacks
1874 have just been pushed. So pushing a state here evens the stacks. */
1878 /*--------------------------------------------------------------------.
1879 | yysetstate -- set current state (the top of the stack) to yystate. |
1880 `--------------------------------------------------------------------*/
1882 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1883 YY_ASSERT (0 <= yystate
&& yystate
< YYNSTATES
);
1884 YY_IGNORE_USELESS_CAST_BEGIN
1885 *yyssp
= YY_CAST (yy_state_t
, yystate
);
1886 YY_IGNORE_USELESS_CAST_END
1887 YY_STACK_PRINT (yyss
, yyssp
);
1889 if (yyss
+ yystacksize
- 1 <= yyssp
)
1890 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1894 /* Get the current used size of the three stacks, in elements. */
1895 YYPTRDIFF_T yysize
= yyssp
- yyss
+ 1;
1897 # if defined yyoverflow
1899 /* Give user a chance to reallocate the stack. Use copies of
1900 these so that the &'s don't force the real ones into
1902 yy_state_t
*yyss1
= yyss
;
1903 YYSTYPE
*yyvs1
= yyvs
;
1904 YYLTYPE
*yyls1
= yyls
;
1906 /* Each stack pointer address is followed by the size of the
1907 data in use in that stack, in bytes. This used to be a
1908 conditional around just the two extra args, but that might
1909 be undefined if yyoverflow is a macro. */
1910 yyoverflow (YY_("memory exhausted"),
1911 &yyss1
, yysize
* YYSIZEOF (*yyssp
),
1912 &yyvs1
, yysize
* YYSIZEOF (*yyvsp
),
1913 &yyls1
, yysize
* YYSIZEOF (*yylsp
),
1919 # else /* defined YYSTACK_RELOCATE */
1920 /* Extend the stack our own way. */
1921 if (YYMAXDEPTH
<= yystacksize
)
1924 if (YYMAXDEPTH
< yystacksize
)
1925 yystacksize
= YYMAXDEPTH
;
1928 yy_state_t
*yyss1
= yyss
;
1929 union yyalloc
*yyptr
=
1930 YY_CAST (union yyalloc
*,
1931 YYSTACK_ALLOC (YY_CAST (YYSIZE_T
, YYSTACK_BYTES (yystacksize
))));
1934 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1935 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1936 YYSTACK_RELOCATE (yyls_alloc
, yyls
);
1937 # undef YYSTACK_RELOCATE
1939 YYSTACK_FREE (yyss1
);
1943 yyssp
= yyss
+ yysize
- 1;
1944 yyvsp
= yyvs
+ yysize
- 1;
1945 yylsp
= yyls
+ yysize
- 1;
1947 YY_IGNORE_USELESS_CAST_BEGIN
1948 YYDPRINTF ((stderr
, "Stack size increased to %ld\n",
1949 YY_CAST (long, yystacksize
)));
1950 YY_IGNORE_USELESS_CAST_END
1952 if (yyss
+ yystacksize
- 1 <= yyssp
)
1955 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1958 if (yystate
== YYFINAL
)
1968 /* Do appropriate processing given the current state. Read a
1969 lookahead token if we need one and don't already have one. */
1971 /* First try to decide what to do without reference to lookahead token. */
1972 yyn
= yypact
[yystate
];
1973 if (yypact_value_is_default (yyn
))
1976 /* Not known => get a lookahead token if don't already have one. */
1978 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1979 if (yychar
== GRAM_EMPTY
)
1981 YYDPRINTF ((stderr
, "Reading a token\n"));
1982 yychar
= yylex (&yylval
, &yylloc
);
1985 if (yychar
<= GRAM_EOF
)
1988 yytoken
= YYSYMBOL_YYEOF
;
1989 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1991 else if (yychar
== GRAM_error
)
1993 /* The scanner already issued an error message, process directly
1994 to error recovery. But do not keep the error token as
1995 lookahead, it is too special and may lead us to an endless
1996 loop in error recovery. */
1997 yychar
= GRAM_UNDEF
;
1998 yytoken
= YYSYMBOL_YYerror
;
1999 yyerror_range
[1] = yylloc
;
2004 yytoken
= YYTRANSLATE (yychar
);
2005 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
2008 /* If the proper action on seeing token YYTOKEN is to reduce or to
2009 detect an error, take that action. */
2011 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
2019 if (yytable_value_is_error (yyn
))
2026 /* Count tokens shifted since error; after three, turn off error
2031 /* Shift the lookahead token. */
2032 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
2034 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2036 YY_IGNORE_MAYBE_UNINITIALIZED_END
2039 /* Discard the shifted token. */
2040 yychar
= GRAM_EMPTY
;
2041 YY_LAC_DISCARD ("shift");
2045 /*-----------------------------------------------------------.
2046 | yydefault -- do the default action for the current state. |
2047 `-----------------------------------------------------------*/
2049 yyn
= yydefact
[yystate
];
2055 /*-----------------------------.
2056 | yyreduce -- do a reduction. |
2057 `-----------------------------*/
2059 /* yyn is the number of a rule to reduce with. */
2062 /* If YYLEN is nonzero, implement the default value of the action:
2065 Otherwise, the following line sets YYVAL to garbage.
2066 This behavior is undocumented and Bison
2067 users should not rely upon it. Assigning to YYVAL
2068 unconditionally makes the parser a bit smaller, and it avoids a
2069 GCC warning that YYVAL may be used uninitialized. */
2070 yyval
= yyvsp
[1-yylen
];
2072 /* Default location. */
2073 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
2074 yyerror_range
[1] = yyloc
;
2075 YY_REDUCE_PRINT (yyn
);
2077 int yychar_backup
= yychar
;
2080 case 6: /* prologue_declaration: "%{...%}" */
2082 muscle_code_grow (union_seen
? "post_prologue" : "pre_prologue",
2083 translate_code ((yyvsp
[0].PROLOGUE
), (yylsp
[0]), true), (yylsp
[0]));
2084 code_scanner_last_string_free ();
2088 case 7: /* prologue_declaration: "%<flag>" */
2090 muscle_percent_define_ensure ((yyvsp
[0].PERCENT_FLAG
), (yylsp
[0]), true);
2094 case 8: /* prologue_declaration: "%define" variable value */
2096 muscle_percent_define_insert ((yyvsp
[-1].variable
), (yyloc
), (yyvsp
[0].value
).kind
, (yyvsp
[0].value
).chars
,
2097 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
);
2101 case 9: /* prologue_declaration: "%header" string.opt */
2102 { handle_header ((yyvsp
[0].yykind_75
)); }
2105 case 10: /* prologue_declaration: "%error-verbose" */
2106 { handle_error_verbose (&(yyloc
), (yyvsp
[0].PERCENT_ERROR_VERBOSE
)); }
2109 case 11: /* prologue_declaration: "%expect" "integer literal" */
2110 { expected_sr_conflicts
= (yyvsp
[0].INT_LITERAL
); }
2113 case 12: /* prologue_declaration: "%expect-rr" "integer literal" */
2114 { expected_rr_conflicts
= (yyvsp
[0].INT_LITERAL
); }
2117 case 13: /* prologue_declaration: "%file-prefix" "string" */
2118 { handle_file_prefix (&(yyloc
), &(yylsp
[-1]), (yyvsp
[-1].PERCENT_FILE_PREFIX
), (yyvsp
[0].STRING
)); }
2121 case 14: /* prologue_declaration: "%glr-parser" */
2123 nondeterministic_parser
= true;
2128 case 15: /* prologue_declaration: "%initial-action" "{...}" */
2130 muscle_code_grow ("initial_action", translate_code ((yyvsp
[0].BRACED_CODE
), (yylsp
[0]), false), (yylsp
[0]));
2131 code_scanner_last_string_free ();
2135 case 16: /* prologue_declaration: "%language" "string" */
2136 { handle_language (&(yylsp
[-1]), (yyvsp
[0].STRING
)); }
2139 case 17: /* prologue_declaration: "%name-prefix" "string" */
2140 { handle_name_prefix (&(yyloc
), (yyvsp
[-1].PERCENT_NAME_PREFIX
), (yyvsp
[0].STRING
)); }
2143 case 18: /* prologue_declaration: "%no-lines" */
2144 { no_lines_flag
= true; }
2147 case 19: /* prologue_declaration: "%nondeterministic-parser" */
2148 { nondeterministic_parser
= true; }
2151 case 20: /* prologue_declaration: "%output" "string" */
2152 { spec_outfile
= unquote ((yyvsp
[0].STRING
)); gram_scanner_last_string_free (); }
2155 case 21: /* $@1: %empty */
2156 { current_param
= (yyvsp
[0].PERCENT_PARAM
); }
2159 case 22: /* prologue_declaration: "%param" $@1 params */
2160 { current_param
= param_none
; }
2163 case 23: /* prologue_declaration: "%pure-parser" */
2164 { handle_pure_parser (&(yyloc
), (yyvsp
[0].PERCENT_PURE_PARSER
)); }
2167 case 24: /* prologue_declaration: "%require" "string" */
2168 { handle_require (&(yylsp
[0]), (yyvsp
[0].STRING
)); }
2171 case 25: /* prologue_declaration: "%skeleton" "string" */
2172 { handle_skeleton (&(yylsp
[0]), (yyvsp
[0].STRING
)); }
2175 case 26: /* prologue_declaration: "%token-table" */
2176 { token_table_flag
= true; }
2179 case 27: /* prologue_declaration: "%verbose" */
2180 { report_flag
|= report_states
; }
2183 case 28: /* prologue_declaration: "%yacc" */
2184 { handle_yacc (&(yyloc
)); }
2187 case 29: /* prologue_declaration: error ";" */
2188 { current_class
= unknown_sym
; yyerrok
; }
2191 case 31: /* params: params "{...}" */
2192 { add_param (current_param
, (yyvsp
[0].BRACED_CODE
), (yylsp
[0])); }
2195 case 32: /* params: "{...}" */
2196 { add_param (current_param
, (yyvsp
[0].BRACED_CODE
), (yylsp
[0])); }
2199 case 34: /* grammar_declaration: "%start" symbols.1 */
2201 grammar_start_symbols_add ((yyvsp
[0].yykind_90
));
2205 case 35: /* grammar_declaration: code_props_type "{...}" generic_symlist */
2208 code_props_symbol_action_init (&code
, (yyvsp
[-1].BRACED_CODE
), (yylsp
[-1]));
2209 code_props_translate_code (&code
);
2211 for (symbol_list
*list
= (yyvsp
[0].generic_symlist
); list
; list
= list
->next
)
2212 symbol_list_code_props_set (list
, (yyvsp
[-2].code_props_type
), &code
);
2213 symbol_list_free ((yyvsp
[0].generic_symlist
));
2218 case 36: /* grammar_declaration: "%default-prec" */
2220 default_prec
= true;
2224 case 37: /* grammar_declaration: "%no-default-prec" */
2226 default_prec
= false;
2230 case 38: /* grammar_declaration: "%code" "{...}" */
2232 /* Do not invoke muscle_percent_code_grow here since it invokes
2233 muscle_user_name_list_grow. */
2234 muscle_code_grow ("percent_code()",
2235 translate_code_braceless ((yyvsp
[0].BRACED_CODE
), (yylsp
[0])), (yylsp
[0]));
2236 code_scanner_last_string_free ();
2240 case 39: /* grammar_declaration: "%code" "identifier" "{...}" */
2242 muscle_percent_code_grow ((yyvsp
[-1].ID
), (yylsp
[-1]), translate_code_braceless ((yyvsp
[0].BRACED_CODE
), (yylsp
[0])), (yylsp
[0]));
2243 code_scanner_last_string_free ();
2247 case 40: /* code_props_type: "%destructor" */
2248 { (yyval
.code_props_type
) = destructor
; }
2251 case 41: /* code_props_type: "%printer" */
2252 { (yyval
.code_props_type
) = printer
; }
2255 case 42: /* union_name: %empty */
2259 case 43: /* union_name: "identifier" */
2260 { muscle_percent_define_insert ("api.value.union.name",
2261 (yylsp
[0]), muscle_keyword
, (yyvsp
[0].ID
),
2262 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
); }
2265 case 44: /* grammar_declaration: "%union" union_name "{...}" */
2268 muscle_code_grow ("union_members", translate_code_braceless ((yyvsp
[0].BRACED_CODE
), (yylsp
[0])), (yylsp
[0]));
2269 code_scanner_last_string_free ();
2273 case 45: /* $@2: %empty */
2274 { current_class
= nterm_sym
; }
2277 case 46: /* symbol_declaration: "%nterm" $@2 nterm_decls */
2279 current_class
= unknown_sym
;
2280 symbol_list_free ((yyvsp
[0].nterm_decls
));
2284 case 47: /* $@3: %empty */
2285 { current_class
= token_sym
; }
2288 case 48: /* symbol_declaration: "%token" $@3 token_decls */
2290 current_class
= unknown_sym
;
2291 symbol_list_free ((yyvsp
[0].token_decls
));
2295 case 49: /* $@4: %empty */
2296 { current_class
= pct_type_sym
; }
2299 case 50: /* symbol_declaration: "%type" $@4 symbol_decls */
2301 current_class
= unknown_sym
;
2302 symbol_list_free ((yyvsp
[0].symbol_decls
));
2306 case 51: /* symbol_declaration: precedence_declarator token_decls_for_prec */
2309 for (symbol_list
*list
= (yyvsp
[0].token_decls_for_prec
); list
; list
= list
->next
)
2310 symbol_precedence_set (list
->content
.sym
, current_prec
, (yyvsp
[-1].precedence_declarator
), (yylsp
[-1]));
2311 symbol_list_free ((yyvsp
[0].token_decls_for_prec
));
2315 case 52: /* precedence_declarator: "%left" */
2316 { (yyval
.precedence_declarator
) = left_assoc
; }
2319 case 53: /* precedence_declarator: "%right" */
2320 { (yyval
.precedence_declarator
) = right_assoc
; }
2323 case 54: /* precedence_declarator: "%nonassoc" */
2324 { (yyval
.precedence_declarator
) = non_assoc
; }
2327 case 55: /* precedence_declarator: "%precedence" */
2328 { (yyval
.precedence_declarator
) = precedence_assoc
; }
2331 case 56: /* string.opt: %empty */
2332 { (yyval
.yykind_75
) = NULL
; }
2335 case 57: /* string.opt: "string" */
2336 { (yyval
.yykind_75
) = (yyvsp
[0].STRING
); }
2339 case 58: /* tag.opt: %empty */
2340 { (yyval
.yykind_76
) = NULL
; }
2343 case 59: /* tag.opt: "<tag>" */
2344 { (yyval
.yykind_76
) = (yyvsp
[0].TAG
); }
2347 case 61: /* generic_symlist: generic_symlist generic_symlist_item */
2348 { (yyval
.generic_symlist
) = symbol_list_append ((yyvsp
[-1].generic_symlist
), (yyvsp
[0].generic_symlist_item
)); }
2351 case 62: /* generic_symlist_item: symbol */
2352 { (yyval
.generic_symlist_item
) = symbol_list_sym_new ((yyvsp
[0].symbol
), (yylsp
[0])); }
2355 case 63: /* generic_symlist_item: tag */
2356 { (yyval
.generic_symlist_item
) = symbol_list_type_new ((yyvsp
[0].tag
), (yylsp
[0])); }
2359 case 65: /* tag: "<*>" */
2360 { (yyval
.tag
) = uniqstr_new ("*"); }
2363 case 66: /* tag: "<>" */
2364 { (yyval
.tag
) = uniqstr_new (""); }
2367 case 68: /* token_decls: token_decl.1 */
2369 (yyval
.token_decls
) = (yyvsp
[0].yykind_82
);
2373 case 69: /* token_decls: "<tag>" token_decl.1 */
2375 (yyval
.token_decls
) = symbol_list_type_set ((yyvsp
[0].yykind_82
), (yyvsp
[-1].TAG
));
2379 case 70: /* token_decls: token_decls "<tag>" token_decl.1 */
2381 (yyval
.token_decls
) = symbol_list_append ((yyvsp
[-2].token_decls
), symbol_list_type_set ((yyvsp
[0].yykind_82
), (yyvsp
[-1].TAG
)));
2385 case 71: /* token_decl.1: token_decl */
2386 { (yyval
.yykind_82
) = symbol_list_sym_new ((yyvsp
[0].token_decl
), (yylsp
[0])); }
2389 case 72: /* token_decl.1: token_decl.1 token_decl */
2390 { (yyval
.yykind_82
) = symbol_list_append ((yyvsp
[-1].yykind_82
), symbol_list_sym_new ((yyvsp
[0].token_decl
), (yylsp
[0]))); }
2393 case 73: /* token_decl: id int.opt alias */
2395 (yyval
.token_decl
) = (yyvsp
[-2].id
);
2396 symbol_class_set ((yyvsp
[-2].id
), current_class
, (yylsp
[-2]), true);
2397 if (0 <= (yyvsp
[-1].yykind_84
))
2398 symbol_code_set ((yyvsp
[-2].id
), (yyvsp
[-1].yykind_84
), (yylsp
[-1]));
2399 if ((yyvsp
[0].alias
))
2400 symbol_make_alias ((yyvsp
[-2].id
), (yyvsp
[0].alias
), (yylsp
[0]));
2404 case 74: /* int.opt: %empty */
2405 { (yyval
.yykind_84
) = -1; }
2408 case 76: /* alias: %empty */
2409 { (yyval
.alias
) = NULL
; }
2412 case 77: /* alias: string_as_id */
2413 { (yyval
.alias
) = (yyvsp
[0].string_as_id
); }
2416 case 78: /* alias: "translatable string" */
2418 (yyval
.alias
) = symbol_get ((yyvsp
[0].TSTRING
), (yylsp
[0]));
2419 symbol_class_set ((yyval
.alias
), token_sym
, (yylsp
[0]), false);
2420 (yyval
.alias
)->translatable
= true;
2424 case 79: /* token_decls_for_prec: token_decl_for_prec.1 */
2426 (yyval
.token_decls_for_prec
) = (yyvsp
[0].yykind_87
);
2430 case 80: /* token_decls_for_prec: "<tag>" token_decl_for_prec.1 */
2432 (yyval
.token_decls_for_prec
) = symbol_list_type_set ((yyvsp
[0].yykind_87
), (yyvsp
[-1].TAG
));
2436 case 81: /* token_decls_for_prec: token_decls_for_prec "<tag>" token_decl_for_prec.1 */
2438 (yyval
.token_decls_for_prec
) = symbol_list_append ((yyvsp
[-2].token_decls_for_prec
), symbol_list_type_set ((yyvsp
[0].yykind_87
), (yyvsp
[-1].TAG
)));
2442 case 82: /* token_decl_for_prec.1: token_decl_for_prec */
2443 { (yyval
.yykind_87
) = symbol_list_sym_new ((yyvsp
[0].token_decl_for_prec
), (yylsp
[0])); }
2446 case 83: /* token_decl_for_prec.1: token_decl_for_prec.1 token_decl_for_prec */
2447 { (yyval
.yykind_87
) = symbol_list_append ((yyvsp
[-1].yykind_87
), symbol_list_sym_new ((yyvsp
[0].token_decl_for_prec
), (yylsp
[0]))); }
2450 case 84: /* token_decl_for_prec: id int.opt */
2452 (yyval
.token_decl_for_prec
) = (yyvsp
[-1].id
);
2453 symbol_class_set ((yyvsp
[-1].id
), token_sym
, (yylsp
[-1]), false);
2454 if (0 <= (yyvsp
[0].yykind_84
))
2455 symbol_code_set ((yyvsp
[-1].id
), (yyvsp
[0].yykind_84
), (yylsp
[0]));
2459 case 86: /* symbol_decls: symbols.1 */
2461 (yyval
.symbol_decls
) = (yyvsp
[0].yykind_90
);
2465 case 87: /* symbol_decls: "<tag>" symbols.1 */
2467 (yyval
.symbol_decls
) = symbol_list_type_set ((yyvsp
[0].yykind_90
), (yyvsp
[-1].TAG
));
2471 case 88: /* symbol_decls: symbol_decls "<tag>" symbols.1 */
2473 (yyval
.symbol_decls
) = symbol_list_append ((yyvsp
[-2].symbol_decls
), symbol_list_type_set ((yyvsp
[0].yykind_90
), (yyvsp
[-1].TAG
)));
2477 case 89: /* symbols.1: symbol */
2479 if (current_class
!= unknown_sym
)
2480 symbol_class_set ((yyvsp
[0].symbol
), current_class
, (yylsp
[0]), false);
2481 (yyval
.yykind_90
) = symbol_list_sym_new ((yyvsp
[0].symbol
), (yylsp
[0]));
2485 case 90: /* symbols.1: symbols.1 symbol */
2487 if (current_class
!= unknown_sym
)
2488 symbol_class_set ((yyvsp
[0].symbol
), current_class
, (yylsp
[0]), false);
2489 (yyval
.yykind_90
) = symbol_list_append ((yyvsp
[-1].yykind_90
), symbol_list_sym_new ((yyvsp
[0].symbol
), (yylsp
[0])));
2493 case 95: /* rules_or_grammar_declaration: error ";" */
2499 case 96: /* $@5: %empty */
2500 { current_lhs ((yyvsp
[-1].id_colon
), (yylsp
[-1]), (yyvsp
[0].yykind_97
)); }
2503 case 97: /* rules: id_colon named_ref.opt $@5 ":" rhses.1 */
2505 /* Free the current lhs. */
2506 current_lhs (0, (yylsp
[-4]), 0);
2510 case 98: /* rhses.1: rhs */
2511 { grammar_current_rule_end ((yylsp
[0])); }
2514 case 99: /* rhses.1: rhses.1 "|" rhs */
2515 { grammar_current_rule_end ((yylsp
[0])); }
2518 case 101: /* rhs: %empty */
2519 { grammar_current_rule_begin (current_lhs_symbol
, current_lhs_loc
,
2520 current_lhs_named_ref
); }
2523 case 102: /* rhs: rhs symbol named_ref.opt */
2524 { grammar_current_rule_symbol_append ((yyvsp
[-1].symbol
), (yylsp
[-1]), (yyvsp
[0].yykind_97
)); }
2527 case 103: /* rhs: rhs tag.opt "{...}" named_ref.opt */
2528 { grammar_current_rule_action_append ((yyvsp
[-1].BRACED_CODE
), (yylsp
[-1]), (yyvsp
[0].yykind_97
), (yyvsp
[-2].yykind_76
)); }
2531 case 104: /* rhs: rhs "%?{...}" */
2532 { grammar_current_rule_predicate_append ((yyvsp
[0].BRACED_PREDICATE
), (yylsp
[0])); }
2535 case 105: /* rhs: rhs "%empty" */
2536 { grammar_current_rule_empty_set ((yylsp
[0])); }
2539 case 106: /* rhs: rhs "%prec" symbol */
2540 { grammar_current_rule_prec_set ((yyvsp
[0].symbol
), (yylsp
[0])); }
2543 case 107: /* rhs: rhs "%dprec" "integer literal" */
2544 { grammar_current_rule_dprec_set ((yyvsp
[0].INT_LITERAL
), (yylsp
[0])); }
2547 case 108: /* rhs: rhs "%merge" "<tag>" */
2548 { grammar_current_rule_merge_set ((yyvsp
[0].TAG
), (yylsp
[0])); }
2551 case 109: /* rhs: rhs "%expect" "integer literal" */
2552 { grammar_current_rule_expect_sr ((yyvsp
[0].INT_LITERAL
), (yylsp
[0])); }
2555 case 110: /* rhs: rhs "%expect-rr" "integer literal" */
2556 { grammar_current_rule_expect_rr ((yyvsp
[0].INT_LITERAL
), (yylsp
[0])); }
2559 case 111: /* named_ref.opt: %empty */
2560 { (yyval
.yykind_97
) = NULL
; }
2563 case 112: /* named_ref.opt: "[identifier]" */
2564 { (yyval
.yykind_97
) = named_ref_new ((yyvsp
[0].BRACKETED_ID
), (yylsp
[0])); }
2567 case 114: /* value: %empty */
2568 { (yyval
.value
).kind
= muscle_keyword
; (yyval
.value
).chars
= ""; }
2571 case 115: /* value: "identifier" */
2572 { (yyval
.value
).kind
= muscle_keyword
; (yyval
.value
).chars
= (yyvsp
[0].ID
); }
2575 case 116: /* value: "string" */
2576 { (yyval
.value
).kind
= muscle_string
; (yyval
.value
).chars
= unquote ((yyvsp
[0].STRING
)); gram_scanner_last_string_free ();}
2579 case 117: /* value: "{...}" */
2580 { (yyval
.value
).kind
= muscle_code
; (yyval
.value
).chars
= strip_braces ((yyvsp
[0].BRACED_CODE
)); gram_scanner_last_string_free (); }
2583 case 118: /* id: "identifier" */
2584 { (yyval
.id
) = symbol_from_uniqstr ((yyvsp
[0].ID
), (yylsp
[0])); }
2587 case 119: /* id: "character literal" */
2589 const char *var
= "api.token.raw";
2590 if (current_class
== nterm_sym
)
2592 complain (&(yylsp
[0]), complaint
,
2593 _("character literals cannot be nonterminals"));
2596 if (muscle_percent_define_ifdef (var
))
2598 complain (&(yylsp
[0]), complaint
,
2599 _("character literals cannot be used together"
2601 location loc
= muscle_percent_define_get_loc (var
);
2602 subcomplain (&loc
, complaint
, _("definition of %s"), var
);
2604 (yyval
.id
) = symbol_get (char_name ((yyvsp
[0].CHAR_LITERAL
)), (yylsp
[0]));
2605 symbol_class_set ((yyval
.id
), token_sym
, (yylsp
[0]), false);
2606 symbol_code_set ((yyval
.id
), (yyvsp
[0].CHAR_LITERAL
), (yylsp
[0]));
2610 case 120: /* id_colon: "identifier:" */
2611 { (yyval
.id_colon
) = symbol_from_uniqstr ((yyvsp
[0].ID_COLON
), (yylsp
[0])); }
2614 case 123: /* string_as_id: "string" */
2616 (yyval
.string_as_id
) = symbol_get ((yyvsp
[0].STRING
), (yylsp
[0]));
2617 symbol_class_set ((yyval
.string_as_id
), token_sym
, (yylsp
[0]), false);
2621 case 125: /* epilogue.opt: "%%" "epilogue" */
2623 muscle_code_grow ("epilogue", translate_code ((yyvsp
[0].EPILOGUE
), (yylsp
[0]), true), (yylsp
[0]));
2624 code_scanner_last_string_free ();
2632 if (yychar_backup
!= yychar
)
2633 YY_LAC_DISCARD ("yychar change");
2635 /* User semantic actions sometimes alter yychar, and that requires
2636 that yytoken be updated with the new translation. We take the
2637 approach of translating immediately before every use of yytoken.
2638 One alternative is translating here after every semantic action,
2639 but that translation would be missed if the semantic action invokes
2640 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2641 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2642 incorrect destructor might then be invoked immediately. In the
2643 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2644 to an incorrect destructor call or verbose syntax error message
2645 before the lookahead is translated. */
2646 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t
, yyr1
[yyn
]), &yyval
, &yyloc
);
2654 /* Now 'shift' the result of the reduction. Determine what state
2655 that goes to, based on the state we popped back to and the rule
2656 number reduced by. */
2658 const int yylhs
= yyr1
[yyn
] - YYNTOKENS
;
2659 const int yyi
= yypgoto
[yylhs
] + *yyssp
;
2660 yystate
= (0 <= yyi
&& yyi
<= YYLAST
&& yycheck
[yyi
] == *yyssp
2662 : yydefgoto
[yylhs
]);
2668 /*--------------------------------------.
2669 | yyerrlab -- here on detecting error. |
2670 `--------------------------------------*/
2672 /* Make sure we have latest lookahead translation. See comments at
2673 user semantic actions for why this is necessary. */
2674 yytoken
= yychar
== GRAM_EMPTY
? YYSYMBOL_YYEMPTY
: YYTRANSLATE (yychar
);
2675 /* If not already recovering from an error, report this error. */
2681 = {yyssp
, yyesa
, &yyes
, &yyes_capacity
, yytoken
, &yylloc
};
2682 if (yychar
!= GRAM_EMPTY
)
2684 if (yyreport_syntax_error (&yyctx
) == 2)
2689 yyerror_range
[1] = yylloc
;
2690 if (yyerrstatus
== 3)
2692 /* If just tried and failed to reuse lookahead token after an
2693 error, discard it. */
2695 if (yychar
<= GRAM_EOF
)
2697 /* Return failure if at end of input. */
2698 if (yychar
== GRAM_EOF
)
2703 yydestruct ("Error: discarding",
2704 yytoken
, &yylval
, &yylloc
);
2705 yychar
= GRAM_EMPTY
;
2709 /* Else will try to reuse lookahead token after shifting the error
2714 /*---------------------------------------------------.
2715 | yyerrorlab -- error raised explicitly by YYERROR. |
2716 `---------------------------------------------------*/
2718 /* Pacify compilers when the user code never invokes YYERROR and the
2719 label yyerrorlab therefore never appears in user code. */
2724 /* Do not reclaim the symbols of the rule whose action triggered
2728 YY_STACK_PRINT (yyss
, yyssp
);
2733 /*-------------------------------------------------------------.
2734 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2735 `-------------------------------------------------------------*/
2737 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2739 /* Pop stack until we find a state that shifts the error token. */
2742 yyn
= yypact
[yystate
];
2743 if (!yypact_value_is_default (yyn
))
2745 yyn
+= YYSYMBOL_YYerror
;
2746 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYSYMBOL_YYerror
)
2754 /* Pop the current state because it cannot handle the error token. */
2758 yyerror_range
[1] = *yylsp
;
2759 yydestruct ("Error: popping",
2760 YY_ACCESSING_SYMBOL (yystate
), yyvsp
, yylsp
);
2763 YY_STACK_PRINT (yyss
, yyssp
);
2766 /* If the stack popping above didn't lose the initial context for the
2767 current lookahead token, the shift below will for sure. */
2768 YY_LAC_DISCARD ("error recovery");
2770 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2772 YY_IGNORE_MAYBE_UNINITIALIZED_END
2774 yyerror_range
[2] = yylloc
;
2776 YYLLOC_DEFAULT (*yylsp
, yyerror_range
, 2);
2778 /* Shift the error token. */
2779 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn
), yyvsp
, yylsp
);
2785 /*-------------------------------------.
2786 | yyacceptlab -- YYACCEPT comes here. |
2787 `-------------------------------------*/
2793 /*-----------------------------------.
2794 | yyabortlab -- YYABORT comes here. |
2795 `-----------------------------------*/
2801 /*-----------------------------------------------------------.
2802 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2803 `-----------------------------------------------------------*/
2805 yyerror (&yylloc
, YY_("memory exhausted"));
2810 /*----------------------------------------------------------.
2811 | yyreturnlab -- parsing is finished, clean up and return. |
2812 `----------------------------------------------------------*/
2814 if (yychar
!= GRAM_EMPTY
)
2816 /* Make sure we have latest lookahead translation. See comments at
2817 user semantic actions for why this is necessary. */
2818 yytoken
= YYTRANSLATE (yychar
);
2819 yydestruct ("Cleanup: discarding lookahead",
2820 yytoken
, &yylval
, &yylloc
);
2822 /* Do not reclaim the symbols of the rule whose action triggered
2823 this YYABORT or YYACCEPT. */
2825 YY_STACK_PRINT (yyss
, yyssp
);
2826 while (yyssp
!= yyss
)
2828 yydestruct ("Cleanup: popping",
2829 YY_ACCESSING_SYMBOL (+*yyssp
), yyvsp
, yylsp
);
2834 YYSTACK_FREE (yyss
);
2837 YYSTACK_FREE (yyes
);
2845 yyreport_syntax_error (const yypcontext_t
*ctx
)
2848 /* Arguments of format: reported tokens (one for the "unexpected",
2849 one per "expected"). */
2850 enum { ARGS_MAX
= 5 };
2851 const char *argv
[ARGS_MAX
];
2853 yysymbol_kind_t unexpected
= yypcontext_token (ctx
);
2854 if (unexpected
!= YYSYMBOL_YYEMPTY
)
2856 argv
[argc
++] = yysymbol_name (unexpected
);
2857 yysymbol_kind_t expected
[ARGS_MAX
- 1];
2858 int nexpected
= yypcontext_expected_tokens (ctx
, expected
, ARGS_MAX
- 1);
2862 for (int i
= 0; i
< nexpected
; ++i
)
2863 argv
[argc
++] = yysymbol_name (expected
[i
]);
2865 syntax_error (*yypcontext_location (ctx
), argc
, argv
);
2870 /* Return the location of the left-hand side of a rule whose
2871 right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in
2872 the right-hand side, and return an empty location equal to the end
2873 boundary of RHS[0] if the right-hand side is empty. */
2876 lloc_default (YYLTYPE
const *rhs
, int n
)
2880 /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;".
2881 The bug is fixed in 7.4.2m, but play it safe for now. */
2882 loc
.start
= rhs
[n
].end
;
2883 loc
.end
= rhs
[n
].end
;
2885 /* Ignore empty nonterminals the start of the right-hand side.
2886 Do not bother to ignore them at the end of the right-hand side,
2887 since empty nonterminals have the same end as their predecessors. */
2888 for (int i
= 1; i
<= n
; i
++)
2889 if (! equal_boundaries (rhs
[i
].start
, rhs
[i
].end
))
2891 loc
.start
= rhs
[i
].start
;
2899 char *strip_braces (char *code
)
2901 code
[strlen (code
) - 1] = 0;
2907 translate_code (char *code
, location loc
, bool plain
)
2909 code_props plain_code
;
2911 code_props_plain_init (&plain_code
, code
, loc
);
2913 code_props_symbol_action_init (&plain_code
, code
, loc
);
2914 code_props_translate_code (&plain_code
);
2915 gram_scanner_last_string_free ();
2916 return plain_code
.code
;
2921 translate_code_braceless (char *code
, location loc
)
2923 return translate_code (strip_braces (code
), loc
, true);
2927 add_param (param_type type
, char *decl
, location loc
)
2929 static char const alphanum
[26 + 26 + 1 + 10 + 1] =
2930 "abcdefghijklmnopqrstuvwxyz"
2931 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2935 char const *name_start
= NULL
;
2938 /* Stop on last actual character. */
2939 for (p
= decl
; p
[1]; p
++)
2941 || ! memchr (alphanum
, p
[-1], sizeof alphanum
- 1))
2942 && memchr (alphanum
, p
[0], sizeof alphanum
- 10 - 1))
2945 /* Strip the surrounding '{' and '}', and any blanks just inside
2948 while (c_isspace ((unsigned char) *p
))
2952 while (c_isspace ((unsigned char) *decl
))
2957 complain (&loc
, complaint
, _("missing identifier in parameter declaration"));
2960 char *name
= xmemdup0 (name_start
, strspn (name_start
, alphanum
));
2961 if (type
& param_lex
)
2962 muscle_pair_list_grow ("lex_param", decl
, name
);
2963 if (type
& param_parse
)
2964 muscle_pair_list_grow ("parse_param", decl
, name
);
2968 gram_scanner_last_string_free ();
2973 handle_header (char const *value
)
2978 char *file
= unquote (value
);
2979 spec_header_file
= xstrdup (file
);
2980 gram_scanner_last_string_free ();
2981 unquote_free (file
);
2987 handle_error_verbose (location
const *loc
, char const *directive
)
2989 bison_directive (loc
, directive
);
2990 muscle_percent_define_insert (directive
, *loc
, muscle_keyword
, "",
2991 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
);
2996 handle_file_prefix (location
const *loc
,
2997 location
const *dir_loc
,
2998 char const *directive
, char const *value_quoted
)
3000 char *value
= unquote (value_quoted
);
3001 bison_directive (loc
, directive
);
3002 bool warned
= false;
3004 if (location_empty (spec_file_prefix_loc
))
3006 spec_file_prefix_loc
= *loc
;
3007 spec_file_prefix
= value
;
3011 duplicate_directive (directive
, spec_file_prefix_loc
, *loc
);
3016 && STRNEQ (directive
, "%file-prefix"))
3017 deprecated_directive (dir_loc
, directive
, "%file-prefix");
3021 handle_language (location
const *loc
, char const *lang
)
3023 language_argmatch (unquote (lang
), grammar_prio
, *loc
);
3028 handle_name_prefix (location
const *loc
,
3029 char const *directive
, char const *value_quoted
)
3031 char *value
= unquote (value_quoted
);
3032 bison_directive (loc
, directive
);
3035 size_t len1
= sizeof (buf1
);
3036 char *old
= asnprintf (buf1
, &len1
, "%s\"%s\"", directive
, value
);
3040 if (location_empty (spec_name_prefix_loc
))
3042 spec_name_prefix
= value
;
3043 spec_name_prefix_loc
= *loc
;
3046 size_t len2
= sizeof (buf2
);
3047 char *new = asnprintf (buf2
, &len2
, "%%define api.prefix {%s}", value
);
3050 deprecated_directive (loc
, old
, new);
3055 duplicate_directive (old
, spec_file_prefix_loc
, *loc
);
3063 handle_pure_parser (location
const *loc
, char const *directive
)
3065 bison_directive (loc
, directive
);
3066 deprecated_directive (loc
, directive
, "%define api.pure");
3067 muscle_percent_define_insert ("api.pure", *loc
, muscle_keyword
, "",
3068 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
);
3073 handle_require (location
const *loc
, char const *version_quoted
)
3075 char *version
= unquote (version_quoted
);
3076 required_version
= strversion_to_int (version
);
3077 if (required_version
== -1)
3079 complain (loc
, complaint
, _("invalid version requirement: %s"),
3081 required_version
= 0;
3085 const char* package_version
=
3086 0 < strverscmp (api_version
, PACKAGE_VERSION
)
3087 ? api_version
: PACKAGE_VERSION
;
3088 if (0 < strverscmp (version
, package_version
))
3090 complain (loc
, complaint
, _("require bison %s, but have %s"),
3091 version
, package_version
);
3095 unquote_free (version
);
3096 gram_scanner_last_string_free ();
3100 handle_skeleton (location
const *loc
, char const *skel_quoted
)
3102 char *skel
= unquote (skel_quoted
);
3103 char const *skeleton_user
= skel
;
3104 if (strchr (skeleton_user
, '/'))
3106 size_t dir_length
= strlen (grammar_file
);
3107 while (dir_length
&& grammar_file
[dir_length
- 1] != '/')
3109 while (dir_length
&& grammar_file
[dir_length
- 1] == '/')
3111 char *skeleton_build
=
3112 xmalloc (dir_length
+ 1 + strlen (skeleton_user
) + 1);
3115 memcpy (skeleton_build
, grammar_file
, dir_length
);
3116 skeleton_build
[dir_length
++] = '/';
3118 strcpy (skeleton_build
+ dir_length
, skeleton_user
);
3119 skeleton_user
= uniqstr_new (skeleton_build
);
3120 free (skeleton_build
);
3122 skeleton_arg (skeleton_user
, grammar_prio
, *loc
);
3127 handle_yacc (location
const *loc
)
3129 const char *directive
= "%yacc";
3130 bison_directive (loc
, directive
);
3131 if (location_empty (yacc_loc
))
3134 duplicate_directive (directive
, yacc_loc
, *loc
);
3139 gram_error (location
const *loc
, char const *msg
)
3141 complain (loc
, complaint
, "%s", msg
);
3152 buf
[0] = '\''; buf
[1] = c
; buf
[2] = '\''; buf
[3] = '\0';
3153 return quotearg_style (escape_quoting_style
, buf
);
3158 current_lhs (symbol
*sym
, location loc
, named_ref
*ref
)
3160 current_lhs_symbol
= sym
;
3161 current_lhs_loc
= loc
;
3163 symbol_location_as_lhs_set (sym
, loc
);
3164 /* In order to simplify memory management, named references for lhs
3165 are always assigned by deep copy into the current symbol_list
3166 node. This is because a single named-ref in the grammar may
3167 result in several uses when the user factors lhs between several
3168 rules using "|". Therefore free the parser's original copy. */
3169 free (current_lhs_named_ref
);
3170 current_lhs_named_ref
= ref
;
3173 static void tron (FILE *yyo
)
3175 begin_use_class ("value", yyo
);
3178 static void troff (FILE *yyo
)
3180 end_use_class ("value", yyo
);
3188 struct obstack obstack_for_unquote
;
3193 obstack_init (&obstack_for_unquote
);
3199 obstack_free (&obstack_for_unquote
, 0);
3203 unquote_free (char *last_string
)
3205 obstack_free (&obstack_for_unquote
, last_string
);
3209 unquote (const char *cp
)
3211 #define GROW(Char) \
3212 obstack_1grow (&obstack_for_unquote, Char);
3213 for (++cp
; *cp
&& *cp
!= '"'; ++cp
)
3222 case '0': case '1': case '2': case '3': case '4':
3223 case '5': case '6': case '7': case '8': case '9':
3225 int c
= cp
[0] - '0';
3226 if (c_isdigit (cp
[1]))
3229 c
= c
* 8 + cp
[0] - '0';
3231 if (c_isdigit (cp
[1]))
3234 c
= c
* 8 + cp
[0] - '0';
3240 case 'a': GROW ('\a'); break;
3241 case 'b': GROW ('\b'); break;
3242 case 'f': GROW ('\f'); break;
3243 case 'n': GROW ('\n'); break;
3244 case 'r': GROW ('\r'); break;
3245 case 't': GROW ('\t'); break;
3246 case 'v': GROW ('\v'); break;
3251 while (c_isxdigit (cp
[1]))
3254 c
= (c
* 16 + (c_isdigit (cp
[0]) ? cp
[0] - '0'
3255 : c_isupper (cp
[0]) ? cp
[0] - 'A'
3268 assert (*cp
== '"');
3270 assert (*cp
== '\0');
3272 return obstack_finish0 (&obstack_for_unquote
);