1 /* A Bison parser, made by GNU Bison 3.7.4.273-d85e. */
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 <http://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.4.273-d85e"
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 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
371 typedef __UINT_LEAST8_TYPE__ yytype_uint8
;
372 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
373 && UINT_LEAST8_MAX <= INT_MAX)
374 typedef uint_least8_t yytype_uint8
;
375 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
376 typedef unsigned char yytype_uint8
;
378 typedef short yytype_uint8
;
381 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
382 typedef __UINT_LEAST16_TYPE__ yytype_uint16
;
383 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
384 && UINT_LEAST16_MAX <= INT_MAX)
385 typedef uint_least16_t yytype_uint16
;
386 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
387 typedef unsigned short yytype_uint16
;
389 typedef int yytype_uint16
;
393 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
394 # define YYPTRDIFF_T __PTRDIFF_TYPE__
395 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
396 # elif defined PTRDIFF_MAX
398 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
400 # define YYPTRDIFF_T ptrdiff_t
401 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
403 # define YYPTRDIFF_T long
404 # define YYPTRDIFF_MAXIMUM LONG_MAX
409 # ifdef __SIZE_TYPE__
410 # define YYSIZE_T __SIZE_TYPE__
411 # elif defined size_t
412 # define YYSIZE_T size_t
413 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
414 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
415 # define YYSIZE_T size_t
417 # define YYSIZE_T unsigned
421 #define YYSIZE_MAXIMUM \
422 YY_CAST (YYPTRDIFF_T, \
423 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
424 ? YYPTRDIFF_MAXIMUM \
425 : YY_CAST (YYSIZE_T, -1)))
427 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
430 /* Stored state numbers (used for stacks). */
431 typedef yytype_uint8 yy_state_t
;
433 /* State numbers in computations. */
434 typedef int yy_state_fast_t
;
437 # if defined YYENABLE_NLS && YYENABLE_NLS
439 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
440 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
444 # define YY_(Msgid) Msgid
449 # define N_(Msgid) Msgid
453 #ifndef YY_ATTRIBUTE_PURE
454 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
455 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
457 # define YY_ATTRIBUTE_PURE
461 #ifndef YY_ATTRIBUTE_UNUSED
462 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
463 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
465 # define YY_ATTRIBUTE_UNUSED
469 /* Suppress unused-variable warnings by "using" E. */
470 #if ! defined lint || defined __GNUC__
471 # define YY_USE(E) ((void) (E))
473 # define YY_USE(E) /* empty */
476 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
477 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
478 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
479 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
480 _Pragma ("GCC diagnostic push") \
481 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
483 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
484 _Pragma ("GCC diagnostic push") \
485 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
486 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
488 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
489 _Pragma ("GCC diagnostic pop")
491 # define YY_INITIAL_VALUE(Value) Value
493 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
494 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
495 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
497 #ifndef YY_INITIAL_VALUE
498 # define YY_INITIAL_VALUE(Value) /* Nothing. */
501 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
502 # define YY_IGNORE_USELESS_CAST_BEGIN \
503 _Pragma ("GCC diagnostic push") \
504 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
505 # define YY_IGNORE_USELESS_CAST_END \
506 _Pragma ("GCC diagnostic pop")
508 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
509 # define YY_IGNORE_USELESS_CAST_BEGIN
510 # define YY_IGNORE_USELESS_CAST_END
514 #define YY_ASSERT(E) ((void) (0 && (E)))
518 /* The parser invokes alloca or malloc; define the necessary symbols. */
520 # ifdef YYSTACK_ALLOC
521 /* Pacify GCC's 'empty if-body' warning. */
522 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
523 # ifndef YYSTACK_ALLOC_MAXIMUM
524 /* The OS might guarantee only one guard page at the bottom of the stack,
525 and a page size can be as small as 4096 bytes. So we cannot safely
526 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
527 to allow for a few compiler-allocated temporary stack slots. */
528 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
531 # define YYSTACK_ALLOC YYMALLOC
532 # define YYSTACK_FREE YYFREE
533 # ifndef YYSTACK_ALLOC_MAXIMUM
534 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
536 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
537 && ! ((defined YYMALLOC || defined malloc) \
538 && (defined YYFREE || defined free)))
539 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
540 # ifndef EXIT_SUCCESS
541 # define EXIT_SUCCESS 0
545 # define YYMALLOC malloc
546 # if ! defined malloc && ! defined EXIT_SUCCESS
547 void *malloc (YYSIZE_T
); /* INFRINGES ON USER NAME SPACE */
552 # if ! defined free && ! defined EXIT_SUCCESS
553 void free (void *); /* INFRINGES ON USER NAME SPACE */
557 # define YYCOPY_NEEDED 1
560 #if (! defined yyoverflow \
561 && (! defined __cplusplus \
562 || (defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL \
563 && defined GRAM_STYPE_IS_TRIVIAL && GRAM_STYPE_IS_TRIVIAL)))
565 /* A type that is properly aligned for any stack member. */
568 yy_state_t yyss_alloc
;
573 /* The size of the maximum gap between one aligned stack and the next. */
574 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
576 /* The size of an array large to enough to hold all stacks, each with
578 # define YYSTACK_BYTES(N) \
579 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE) \
580 + YYSIZEOF (YYLTYPE)) \
581 + 2 * YYSTACK_GAP_MAXIMUM)
583 # define YYCOPY_NEEDED 1
585 /* Relocate STACK from its old location to the new one. The
586 local variables YYSIZE and YYSTACKSIZE give the old and new number of
587 elements in the stack, and YYPTR gives the new location of the
588 stack. Advance YYPTR to a properly aligned location for the next
590 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
593 YYPTRDIFF_T yynewbytes; \
594 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
595 Stack = &yyptr->Stack_alloc; \
596 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
597 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
603 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
604 /* Copy COUNT objects from SRC to DST. The source and destination do
607 # if defined __GNUC__ && 1 < __GNUC__
608 # define YYCOPY(Dst, Src, Count) \
609 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
611 # define YYCOPY(Dst, Src, Count) \
615 for (yyi = 0; yyi < (Count); yyi++) \
616 (Dst)[yyi] = (Src)[yyi]; \
621 #endif /* !YYCOPY_NEEDED */
623 /* YYFINAL -- State number of the termination state. */
625 /* YYLAST -- Last index in YYTABLE. */
628 /* YYNTOKENS -- Number of terminals. */
630 /* YYNNTS -- Number of nonterminals. */
632 /* YYNRULES -- Number of rules. */
634 /* YYNSTATES -- Number of states. */
635 #define YYNSTATES 169
637 /* YYMAXUTOK -- Last valid token kind. */
638 #define YYMAXUTOK 315
641 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
642 as returned by yylex, with out-of-bounds checking. */
643 #define YYTRANSLATE(YYX) YY_CAST (yysymbol_kind_t, YYX)
646 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
647 static const yytype_int16 yyrline
[] =
649 0, 310, 310, 319, 320, 324, 325, 331, 335, 340,
650 341, 342, 343, 344, 345, 350, 355, 356, 357, 358,
651 359, 360, 360, 361, 362, 363, 364, 365, 366, 367,
652 368, 372, 373, 382, 383, 387, 398, 402, 406, 414,
653 424, 425, 435, 436, 442, 455, 455, 460, 460, 465,
654 465, 470, 480, 481, 482, 483, 488, 489, 493, 494,
655 499, 500, 504, 505, 509, 510, 511, 524, 533, 537,
656 541, 549, 550, 554, 567, 568, 573, 574, 575, 593,
657 597, 601, 609, 611, 616, 623, 633, 637, 641, 649,
658 655, 668, 669, 675, 676, 677, 684, 684, 692, 693,
659 694, 699, 702, 704, 706, 708, 710, 712, 714, 716,
660 718, 723, 724, 733, 757, 758, 759, 760, 772, 774,
661 798, 803, 804, 809, 817, 818
665 /** Accessing symbol of state STATE. */
666 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
669 /* The user-facing name of the symbol whose (internal) number is
670 YYSYMBOL. No bounds checking. */
671 static const char *yysymbol_name (yysymbol_kind_t yysymbol
) YY_ATTRIBUTE_UNUSED
;
674 yysymbol_name (yysymbol_kind_t yysymbol
)
676 static const char *const yy_sname
[] =
678 N_("end of file"), N_("error"), N_("invalid token"), N_("string"),
679 N_("translatable string"), "%token", "%nterm", "%type", "%destructor",
680 "%printer", "%left", "%right", "%nonassoc", "%precedence", "%prec",
681 "%dprec", "%merge", "%code", "%default-prec", "%define",
682 "%error-verbose", "%expect", "%expect-rr", "%file-prefix", "%<flag>",
683 "%glr-parser", "%header", "%initial-action", "%language", "%name-prefix",
684 "%no-default-prec", "%no-lines", "%nondeterministic-parser", "%output",
685 "%pure-parser", "%require", "%skeleton", "%start", "%token-table",
686 "%verbose", "%yacc", "{...}", "%?{...}", N_("[identifier]"),
687 N_("character literal"), ":", N_("epilogue"), "=", N_("identifier"),
688 N_("identifier:"), "%%", "|", "%{...%}", ";", N_("<tag>"), "<*>", "<>",
689 N_("integer literal"), "%param", "%union", "%empty", "$accept", "input",
690 "prologue_declarations", "prologue_declaration", "$@1", "params",
691 "grammar_declaration", "code_props_type", "union_name",
692 "symbol_declaration", "$@2", "$@3", "$@4", "precedence_declarator",
693 "string.opt", "tag.opt", "generic_symlist", "generic_symlist_item",
694 "tag", "nterm_decls", "token_decls", "token_decl.1", "token_decl",
695 "int.opt", "alias", "token_decls_for_prec", "token_decl_for_prec.1",
696 "token_decl_for_prec", "symbol_decls", "symbols.1", "grammar",
697 "rules_or_grammar_declaration", "rules", "$@5", "rhses.1", "rhs",
698 "named_ref.opt", "variable", "value", "id", "id_colon", "symbol",
699 "string_as_id", "epilogue.opt", YY_NULLPTR
701 /* YYTRANSLATABLE[SYMBOL-NUM] -- Whether YY_SNAME[SYMBOL-NUM] is
702 internationalizable. */
703 static yytype_int8 yytranslatable
[] =
705 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
706 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
707 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
708 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
709 0, 0, 0, 1, 1, 0, 1, 0, 1, 1,
710 0, 0, 0, 0, 1, 0, 0, 1, 0, 0,
713 return (yysymbol
< YYNTOKENS
&& yytranslatable
[yysymbol
]
714 ? _(yy_sname
[yysymbol
])
715 : yy_sname
[yysymbol
]);
720 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
721 (internal) symbol number NUM (which must be that of a token). */
722 static const yytype_int16 yytoknum
[] =
724 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
725 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
726 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
727 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
728 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
729 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
734 #define YYPACT_NINF (-148)
736 #define yypact_value_is_default(Yyn) \
737 ((Yyn) == YYPACT_NINF)
739 #define YYTABLE_NINF (-125)
741 #define yytable_value_is_error(Yyn) \
744 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
746 static const yytype_int16 yypact
[] =
748 -148, 13, 113, -148, -27, -148, -148, -148, -148, -148,
749 -148, -148, -148, -148, -33, -148, -21, -148, -29, -26,
750 26, -148, -148, 27, -9, 30, 31, -148, -148, -148,
751 32, -148, 34, 36, 112, -148, -148, -148, 168, -148,
752 -148, -148, -3, -148, -148, 19, -148, 7, -148, -37,
753 -37, 164, -148, 33, -148, 2, -148, -148, -148, -148,
754 -148, -148, -148, -148, -148, -148, -148, -148, -148, -148,
755 112, -148, -148, -148, 9, -148, 20, 58, -148, -148,
756 37, 38, -148, 40, 155, 112, 35, 112, -148, 41,
757 -148, -28, 43, -28, -148, 41, -148, 43, 112, 46,
758 112, -148, -148, -148, -148, -148, -148, -148, -148, 44,
759 -148, -148, -148, -148, -148, 50, -148, -148, -148, -148,
760 155, -148, -148, -148, 112, 112, -148, -148, -148, -28,
761 -28, -148, 21, 112, 112, -148, 59, -148, -148, 112,
762 -28, -148, -148, -148, 112, -148, -30, 180, -148, -148,
763 112, 48, 49, 52, 53, -148, -148, -148, 65, 37,
764 180, -148, -148, -148, -148, -148, 37, -148, -148
767 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
768 Performed when YYTABLE does not specify something else to do. Zero
769 means the default is an error. */
770 static const yytype_int8 yydefact
[] =
772 3, 0, 0, 1, 0, 47, 45, 49, 40, 41,
773 52, 53, 54, 55, 0, 36, 0, 10, 0, 0,
774 0, 7, 14, 56, 0, 0, 0, 37, 18, 19,
775 0, 23, 0, 0, 0, 26, 27, 28, 0, 6,
776 30, 21, 42, 4, 5, 0, 33, 0, 29, 0,
777 0, 0, 38, 0, 113, 114, 11, 12, 13, 57,
778 9, 15, 16, 17, 20, 24, 25, 123, 119, 118,
779 34, 121, 89, 122, 0, 120, 0, 0, 91, 93,
780 111, 0, 43, 0, 0, 0, 51, 79, 82, 74,
781 85, 0, 48, 68, 71, 74, 46, 67, 0, 50,
782 86, 39, 116, 117, 115, 8, 90, 95, 94, 0,
783 92, 2, 112, 96, 32, 22, 44, 64, 65, 66,
784 35, 60, 63, 62, 80, 0, 83, 75, 84, 69,
785 0, 72, 76, 87, 0, 125, 0, 31, 61, 81,
786 70, 78, 73, 77, 88, 101, 97, 98, 101, 100,
787 0, 0, 0, 0, 0, 104, 59, 105, 0, 111,
788 99, 106, 107, 108, 109, 110, 111, 102, 103
791 /* YYPGOTO[NTERM-NUM]. */
792 static const yytype_int16 yypgoto
[] =
794 -148, -148, -148, -148, -148, -148, 109, -148, -148, -148,
795 -148, -148, -148, -148, -148, -148, -148, -7, -148, -148,
796 66, -73, -87, 60, -148, -148, -71, -83, -148, -50,
797 -148, 51, -148, -148, -148, -19, -147, -148, -148, -47,
801 /* YYDEFGOTO[NTERM-NUM]. */
802 static const yytype_uint8 yydefgoto
[] =
804 0, 1, 2, 43, 81, 115, 76, 45, 83, 46,
805 50, 49, 51, 47, 60, 158, 120, 121, 122, 96,
806 92, 93, 94, 128, 142, 86, 87, 88, 99, 70,
807 77, 78, 79, 136, 146, 147, 113, 55, 105, 71,
811 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
812 positive, shift that token. If negative, reduce the rule whose
813 number is the opposite. If YYTABLE_NINF, syntax error. */
814 static const yytype_int16 yytable
[] =
816 89, 100, 95, 95, 126, 102, 131, 68, 52, 90,
817 67, 69, 167, 3, 124, 53, 68, 91, 129, 168,
818 69, 148, 106, 149, 67, 141, 48, 54, 56, 58,
819 59, 57, 61, 62, 63, 64, 123, 65, 89, 66,
820 89, 126, 131, 103, 95, 82, 95, 90, 133, 90,
821 104, 68, 106, 131, 139, 69, 126, 140, -124, 74,
822 84, 85, 107, 5, 6, 7, 8, 9, 10, 11,
823 12, 13, 123, 108, 101, 14, 15, 89, 89, 114,
824 112, 116, 95, 95, 144, 106, 90, 90, 27, 125,
825 135, 137, 89, 95, 143, 34, 106, 130, 127, 159,
826 134, 90, 161, 163, 145, 162, 166, 75, 109, 164,
827 165, 44, 159, 138, 4, 67, 97, 42, 5, 6,
828 7, 8, 9, 10, 11, 12, 13, 0, 110, 160,
829 14, 15, 16, 17, 18, 19, 20, 21, 22, 23,
830 24, 25, 26, 27, 28, 29, 30, 31, 32, 33,
831 34, 35, 36, 37, 0, 132, 68, 0, 67, 0,
832 69, 0, 0, 38, 0, 39, 40, 67, 0, 74,
833 0, 41, 42, 5, 6, 7, 8, 9, 10, 11,
834 12, 13, 0, 67, 0, 14, 15, 0, 0, 0,
835 0, 0, 0, 0, 150, 151, 152, 0, 27, 68,
836 0, 153, 154, 69, 0, 34, 0, 0, 68, 117,
837 118, 119, 69, 0, 0, 0, 0, 75, 98, 0,
838 0, -58, 155, 0, 68, 0, 0, 42, 69, 0,
839 0, 0, 0, 0, 156, 0, 0, 0, 0, 0,
843 static const yytype_int16 yycheck
[] =
845 47, 51, 49, 50, 87, 3, 93, 44, 41, 47,
846 3, 48, 159, 0, 85, 48, 44, 54, 91, 166,
847 48, 51, 70, 53, 3, 4, 53, 48, 57, 3,
848 3, 57, 41, 3, 3, 3, 84, 3, 85, 3,
849 87, 124, 129, 41, 91, 48, 93, 85, 98, 87,
850 48, 44, 100, 140, 125, 48, 139, 130, 0, 1,
851 41, 54, 53, 5, 6, 7, 8, 9, 10, 11,
852 12, 13, 120, 53, 41, 17, 18, 124, 125, 41,
853 43, 41, 129, 130, 134, 133, 124, 125, 30, 54,
854 46, 41, 139, 140, 132, 37, 144, 54, 57, 147,
855 54, 139, 150, 54, 45, 57, 41, 49, 50, 57,
856 57, 2, 160, 120, 1, 3, 50, 59, 5, 6,
857 7, 8, 9, 10, 11, 12, 13, -1, 77, 148,
858 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
859 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
860 37, 38, 39, 40, -1, 95, 44, -1, 3, -1,
861 48, -1, -1, 50, -1, 52, 53, 3, -1, 1,
862 -1, 58, 59, 5, 6, 7, 8, 9, 10, 11,
863 12, 13, -1, 3, -1, 17, 18, -1, -1, -1,
864 -1, -1, -1, -1, 14, 15, 16, -1, 30, 44,
865 -1, 21, 22, 48, -1, 37, -1, -1, 44, 54,
866 55, 56, 48, -1, -1, -1, -1, 49, 54, -1,
867 -1, 41, 42, -1, 44, -1, -1, 59, 48, -1,
868 -1, -1, -1, -1, 54, -1, -1, -1, -1, -1,
872 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
874 static const yytype_int8 yystos
[] =
876 0, 62, 63, 0, 1, 5, 6, 7, 8, 9,
877 10, 11, 12, 13, 17, 18, 19, 20, 21, 22,
878 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
879 33, 34, 35, 36, 37, 38, 39, 40, 50, 52,
880 53, 58, 59, 64, 67, 68, 70, 74, 53, 72,
881 71, 73, 41, 48, 48, 98, 57, 57, 3, 3,
882 75, 41, 3, 3, 3, 3, 3, 3, 44, 48,
883 90, 100, 102, 103, 1, 49, 67, 91, 92, 93,
884 101, 65, 48, 69, 41, 54, 86, 87, 88, 100,
885 103, 54, 81, 82, 83, 100, 80, 81, 54, 89,
886 90, 41, 3, 41, 48, 99, 102, 53, 53, 50,
887 92, 104, 43, 97, 41, 66, 41, 54, 55, 56,
888 77, 78, 79, 102, 87, 54, 88, 57, 84, 82,
889 54, 83, 84, 90, 54, 46, 94, 41, 78, 87,
890 82, 4, 85, 103, 90, 45, 95, 96, 51, 53,
891 14, 15, 16, 21, 22, 42, 54, 60, 76, 102,
892 96, 102, 57, 54, 57, 57, 41, 97, 97
895 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
896 static const yytype_int8 yyr1
[] =
898 0, 61, 62, 63, 63, 64, 64, 64, 64, 64,
899 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
900 64, 65, 64, 64, 64, 64, 64, 64, 64, 64,
901 64, 66, 66, 67, 67, 67, 67, 67, 67, 67,
902 68, 68, 69, 69, 67, 71, 70, 72, 70, 73,
903 70, 70, 74, 74, 74, 74, 75, 75, 76, 76,
904 77, 77, 78, 78, 79, 79, 79, 80, 81, 81,
905 81, 82, 82, 83, 84, 84, 85, 85, 85, 86,
906 86, 86, 87, 87, 88, 88, 89, 89, 89, 90,
907 90, 91, 91, 92, 92, 92, 94, 93, 95, 95,
908 95, 96, 96, 96, 96, 96, 96, 96, 96, 96,
909 96, 97, 97, 98, 99, 99, 99, 99, 100, 100,
910 101, 102, 102, 103, 104, 104
913 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
914 static const yytype_int8 yyr2
[] =
916 0, 2, 4, 0, 2, 1, 1, 1, 3, 2,
917 1, 2, 2, 2, 1, 2, 2, 2, 1, 1,
918 2, 0, 3, 1, 2, 2, 1, 1, 1, 2,
919 1, 2, 1, 1, 2, 3, 1, 1, 2, 3,
920 1, 1, 0, 1, 3, 0, 3, 0, 3, 0,
921 3, 2, 1, 1, 1, 1, 0, 1, 0, 1,
922 1, 2, 1, 1, 1, 1, 1, 1, 1, 2,
923 3, 1, 2, 3, 0, 1, 0, 1, 1, 1,
924 2, 3, 1, 2, 2, 1, 1, 2, 3, 1,
925 2, 1, 2, 1, 2, 2, 0, 5, 1, 3,
926 2, 0, 3, 4, 2, 2, 3, 3, 3, 3,
927 3, 0, 1, 1, 0, 1, 1, 1, 1, 1,
932 enum { YYENOMEM
= -2 };
934 #define yyerrok (yyerrstatus = 0)
935 #define yyclearin (yychar = GRAM_EMPTY)
937 #define YYACCEPT goto yyacceptlab
938 #define YYABORT goto yyabortlab
939 #define YYERROR goto yyerrorlab
940 #define YYNOMEM goto yyexhaustedlab
943 #define YYRECOVERING() (!!yyerrstatus)
945 #define YYBACKUP(Token, Value) \
947 if (yychar == GRAM_EMPTY) \
951 YYPOPSTACK (yylen); \
953 YY_LAC_DISCARD ("YYBACKUP"); \
958 yyerror (&yylloc, YY_("syntax error: cannot back up")); \
963 /* Backward compatibility with an undocumented macro.
964 Use GRAM_error or GRAM_UNDEF. */
965 #define YYERRCODE GRAM_UNDEF
967 /* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
968 If N is 0, then set CURRENT to the empty location which ends
969 the previous symbol: RHS[0] (always defined). */
971 #ifndef YYLLOC_DEFAULT
972 # define YYLLOC_DEFAULT(Current, Rhs, N) \
976 (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
977 (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
978 (Current).last_line = YYRHSLOC (Rhs, N).last_line; \
979 (Current).last_column = YYRHSLOC (Rhs, N).last_column; \
983 (Current).first_line = (Current).last_line = \
984 YYRHSLOC (Rhs, 0).last_line; \
985 (Current).first_column = (Current).last_column = \
986 YYRHSLOC (Rhs, 0).last_column; \
991 #define YYRHSLOC(Rhs, K) ((Rhs)[K])
994 /* Enable debugging if requested. */
998 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
999 # define YYFPRINTF fprintf
1002 # define YYDPRINTF(Args) \
1009 /* YY_LOCATION_PRINT -- Print the location on the stream.
1010 This macro was not mandated originally: define only if we know
1011 we won't break user code: when these are the locations we know. */
1013 # ifndef YY_LOCATION_PRINT
1014 # if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
1016 /* Print *YYLOCP on YYO. Private, do not rely on its existence. */
1020 yy_location_print_ (FILE *yyo
, YYLTYPE
const * const yylocp
)
1023 int end_col
= 0 != yylocp
->last_column
? yylocp
->last_column
- 1 : 0;
1024 if (0 <= yylocp
->first_line
)
1026 res
+= YYFPRINTF (yyo
, "%d", yylocp
->first_line
);
1027 if (0 <= yylocp
->first_column
)
1028 res
+= YYFPRINTF (yyo
, ".%d", yylocp
->first_column
);
1030 if (0 <= yylocp
->last_line
)
1032 if (yylocp
->first_line
< yylocp
->last_line
)
1034 res
+= YYFPRINTF (yyo
, "-%d", yylocp
->last_line
);
1036 res
+= YYFPRINTF (yyo
, ".%d", end_col
);
1038 else if (0 <= end_col
&& yylocp
->first_column
< end_col
)
1039 res
+= YYFPRINTF (yyo
, "-%d", end_col
);
1044 # define YY_LOCATION_PRINT(File, Loc) \
1045 yy_location_print_ (File, &(Loc))
1048 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
1050 # endif /* !defined YY_LOCATION_PRINT */
1053 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
1057 YYFPRINTF (stderr, "%s ", Title); \
1058 yy_symbol_print (stderr, \
1059 Kind, Value, Location); \
1060 YYFPRINTF (stderr, "\n"); \
1065 /*-----------------------------------.
1066 | Print this symbol's value on YYO. |
1067 `-----------------------------------*/
1070 yy_symbol_value_print (FILE *yyo
,
1071 yysymbol_kind_t yykind
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
)
1073 FILE *yyoutput
= yyo
;
1075 YY_USE (yylocationp
);
1079 if (yykind
< YYNTOKENS
)
1080 YYPRINT (yyo
, yytoknum
[yykind
], *yyvaluep
);
1082 /* "%code pre-printer" blocks. */
1085 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1088 case YYSYMBOL_STRING
: /* "string" */
1089 { fputs (((*yyvaluep
).STRING
), yyo
); }
1092 case YYSYMBOL_TSTRING
: /* "translatable string" */
1093 { fputs (((*yyvaluep
).TSTRING
), yyo
); }
1096 case YYSYMBOL_PERCENT_ERROR_VERBOSE
: /* "%error-verbose" */
1097 { fputs (((*yyvaluep
).PERCENT_ERROR_VERBOSE
), yyo
); }
1100 case YYSYMBOL_PERCENT_FILE_PREFIX
: /* "%file-prefix" */
1101 { fputs (((*yyvaluep
).PERCENT_FILE_PREFIX
), yyo
); }
1104 case YYSYMBOL_PERCENT_FLAG
: /* "%<flag>" */
1105 { fprintf (yyo
, "%%%s", ((*yyvaluep
).PERCENT_FLAG
)); }
1108 case YYSYMBOL_PERCENT_NAME_PREFIX
: /* "%name-prefix" */
1109 { fputs (((*yyvaluep
).PERCENT_NAME_PREFIX
), yyo
); }
1112 case YYSYMBOL_PERCENT_PURE_PARSER
: /* "%pure-parser" */
1113 { fputs (((*yyvaluep
).PERCENT_PURE_PARSER
), yyo
); }
1116 case YYSYMBOL_BRACED_CODE
: /* "{...}" */
1117 { fputs (((*yyvaluep
).BRACED_CODE
), yyo
); }
1120 case YYSYMBOL_BRACED_PREDICATE
: /* "%?{...}" */
1121 { fputs (((*yyvaluep
).BRACED_PREDICATE
), yyo
); }
1124 case YYSYMBOL_BRACKETED_ID
: /* "[identifier]" */
1125 { fprintf (yyo
, "[%s]", ((*yyvaluep
).BRACKETED_ID
)); }
1128 case YYSYMBOL_CHAR_LITERAL
: /* "character literal" */
1129 { fputs (char_name (((*yyvaluep
).CHAR_LITERAL
)), yyo
); }
1132 case YYSYMBOL_EPILOGUE
: /* "epilogue" */
1133 { fputs (((*yyvaluep
).EPILOGUE
), yyo
); }
1136 case YYSYMBOL_ID
: /* "identifier" */
1137 { fputs (((*yyvaluep
).ID
), yyo
); }
1140 case YYSYMBOL_ID_COLON
: /* "identifier:" */
1141 { fprintf (yyo
, "%s:", ((*yyvaluep
).ID_COLON
)); }
1144 case YYSYMBOL_PROLOGUE
: /* "%{...%}" */
1145 { fputs (((*yyvaluep
).PROLOGUE
), yyo
); }
1148 case YYSYMBOL_TAG
: /* "<tag>" */
1149 { fprintf (yyo
, "<%s>", ((*yyvaluep
).TAG
)); }
1152 case YYSYMBOL_INT_LITERAL
: /* "integer literal" */
1153 { fprintf (yyo
, "%d", ((*yyvaluep
).INT_LITERAL
)); }
1156 case YYSYMBOL_PERCENT_PARAM
: /* "%param" */
1158 switch (((*yyvaluep
).PERCENT_PARAM
))
1160 #define CASE(In, Out) \
1161 case param_ ## In: fputs ("%" #Out, yyo); break
1162 CASE (lex
, lex
-param
);
1163 CASE (parse
, parse
-param
);
1166 case param_none
: aver (false); break;
1171 case YYSYMBOL_code_props_type
: /* code_props_type */
1172 { fprintf (yyo
, "%s", code_props_type_string (((*yyvaluep
).code_props_type
))); }
1175 case YYSYMBOL_75_string_opt
: /* string.opt */
1176 { fputs (((*yyvaluep
).yykind_75
), yyo
); }
1179 case YYSYMBOL_76_tag_opt
: /* tag.opt */
1180 { fputs (((*yyvaluep
).yykind_76
), yyo
); }
1183 case YYSYMBOL_generic_symlist
: /* generic_symlist */
1184 { symbol_list_syms_print (((*yyvaluep
).generic_symlist
), yyo
); }
1187 case YYSYMBOL_generic_symlist_item
: /* generic_symlist_item */
1188 { symbol_list_syms_print (((*yyvaluep
).generic_symlist_item
), yyo
); }
1191 case YYSYMBOL_tag
: /* tag */
1192 { fprintf (yyo
, "<%s>", ((*yyvaluep
).tag
)); }
1195 case YYSYMBOL_nterm_decls
: /* nterm_decls */
1196 { symbol_list_syms_print (((*yyvaluep
).nterm_decls
), yyo
); }
1199 case YYSYMBOL_token_decls
: /* token_decls */
1200 { symbol_list_syms_print (((*yyvaluep
).token_decls
), yyo
); }
1203 case YYSYMBOL_82_token_decl_1
: /* token_decl.1 */
1204 { symbol_list_syms_print (((*yyvaluep
).yykind_82
), yyo
); }
1207 case YYSYMBOL_token_decl
: /* token_decl */
1208 { fprintf (yyo
, "%s", ((*yyvaluep
).token_decl
) ? ((*yyvaluep
).token_decl
)->tag
: "<NULL>"); }
1211 case YYSYMBOL_84_int_opt
: /* int.opt */
1212 { fprintf (yyo
, "%d", ((*yyvaluep
).yykind_84
)); }
1215 case YYSYMBOL_alias
: /* alias */
1216 { fprintf (yyo
, "%s", ((*yyvaluep
).alias
) ? ((*yyvaluep
).alias
)->tag
: "<NULL>"); }
1219 case YYSYMBOL_token_decls_for_prec
: /* token_decls_for_prec */
1220 { symbol_list_syms_print (((*yyvaluep
).token_decls_for_prec
), yyo
); }
1223 case YYSYMBOL_87_token_decl_for_prec_1
: /* token_decl_for_prec.1 */
1224 { symbol_list_syms_print (((*yyvaluep
).yykind_87
), yyo
); }
1227 case YYSYMBOL_token_decl_for_prec
: /* token_decl_for_prec */
1228 { fprintf (yyo
, "%s", ((*yyvaluep
).token_decl_for_prec
) ? ((*yyvaluep
).token_decl_for_prec
)->tag
: "<NULL>"); }
1231 case YYSYMBOL_symbol_decls
: /* symbol_decls */
1232 { symbol_list_syms_print (((*yyvaluep
).symbol_decls
), yyo
); }
1235 case YYSYMBOL_90_symbols_1
: /* symbols.1 */
1236 { symbol_list_syms_print (((*yyvaluep
).yykind_90
), yyo
); }
1239 case YYSYMBOL_variable
: /* variable */
1240 { fputs (((*yyvaluep
).variable
), yyo
); }
1243 case YYSYMBOL_value
: /* value */
1245 switch (((*yyvaluep
).value
).kind
)
1247 case muscle_code
: fprintf (yyo
, "{%s}", ((*yyvaluep
).value
).chars
); break;
1248 case muscle_keyword
: fprintf (yyo
, "%s", ((*yyvaluep
).value
).chars
); break;
1249 case muscle_string
: fprintf (yyo
, "\"%s\"", ((*yyvaluep
).value
).chars
); break;
1254 case YYSYMBOL_id
: /* id */
1255 { fprintf (yyo
, "%s", ((*yyvaluep
).id
) ? ((*yyvaluep
).id
)->tag
: "<NULL>"); }
1258 case YYSYMBOL_id_colon
: /* id_colon */
1259 { fprintf (yyo
, "%s:", ((*yyvaluep
).id_colon
)->tag
); }
1262 case YYSYMBOL_symbol
: /* symbol */
1263 { fprintf (yyo
, "%s", ((*yyvaluep
).symbol
) ? ((*yyvaluep
).symbol
)->tag
: "<NULL>"); }
1266 case YYSYMBOL_string_as_id
: /* string_as_id */
1267 { fprintf (yyo
, "%s", ((*yyvaluep
).string_as_id
) ? ((*yyvaluep
).string_as_id
)->tag
: "<NULL>"); }
1273 YY_IGNORE_MAYBE_UNINITIALIZED_END
1274 /* "%code post-printer" blocks. */
1280 /*---------------------------.
1281 | Print this symbol on YYO. |
1282 `---------------------------*/
1285 yy_symbol_print (FILE *yyo
,
1286 yysymbol_kind_t yykind
, YYSTYPE
const * const yyvaluep
, YYLTYPE
const * const yylocationp
)
1288 YYFPRINTF (yyo
, "%s %s (",
1289 yykind
< YYNTOKENS
? "token" : "nterm", yysymbol_name (yykind
));
1291 YY_LOCATION_PRINT (yyo
, *yylocationp
);
1292 YYFPRINTF (yyo
, ": ");
1293 yy_symbol_value_print (yyo
, yykind
, yyvaluep
, yylocationp
);
1294 YYFPRINTF (yyo
, ")");
1297 /*------------------------------------------------------------------.
1298 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
1300 `------------------------------------------------------------------*/
1303 yy_stack_print (yy_state_t
*yybottom
, yy_state_t
*yytop
)
1305 YYFPRINTF (stderr
, "Stack now");
1306 for (; yybottom
<= yytop
; yybottom
++)
1308 int yybot
= *yybottom
;
1309 YYFPRINTF (stderr
, " %d", yybot
);
1311 YYFPRINTF (stderr
, "\n");
1314 # define YY_STACK_PRINT(Bottom, Top) \
1317 yy_stack_print ((Bottom), (Top)); \
1321 /*------------------------------------------------.
1322 | Report that the YYRULE is going to be reduced. |
1323 `------------------------------------------------*/
1326 yy_reduce_print (yy_state_t
*yyssp
, YYSTYPE
*yyvsp
, YYLTYPE
*yylsp
,
1329 int yylno
= yyrline
[yyrule
];
1330 int yynrhs
= yyr2
[yyrule
];
1332 YYFPRINTF (stderr
, "Reducing stack by rule %d (line %d):\n",
1334 /* The symbols being reduced. */
1335 for (yyi
= 0; yyi
< yynrhs
; yyi
++)
1337 YYFPRINTF (stderr
, " $%d = ", yyi
+ 1);
1338 yy_symbol_print (stderr
,
1339 YY_ACCESSING_SYMBOL (+yyssp
[yyi
+ 1 - yynrhs
]),
1340 &yyvsp
[(yyi
+ 1) - (yynrhs
)],
1341 &(yylsp
[(yyi
+ 1) - (yynrhs
)]));
1342 YYFPRINTF (stderr
, "\n");
1346 # define YY_REDUCE_PRINT(Rule) \
1349 yy_reduce_print (yyssp, yyvsp, yylsp, Rule); \
1352 /* Nonzero means print parse trace. It is left uninitialized so that
1353 multiple parsers can coexist. */
1355 #else /* !GRAM_DEBUG */
1356 # define YYDPRINTF(Args) ((void) 0)
1357 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
1358 # define YY_STACK_PRINT(Bottom, Top)
1359 # define YY_REDUCE_PRINT(Rule)
1360 #endif /* !GRAM_DEBUG */
1363 /* YYINITDEPTH -- initial size of the parser's stacks. */
1365 # define YYINITDEPTH 200
1368 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
1369 if the built-in stack extension method is used).
1371 Do not make this value too large; the results are undefined if
1372 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1373 evaluated with infinite-precision integer arithmetic. */
1376 # define YYMAXDEPTH 10000
1380 /* Given a state stack such that *YYBOTTOM is its bottom, such that
1381 *YYTOP is either its top or is YYTOP_EMPTY to indicate an empty
1382 stack, and such that *YYCAPACITY is the maximum number of elements it
1383 can hold without a reallocation, make sure there is enough room to
1384 store YYADD more elements. If not, allocate a new stack using
1385 YYSTACK_ALLOC, copy the existing elements, and adjust *YYBOTTOM,
1386 *YYTOP, and *YYCAPACITY to reflect the new capacity and memory
1387 location. If *YYBOTTOM != YYBOTTOM_NO_FREE, then free the old stack
1388 using YYSTACK_FREE. Return 0 if successful or if no reallocation is
1389 required. Return YYENOMEM if memory is exhausted. */
1391 yy_lac_stack_realloc (YYPTRDIFF_T
*yycapacity
, YYPTRDIFF_T yyadd
,
1393 char const *yydebug_prefix
,
1394 char const *yydebug_suffix
,
1396 yy_state_t
**yybottom
,
1397 yy_state_t
*yybottom_no_free
,
1398 yy_state_t
**yytop
, yy_state_t
*yytop_empty
)
1400 YYPTRDIFF_T yysize_old
=
1401 *yytop
== yytop_empty
? 0 : *yytop
- *yybottom
+ 1;
1402 YYPTRDIFF_T yysize_new
= yysize_old
+ yyadd
;
1403 if (*yycapacity
< yysize_new
)
1405 YYPTRDIFF_T yyalloc
= 2 * yysize_new
;
1406 yy_state_t
*yybottom_new
;
1407 /* Use YYMAXDEPTH for maximum stack size given that the stack
1408 should never need to grow larger than the main state stack
1409 needs to grow without LAC. */
1410 if (YYMAXDEPTH
< yysize_new
)
1412 YYDPRINTF ((stderr
, "%smax size exceeded%s", yydebug_prefix
,
1416 if (YYMAXDEPTH
< yyalloc
)
1417 yyalloc
= YYMAXDEPTH
;
1419 YY_CAST (yy_state_t
*,
1420 YYSTACK_ALLOC (YY_CAST (YYSIZE_T
,
1421 yyalloc
* YYSIZEOF (*yybottom_new
))));
1424 YYDPRINTF ((stderr
, "%srealloc failed%s", yydebug_prefix
,
1428 if (*yytop
!= yytop_empty
)
1430 YYCOPY (yybottom_new
, *yybottom
, yysize_old
);
1431 *yytop
= yybottom_new
+ (yysize_old
- 1);
1433 if (*yybottom
!= yybottom_no_free
)
1434 YYSTACK_FREE (*yybottom
);
1435 *yybottom
= yybottom_new
;
1436 *yycapacity
= yyalloc
;
1441 /* Establish the initial context for the current lookahead if no initial
1442 context is currently established.
1444 We define a context as a snapshot of the parser stacks. We define
1445 the initial context for a lookahead as the context in which the
1446 parser initially examines that lookahead in order to select a
1447 syntactic action. Thus, if the lookahead eventually proves
1448 syntactically unacceptable (possibly in a later context reached via a
1449 series of reductions), the initial context can be used to determine
1450 the exact set of tokens that would be syntactically acceptable in the
1451 lookahead's place. Moreover, it is the context after which any
1452 further semantic actions would be erroneous because they would be
1453 determined by a syntactically unacceptable token.
1455 YY_LAC_ESTABLISH should be invoked when a reduction is about to be
1456 performed in an inconsistent state (which, for the purposes of LAC,
1457 includes consistent states that don't know they're consistent because
1458 their default reductions have been disabled). Iff there is a
1459 lookahead token, it should also be invoked before reporting a syntax
1460 error. This latter case is for the sake of the debugging output.
1462 For parse.lac=full, the implementation of YY_LAC_ESTABLISH is as
1463 follows. If no initial context is currently established for the
1464 current lookahead, then check if that lookahead can eventually be
1465 shifted if syntactic actions continue from the current context.
1466 Report a syntax error if it cannot. */
1467 #define YY_LAC_ESTABLISH \
1469 if (!yy_lac_established) \
1471 YYDPRINTF ((stderr, \
1472 "LAC: initial context established for %s\n", \
1473 yysymbol_name (yytoken))); \
1474 yy_lac_established = 1; \
1475 switch (yy_lac (yyesa, &yyes, &yyes_capacity, yyssp, yytoken)) \
1485 /* Discard any previous initial lookahead context because of Event,
1486 which may be a lookahead change or an invalidation of the currently
1487 established initial context for the current lookahead.
1489 The most common example of a lookahead change is a shift. An example
1490 of both cases is syntax error recovery. That is, a syntax error
1491 occurs when the lookahead is syntactically erroneous for the
1492 currently established initial context, so error recovery manipulates
1493 the parser stacks to try to find a new initial context in which the
1494 current lookahead is syntactically acceptable. If it fails to find
1495 such a context, it discards the lookahead. */
1497 # define YY_LAC_DISCARD(Event) \
1499 if (yy_lac_established) \
1501 YYDPRINTF ((stderr, "LAC: initial context discarded due to " \
1503 yy_lac_established = 0; \
1507 # define YY_LAC_DISCARD(Event) yy_lac_established = 0
1510 /* Given the stack whose top is *YYSSP, return 0 iff YYTOKEN can
1511 eventually (after perhaps some reductions) be shifted, return 1 if
1512 not, or return YYENOMEM if memory is exhausted. As preconditions and
1513 postconditions: *YYES_CAPACITY is the allocated size of the array to
1514 which *YYES points, and either *YYES = YYESA or *YYES points to an
1515 array allocated with YYSTACK_ALLOC. yy_lac may overwrite the
1516 contents of either array, alter *YYES and *YYES_CAPACITY, and free
1517 any old *YYES other than YYESA. */
1519 yy_lac (yy_state_t
*yyesa
, yy_state_t
**yyes
,
1520 YYPTRDIFF_T
*yyes_capacity
, yy_state_t
*yyssp
, yysymbol_kind_t yytoken
)
1522 yy_state_t
*yyes_prev
= yyssp
;
1523 yy_state_t
*yyesp
= yyes_prev
;
1524 /* Reduce until we encounter a shift and thereby accept the token. */
1525 YYDPRINTF ((stderr
, "LAC: checking lookahead %s:", yysymbol_name (yytoken
)));
1526 if (yytoken
== YYSYMBOL_YYUNDEF
)
1528 YYDPRINTF ((stderr
, " Always Err\n"));
1533 int yyrule
= yypact
[+*yyesp
];
1534 if (yypact_value_is_default (yyrule
)
1535 || (yyrule
+= yytoken
) < 0 || YYLAST
< yyrule
1536 || yycheck
[yyrule
] != yytoken
)
1538 /* Use the default action. */
1539 yyrule
= yydefact
[+*yyesp
];
1542 YYDPRINTF ((stderr
, " Err\n"));
1548 /* Use the action from yytable. */
1549 yyrule
= yytable
[yyrule
];
1550 if (yytable_value_is_error (yyrule
))
1552 YYDPRINTF ((stderr
, " Err\n"));
1557 YYDPRINTF ((stderr
, " S%d\n", yyrule
));
1562 /* By now we know we have to simulate a reduce. */
1563 YYDPRINTF ((stderr
, " R%d", yyrule
- 1));
1565 /* Pop the corresponding number of values from the stack. */
1566 YYPTRDIFF_T yylen
= yyr2
[yyrule
];
1567 /* First pop from the LAC stack as many tokens as possible. */
1568 if (yyesp
!= yyes_prev
)
1570 YYPTRDIFF_T yysize
= yyesp
- *yyes
+ 1;
1582 /* Only afterwards look at the main stack. */
1584 yyesp
= yyes_prev
-= yylen
;
1586 /* Push the resulting state of the reduction. */
1588 yy_state_fast_t yystate
;
1590 const int yylhs
= yyr1
[yyrule
] - YYNTOKENS
;
1591 const int yyi
= yypgoto
[yylhs
] + *yyesp
;
1592 yystate
= (0 <= yyi
&& yyi
<= YYLAST
&& yycheck
[yyi
] == *yyesp
1594 : yydefgoto
[yylhs
]);
1596 if (yyesp
== yyes_prev
)
1599 YY_IGNORE_USELESS_CAST_BEGIN
1600 *yyesp
= YY_CAST (yy_state_t
, yystate
);
1601 YY_IGNORE_USELESS_CAST_END
1605 if (yy_lac_stack_realloc (yyes_capacity
, 1,
1609 yyes
, yyesa
, &yyesp
, yyes_prev
))
1611 YYDPRINTF ((stderr
, "\n"));
1614 YY_IGNORE_USELESS_CAST_BEGIN
1615 *++yyesp
= YY_CAST (yy_state_t
, yystate
);
1616 YY_IGNORE_USELESS_CAST_END
1618 YYDPRINTF ((stderr
, " G%d", yystate
));
1623 /* Context of a parse error. */
1629 YYPTRDIFF_T
*yyes_capacity
;
1630 yysymbol_kind_t yytoken
;
1634 /* Put in YYARG at most YYARGN of the expected tokens given the
1635 current YYCTX, and return the number of tokens stored in YYARG. If
1636 YYARG is null, return the number of expected tokens (guaranteed to
1637 be less than YYNTOKENS). Return YYENOMEM on memory exhaustion.
1638 Return 0 if there are more than YYARGN expected tokens, yet fill
1639 YYARG up to YYARGN. */
1641 yypcontext_expected_tokens (const yypcontext_t
*yyctx
,
1642 yysymbol_kind_t yyarg
[], int yyargn
)
1644 /* Actual size of YYARG. */
1648 for (yyx
= 0; yyx
< YYNTOKENS
; ++yyx
)
1650 yysymbol_kind_t yysym
= YY_CAST (yysymbol_kind_t
, yyx
);
1651 if (yysym
!= YYSYMBOL_YYerror
&& yysym
!= YYSYMBOL_YYUNDEF
)
1652 switch (yy_lac (yyctx
->yyesa
, yyctx
->yyes
, yyctx
->yyes_capacity
, yyctx
->yyssp
, yysym
))
1661 else if (yycount
== yyargn
)
1664 yyarg
[yycount
++] = yysym
;
1667 if (yyarg
&& yycount
== 0 && 0 < yyargn
)
1668 yyarg
[0] = YYSYMBOL_YYEMPTY
;
1675 /* The kind of the lookahead of this context. */
1676 static yysymbol_kind_t
1677 yypcontext_token (const yypcontext_t
*yyctx
) YY_ATTRIBUTE_UNUSED
;
1679 static yysymbol_kind_t
1680 yypcontext_token (const yypcontext_t
*yyctx
)
1682 return yyctx
->yytoken
;
1685 /* The location of the lookahead of this context. */
1687 yypcontext_location (const yypcontext_t
*yyctx
) YY_ATTRIBUTE_UNUSED
;
1690 yypcontext_location (const yypcontext_t
*yyctx
)
1692 return yyctx
->yylloc
;
1695 /* User defined function to report a syntax error. */
1697 yyreport_syntax_error (const yypcontext_t
*yyctx
);
1699 /*-----------------------------------------------.
1700 | Release the memory associated to this symbol. |
1701 `-----------------------------------------------*/
1704 yydestruct (const char *yymsg
,
1705 yysymbol_kind_t yykind
, YYSTYPE
*yyvaluep
, YYLTYPE
*yylocationp
)
1708 YY_USE (yylocationp
);
1711 YY_SYMBOL_PRINT (yymsg
, yykind
, yyvaluep
, yylocationp
);
1713 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1716 case YYSYMBOL_generic_symlist
: /* generic_symlist */
1717 { symbol_list_free (((*yyvaluep
).generic_symlist
)); }
1720 case YYSYMBOL_generic_symlist_item
: /* generic_symlist_item */
1721 { symbol_list_free (((*yyvaluep
).generic_symlist_item
)); }
1724 case YYSYMBOL_nterm_decls
: /* nterm_decls */
1725 { symbol_list_free (((*yyvaluep
).nterm_decls
)); }
1728 case YYSYMBOL_token_decls
: /* token_decls */
1729 { symbol_list_free (((*yyvaluep
).token_decls
)); }
1732 case YYSYMBOL_82_token_decl_1
: /* token_decl.1 */
1733 { symbol_list_free (((*yyvaluep
).yykind_82
)); }
1736 case YYSYMBOL_token_decls_for_prec
: /* token_decls_for_prec */
1737 { symbol_list_free (((*yyvaluep
).token_decls_for_prec
)); }
1740 case YYSYMBOL_87_token_decl_for_prec_1
: /* token_decl_for_prec.1 */
1741 { symbol_list_free (((*yyvaluep
).yykind_87
)); }
1744 case YYSYMBOL_symbol_decls
: /* symbol_decls */
1745 { symbol_list_free (((*yyvaluep
).symbol_decls
)); }
1748 case YYSYMBOL_90_symbols_1
: /* symbols.1 */
1749 { symbol_list_free (((*yyvaluep
).yykind_90
)); }
1755 YY_IGNORE_MAYBE_UNINITIALIZED_END
1770 /* Lookahead token kind. */
1774 /* The semantic value of the lookahead symbol. */
1775 /* Default value used for initialization, for pacifying older GCCs
1776 or non-GCC compilers. */
1777 YY_INITIAL_VALUE (static YYSTYPE yyval_default
;)
1778 YYSTYPE yylval
YY_INITIAL_VALUE (= yyval_default
);
1780 /* Location data for the lookahead symbol. */
1781 static YYLTYPE yyloc_default
1782 # if defined GRAM_LTYPE_IS_TRIVIAL && GRAM_LTYPE_IS_TRIVIAL
1786 YYLTYPE yylloc
= yyloc_default
;
1788 /* Number of syntax errors so far. */
1791 yy_state_fast_t yystate
= 0;
1792 /* Number of tokens to shift before error messages enabled. */
1793 int yyerrstatus
= 0;
1795 /* Refer to the stacks through separate pointers, to allow yyoverflow
1796 to reallocate them elsewhere. */
1799 YYPTRDIFF_T yystacksize
= YYINITDEPTH
;
1801 /* The state stack: array, bottom, top. */
1802 yy_state_t yyssa
[YYINITDEPTH
];
1803 yy_state_t
*yyss
= yyssa
;
1804 yy_state_t
*yyssp
= yyss
;
1806 /* The semantic value stack: array, bottom, top. */
1807 YYSTYPE yyvsa
[YYINITDEPTH
];
1808 YYSTYPE
*yyvs
= yyvsa
;
1809 YYSTYPE
*yyvsp
= yyvs
;
1811 /* The location stack: array, bottom, top. */
1812 YYLTYPE yylsa
[YYINITDEPTH
];
1813 YYLTYPE
*yyls
= yylsa
;
1814 YYLTYPE
*yylsp
= yyls
;
1816 yy_state_t yyesa
[20];
1817 yy_state_t
*yyes
= yyesa
;
1818 YYPTRDIFF_T yyes_capacity
= 20 < YYMAXDEPTH
? 20 : YYMAXDEPTH
;
1820 /* Whether LAC context is established. A Boolean. */
1821 int yy_lac_established
= 0;
1823 /* The return value of yyparse. */
1825 /* Lookahead symbol kind. */
1826 yysymbol_kind_t yytoken
= YYSYMBOL_YYEMPTY
;
1827 /* The variables used to return semantic value and location from the
1832 /* The locations where the error started and ended. */
1833 YYLTYPE yyerror_range
[3];
1837 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1839 /* The number of symbols on the RHS of the reduced rule.
1840 Keep to zero when no symbol should be popped. */
1843 YYDPRINTF ((stderr
, "Starting parse\n"));
1845 yychar
= GRAM_EMPTY
; /* Cause a token to be read. */
1848 /* User initialization code. */
1850 /* Bison's grammar can initial empty locations, hence a default
1851 location is needed. */
1852 boundary_set (&yylloc
.start
, grammar_file
, 1, 1, 1);
1853 boundary_set (&yylloc
.end
, grammar_file
, 1, 1, 1);
1861 /*------------------------------------------------------------.
1862 | yynewstate -- push a new state, which is found in yystate. |
1863 `------------------------------------------------------------*/
1865 /* In all cases, when you get here, the value and location stacks
1866 have just been pushed. So pushing a state here evens the stacks. */
1870 /*--------------------------------------------------------------------.
1871 | yysetstate -- set current state (the top of the stack) to yystate. |
1872 `--------------------------------------------------------------------*/
1874 YYDPRINTF ((stderr
, "Entering state %d\n", yystate
));
1875 YY_ASSERT (0 <= yystate
&& yystate
< YYNSTATES
);
1876 YY_IGNORE_USELESS_CAST_BEGIN
1877 *yyssp
= YY_CAST (yy_state_t
, yystate
);
1878 YY_IGNORE_USELESS_CAST_END
1879 YY_STACK_PRINT (yyss
, yyssp
);
1881 if (yyss
+ yystacksize
- 1 <= yyssp
)
1882 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1886 /* Get the current used size of the three stacks, in elements. */
1887 YYPTRDIFF_T yysize
= yyssp
- yyss
+ 1;
1889 # if defined yyoverflow
1891 /* Give user a chance to reallocate the stack. Use copies of
1892 these so that the &'s don't force the real ones into
1894 yy_state_t
*yyss1
= yyss
;
1895 YYSTYPE
*yyvs1
= yyvs
;
1896 YYLTYPE
*yyls1
= yyls
;
1898 /* Each stack pointer address is followed by the size of the
1899 data in use in that stack, in bytes. This used to be a
1900 conditional around just the two extra args, but that might
1901 be undefined if yyoverflow is a macro. */
1902 yyoverflow (YY_("memory exhausted"),
1903 &yyss1
, yysize
* YYSIZEOF (*yyssp
),
1904 &yyvs1
, yysize
* YYSIZEOF (*yyvsp
),
1905 &yyls1
, yysize
* YYSIZEOF (*yylsp
),
1911 # else /* defined YYSTACK_RELOCATE */
1912 /* Extend the stack our own way. */
1913 if (YYMAXDEPTH
<= yystacksize
)
1916 if (YYMAXDEPTH
< yystacksize
)
1917 yystacksize
= YYMAXDEPTH
;
1920 yy_state_t
*yyss1
= yyss
;
1921 union yyalloc
*yyptr
=
1922 YY_CAST (union yyalloc
*,
1923 YYSTACK_ALLOC (YY_CAST (YYSIZE_T
, YYSTACK_BYTES (yystacksize
))));
1926 YYSTACK_RELOCATE (yyss_alloc
, yyss
);
1927 YYSTACK_RELOCATE (yyvs_alloc
, yyvs
);
1928 YYSTACK_RELOCATE (yyls_alloc
, yyls
);
1929 # undef YYSTACK_RELOCATE
1931 YYSTACK_FREE (yyss1
);
1935 yyssp
= yyss
+ yysize
- 1;
1936 yyvsp
= yyvs
+ yysize
- 1;
1937 yylsp
= yyls
+ yysize
- 1;
1939 YY_IGNORE_USELESS_CAST_BEGIN
1940 YYDPRINTF ((stderr
, "Stack size increased to %ld\n",
1941 YY_CAST (long, yystacksize
)));
1942 YY_IGNORE_USELESS_CAST_END
1944 if (yyss
+ yystacksize
- 1 <= yyssp
)
1947 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1950 if (yystate
== YYFINAL
)
1960 /* Do appropriate processing given the current state. Read a
1961 lookahead token if we need one and don't already have one. */
1963 /* First try to decide what to do without reference to lookahead token. */
1964 yyn
= yypact
[yystate
];
1965 if (yypact_value_is_default (yyn
))
1968 /* Not known => get a lookahead token if don't already have one. */
1970 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1971 if (yychar
== GRAM_EMPTY
)
1973 YYDPRINTF ((stderr
, "Reading a token\n"));
1974 yychar
= yylex (&yylval
, &yylloc
);
1977 if (yychar
<= GRAM_EOF
)
1980 yytoken
= YYSYMBOL_YYEOF
;
1981 YYDPRINTF ((stderr
, "Now at end of input.\n"));
1983 else if (yychar
== GRAM_error
)
1985 /* The scanner already issued an error message, process directly
1986 to error recovery. But do not keep the error token as
1987 lookahead, it is too special and may lead us to an endless
1988 loop in error recovery. */
1989 yychar
= GRAM_UNDEF
;
1990 yytoken
= YYSYMBOL_YYerror
;
1991 yyerror_range
[1] = yylloc
;
1996 yytoken
= YYTRANSLATE (yychar
);
1997 YY_SYMBOL_PRINT ("Next token is", yytoken
, &yylval
, &yylloc
);
2000 /* If the proper action on seeing token YYTOKEN is to reduce or to
2001 detect an error, take that action. */
2003 if (yyn
< 0 || YYLAST
< yyn
|| yycheck
[yyn
] != yytoken
)
2011 if (yytable_value_is_error (yyn
))
2018 /* Count tokens shifted since error; after three, turn off error
2023 /* Shift the lookahead token. */
2024 YY_SYMBOL_PRINT ("Shifting", yytoken
, &yylval
, &yylloc
);
2026 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2028 YY_IGNORE_MAYBE_UNINITIALIZED_END
2031 /* Discard the shifted token. */
2032 yychar
= GRAM_EMPTY
;
2033 YY_LAC_DISCARD ("shift");
2037 /*-----------------------------------------------------------.
2038 | yydefault -- do the default action for the current state. |
2039 `-----------------------------------------------------------*/
2041 yyn
= yydefact
[yystate
];
2047 /*-----------------------------.
2048 | yyreduce -- do a reduction. |
2049 `-----------------------------*/
2051 /* yyn is the number of a rule to reduce with. */
2054 /* If YYLEN is nonzero, implement the default value of the action:
2057 Otherwise, the following line sets YYVAL to garbage.
2058 This behavior is undocumented and Bison
2059 users should not rely upon it. Assigning to YYVAL
2060 unconditionally makes the parser a bit smaller, and it avoids a
2061 GCC warning that YYVAL may be used uninitialized. */
2062 yyval
= yyvsp
[1-yylen
];
2064 /* Default location. */
2065 YYLLOC_DEFAULT (yyloc
, (yylsp
- yylen
), yylen
);
2066 yyerror_range
[1] = yyloc
;
2067 YY_REDUCE_PRINT (yyn
);
2069 int yychar_backup
= yychar
;
2072 case 6: /* prologue_declaration: "%{...%}" */
2074 muscle_code_grow (union_seen
? "post_prologue" : "pre_prologue",
2075 translate_code ((yyvsp
[0].PROLOGUE
), (yylsp
[0]), true), (yylsp
[0]));
2076 code_scanner_last_string_free ();
2080 case 7: /* prologue_declaration: "%<flag>" */
2082 muscle_percent_define_ensure ((yyvsp
[0].PERCENT_FLAG
), (yylsp
[0]), true);
2086 case 8: /* prologue_declaration: "%define" variable value */
2088 muscle_percent_define_insert ((yyvsp
[-1].variable
), (yyloc
), (yyvsp
[0].value
).kind
, (yyvsp
[0].value
).chars
,
2089 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
);
2093 case 9: /* prologue_declaration: "%header" string.opt */
2094 { handle_header ((yyvsp
[0].yykind_75
)); }
2097 case 10: /* prologue_declaration: "%error-verbose" */
2098 { handle_error_verbose (&(yyloc
), (yyvsp
[0].PERCENT_ERROR_VERBOSE
)); }
2101 case 11: /* prologue_declaration: "%expect" "integer literal" */
2102 { expected_sr_conflicts
= (yyvsp
[0].INT_LITERAL
); }
2105 case 12: /* prologue_declaration: "%expect-rr" "integer literal" */
2106 { expected_rr_conflicts
= (yyvsp
[0].INT_LITERAL
); }
2109 case 13: /* prologue_declaration: "%file-prefix" "string" */
2110 { handle_file_prefix (&(yyloc
), &(yylsp
[-1]), (yyvsp
[-1].PERCENT_FILE_PREFIX
), (yyvsp
[0].STRING
)); }
2113 case 14: /* prologue_declaration: "%glr-parser" */
2115 nondeterministic_parser
= true;
2120 case 15: /* prologue_declaration: "%initial-action" "{...}" */
2122 muscle_code_grow ("initial_action", translate_code ((yyvsp
[0].BRACED_CODE
), (yylsp
[0]), false), (yylsp
[0]));
2123 code_scanner_last_string_free ();
2127 case 16: /* prologue_declaration: "%language" "string" */
2128 { handle_language (&(yylsp
[-1]), (yyvsp
[0].STRING
)); }
2131 case 17: /* prologue_declaration: "%name-prefix" "string" */
2132 { handle_name_prefix (&(yyloc
), (yyvsp
[-1].PERCENT_NAME_PREFIX
), (yyvsp
[0].STRING
)); }
2135 case 18: /* prologue_declaration: "%no-lines" */
2136 { no_lines_flag
= true; }
2139 case 19: /* prologue_declaration: "%nondeterministic-parser" */
2140 { nondeterministic_parser
= true; }
2143 case 20: /* prologue_declaration: "%output" "string" */
2144 { spec_outfile
= unquote ((yyvsp
[0].STRING
)); gram_scanner_last_string_free (); }
2147 case 21: /* $@1: %empty */
2148 { current_param
= (yyvsp
[0].PERCENT_PARAM
); }
2151 case 22: /* prologue_declaration: "%param" $@1 params */
2152 { current_param
= param_none
; }
2155 case 23: /* prologue_declaration: "%pure-parser" */
2156 { handle_pure_parser (&(yyloc
), (yyvsp
[0].PERCENT_PURE_PARSER
)); }
2159 case 24: /* prologue_declaration: "%require" "string" */
2160 { handle_require (&(yylsp
[0]), (yyvsp
[0].STRING
)); }
2163 case 25: /* prologue_declaration: "%skeleton" "string" */
2164 { handle_skeleton (&(yylsp
[0]), (yyvsp
[0].STRING
)); }
2167 case 26: /* prologue_declaration: "%token-table" */
2168 { token_table_flag
= true; }
2171 case 27: /* prologue_declaration: "%verbose" */
2172 { report_flag
|= report_states
; }
2175 case 28: /* prologue_declaration: "%yacc" */
2176 { handle_yacc (&(yyloc
)); }
2179 case 29: /* prologue_declaration: error ";" */
2180 { current_class
= unknown_sym
; yyerrok
; }
2183 case 31: /* params: params "{...}" */
2184 { add_param (current_param
, (yyvsp
[0].BRACED_CODE
), (yylsp
[0])); }
2187 case 32: /* params: "{...}" */
2188 { add_param (current_param
, (yyvsp
[0].BRACED_CODE
), (yylsp
[0])); }
2191 case 34: /* grammar_declaration: "%start" symbols.1 */
2193 grammar_start_symbols_add ((yyvsp
[0].yykind_90
));
2197 case 35: /* grammar_declaration: code_props_type "{...}" generic_symlist */
2200 code_props_symbol_action_init (&code
, (yyvsp
[-1].BRACED_CODE
), (yylsp
[-1]));
2201 code_props_translate_code (&code
);
2203 for (symbol_list
*list
= (yyvsp
[0].generic_symlist
); list
; list
= list
->next
)
2204 symbol_list_code_props_set (list
, (yyvsp
[-2].code_props_type
), &code
);
2205 symbol_list_free ((yyvsp
[0].generic_symlist
));
2210 case 36: /* grammar_declaration: "%default-prec" */
2212 default_prec
= true;
2216 case 37: /* grammar_declaration: "%no-default-prec" */
2218 default_prec
= false;
2222 case 38: /* grammar_declaration: "%code" "{...}" */
2224 /* Do not invoke muscle_percent_code_grow here since it invokes
2225 muscle_user_name_list_grow. */
2226 muscle_code_grow ("percent_code()",
2227 translate_code_braceless ((yyvsp
[0].BRACED_CODE
), (yylsp
[0])), (yylsp
[0]));
2228 code_scanner_last_string_free ();
2232 case 39: /* grammar_declaration: "%code" "identifier" "{...}" */
2234 muscle_percent_code_grow ((yyvsp
[-1].ID
), (yylsp
[-1]), translate_code_braceless ((yyvsp
[0].BRACED_CODE
), (yylsp
[0])), (yylsp
[0]));
2235 code_scanner_last_string_free ();
2239 case 40: /* code_props_type: "%destructor" */
2240 { (yyval
.code_props_type
) = destructor
; }
2243 case 41: /* code_props_type: "%printer" */
2244 { (yyval
.code_props_type
) = printer
; }
2247 case 42: /* union_name: %empty */
2251 case 43: /* union_name: "identifier" */
2252 { muscle_percent_define_insert ("api.value.union.name",
2253 (yylsp
[0]), muscle_keyword
, (yyvsp
[0].ID
),
2254 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
); }
2257 case 44: /* grammar_declaration: "%union" union_name "{...}" */
2260 muscle_code_grow ("union_members", translate_code_braceless ((yyvsp
[0].BRACED_CODE
), (yylsp
[0])), (yylsp
[0]));
2261 code_scanner_last_string_free ();
2265 case 45: /* $@2: %empty */
2266 { current_class
= nterm_sym
; }
2269 case 46: /* symbol_declaration: "%nterm" $@2 nterm_decls */
2271 current_class
= unknown_sym
;
2272 symbol_list_free ((yyvsp
[0].nterm_decls
));
2276 case 47: /* $@3: %empty */
2277 { current_class
= token_sym
; }
2280 case 48: /* symbol_declaration: "%token" $@3 token_decls */
2282 current_class
= unknown_sym
;
2283 symbol_list_free ((yyvsp
[0].token_decls
));
2287 case 49: /* $@4: %empty */
2288 { current_class
= pct_type_sym
; }
2291 case 50: /* symbol_declaration: "%type" $@4 symbol_decls */
2293 current_class
= unknown_sym
;
2294 symbol_list_free ((yyvsp
[0].symbol_decls
));
2298 case 51: /* symbol_declaration: precedence_declarator token_decls_for_prec */
2301 for (symbol_list
*list
= (yyvsp
[0].token_decls_for_prec
); list
; list
= list
->next
)
2302 symbol_precedence_set (list
->content
.sym
, current_prec
, (yyvsp
[-1].precedence_declarator
), (yylsp
[-1]));
2303 symbol_list_free ((yyvsp
[0].token_decls_for_prec
));
2307 case 52: /* precedence_declarator: "%left" */
2308 { (yyval
.precedence_declarator
) = left_assoc
; }
2311 case 53: /* precedence_declarator: "%right" */
2312 { (yyval
.precedence_declarator
) = right_assoc
; }
2315 case 54: /* precedence_declarator: "%nonassoc" */
2316 { (yyval
.precedence_declarator
) = non_assoc
; }
2319 case 55: /* precedence_declarator: "%precedence" */
2320 { (yyval
.precedence_declarator
) = precedence_assoc
; }
2323 case 56: /* string.opt: %empty */
2324 { (yyval
.yykind_75
) = NULL
; }
2327 case 57: /* string.opt: "string" */
2328 { (yyval
.yykind_75
) = (yyvsp
[0].STRING
); }
2331 case 58: /* tag.opt: %empty */
2332 { (yyval
.yykind_76
) = NULL
; }
2335 case 59: /* tag.opt: "<tag>" */
2336 { (yyval
.yykind_76
) = (yyvsp
[0].TAG
); }
2339 case 61: /* generic_symlist: generic_symlist generic_symlist_item */
2340 { (yyval
.generic_symlist
) = symbol_list_append ((yyvsp
[-1].generic_symlist
), (yyvsp
[0].generic_symlist_item
)); }
2343 case 62: /* generic_symlist_item: symbol */
2344 { (yyval
.generic_symlist_item
) = symbol_list_sym_new ((yyvsp
[0].symbol
), (yylsp
[0])); }
2347 case 63: /* generic_symlist_item: tag */
2348 { (yyval
.generic_symlist_item
) = symbol_list_type_new ((yyvsp
[0].tag
), (yylsp
[0])); }
2351 case 65: /* tag: "<*>" */
2352 { (yyval
.tag
) = uniqstr_new ("*"); }
2355 case 66: /* tag: "<>" */
2356 { (yyval
.tag
) = uniqstr_new (""); }
2359 case 68: /* token_decls: token_decl.1 */
2361 (yyval
.token_decls
) = (yyvsp
[0].yykind_82
);
2365 case 69: /* token_decls: "<tag>" token_decl.1 */
2367 (yyval
.token_decls
) = symbol_list_type_set ((yyvsp
[0].yykind_82
), (yyvsp
[-1].TAG
));
2371 case 70: /* token_decls: token_decls "<tag>" token_decl.1 */
2373 (yyval
.token_decls
) = symbol_list_append ((yyvsp
[-2].token_decls
), symbol_list_type_set ((yyvsp
[0].yykind_82
), (yyvsp
[-1].TAG
)));
2377 case 71: /* token_decl.1: token_decl */
2378 { (yyval
.yykind_82
) = symbol_list_sym_new ((yyvsp
[0].token_decl
), (yylsp
[0])); }
2381 case 72: /* token_decl.1: token_decl.1 token_decl */
2382 { (yyval
.yykind_82
) = symbol_list_append ((yyvsp
[-1].yykind_82
), symbol_list_sym_new ((yyvsp
[0].token_decl
), (yylsp
[0]))); }
2385 case 73: /* token_decl: id int.opt alias */
2387 (yyval
.token_decl
) = (yyvsp
[-2].id
);
2388 symbol_class_set ((yyvsp
[-2].id
), current_class
, (yylsp
[-2]), true);
2389 if (0 <= (yyvsp
[-1].yykind_84
))
2390 symbol_code_set ((yyvsp
[-2].id
), (yyvsp
[-1].yykind_84
), (yylsp
[-1]));
2391 if ((yyvsp
[0].alias
))
2392 symbol_make_alias ((yyvsp
[-2].id
), (yyvsp
[0].alias
), (yylsp
[0]));
2396 case 74: /* int.opt: %empty */
2397 { (yyval
.yykind_84
) = -1; }
2400 case 76: /* alias: %empty */
2401 { (yyval
.alias
) = NULL
; }
2404 case 77: /* alias: string_as_id */
2405 { (yyval
.alias
) = (yyvsp
[0].string_as_id
); }
2408 case 78: /* alias: "translatable string" */
2410 (yyval
.alias
) = symbol_get ((yyvsp
[0].TSTRING
), (yylsp
[0]));
2411 symbol_class_set ((yyval
.alias
), token_sym
, (yylsp
[0]), false);
2412 (yyval
.alias
)->translatable
= true;
2416 case 79: /* token_decls_for_prec: token_decl_for_prec.1 */
2418 (yyval
.token_decls_for_prec
) = (yyvsp
[0].yykind_87
);
2422 case 80: /* token_decls_for_prec: "<tag>" token_decl_for_prec.1 */
2424 (yyval
.token_decls_for_prec
) = symbol_list_type_set ((yyvsp
[0].yykind_87
), (yyvsp
[-1].TAG
));
2428 case 81: /* token_decls_for_prec: token_decls_for_prec "<tag>" token_decl_for_prec.1 */
2430 (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
)));
2434 case 82: /* token_decl_for_prec.1: token_decl_for_prec */
2435 { (yyval
.yykind_87
) = symbol_list_sym_new ((yyvsp
[0].token_decl_for_prec
), (yylsp
[0])); }
2438 case 83: /* token_decl_for_prec.1: token_decl_for_prec.1 token_decl_for_prec */
2439 { (yyval
.yykind_87
) = symbol_list_append ((yyvsp
[-1].yykind_87
), symbol_list_sym_new ((yyvsp
[0].token_decl_for_prec
), (yylsp
[0]))); }
2442 case 84: /* token_decl_for_prec: id int.opt */
2444 (yyval
.token_decl_for_prec
) = (yyvsp
[-1].id
);
2445 symbol_class_set ((yyvsp
[-1].id
), token_sym
, (yylsp
[-1]), false);
2446 if (0 <= (yyvsp
[0].yykind_84
))
2447 symbol_code_set ((yyvsp
[-1].id
), (yyvsp
[0].yykind_84
), (yylsp
[0]));
2451 case 86: /* symbol_decls: symbols.1 */
2453 (yyval
.symbol_decls
) = (yyvsp
[0].yykind_90
);
2457 case 87: /* symbol_decls: "<tag>" symbols.1 */
2459 (yyval
.symbol_decls
) = symbol_list_type_set ((yyvsp
[0].yykind_90
), (yyvsp
[-1].TAG
));
2463 case 88: /* symbol_decls: symbol_decls "<tag>" symbols.1 */
2465 (yyval
.symbol_decls
) = symbol_list_append ((yyvsp
[-2].symbol_decls
), symbol_list_type_set ((yyvsp
[0].yykind_90
), (yyvsp
[-1].TAG
)));
2469 case 89: /* symbols.1: symbol */
2471 if (current_class
!= unknown_sym
)
2472 symbol_class_set ((yyvsp
[0].symbol
), current_class
, (yylsp
[0]), false);
2473 (yyval
.yykind_90
) = symbol_list_sym_new ((yyvsp
[0].symbol
), (yylsp
[0]));
2477 case 90: /* symbols.1: 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_append ((yyvsp
[-1].yykind_90
), symbol_list_sym_new ((yyvsp
[0].symbol
), (yylsp
[0])));
2485 case 95: /* rules_or_grammar_declaration: error ";" */
2491 case 96: /* $@5: %empty */
2492 { current_lhs ((yyvsp
[-1].id_colon
), (yylsp
[-1]), (yyvsp
[0].yykind_97
)); }
2495 case 97: /* rules: id_colon named_ref.opt $@5 ":" rhses.1 */
2497 /* Free the current lhs. */
2498 current_lhs (0, (yylsp
[-4]), 0);
2502 case 98: /* rhses.1: rhs */
2503 { grammar_current_rule_end ((yylsp
[0])); }
2506 case 99: /* rhses.1: rhses.1 "|" rhs */
2507 { grammar_current_rule_end ((yylsp
[0])); }
2510 case 101: /* rhs: %empty */
2511 { grammar_current_rule_begin (current_lhs_symbol
, current_lhs_loc
,
2512 current_lhs_named_ref
); }
2515 case 102: /* rhs: rhs symbol named_ref.opt */
2516 { grammar_current_rule_symbol_append ((yyvsp
[-1].symbol
), (yylsp
[-1]), (yyvsp
[0].yykind_97
)); }
2519 case 103: /* rhs: rhs tag.opt "{...}" named_ref.opt */
2520 { grammar_current_rule_action_append ((yyvsp
[-1].BRACED_CODE
), (yylsp
[-1]), (yyvsp
[0].yykind_97
), (yyvsp
[-2].yykind_76
)); }
2523 case 104: /* rhs: rhs "%?{...}" */
2524 { grammar_current_rule_predicate_append ((yyvsp
[0].BRACED_PREDICATE
), (yylsp
[0])); }
2527 case 105: /* rhs: rhs "%empty" */
2528 { grammar_current_rule_empty_set ((yylsp
[0])); }
2531 case 106: /* rhs: rhs "%prec" symbol */
2532 { grammar_current_rule_prec_set ((yyvsp
[0].symbol
), (yylsp
[0])); }
2535 case 107: /* rhs: rhs "%dprec" "integer literal" */
2536 { grammar_current_rule_dprec_set ((yyvsp
[0].INT_LITERAL
), (yylsp
[0])); }
2539 case 108: /* rhs: rhs "%merge" "<tag>" */
2540 { grammar_current_rule_merge_set ((yyvsp
[0].TAG
), (yylsp
[0])); }
2543 case 109: /* rhs: rhs "%expect" "integer literal" */
2544 { grammar_current_rule_expect_sr ((yyvsp
[0].INT_LITERAL
), (yylsp
[0])); }
2547 case 110: /* rhs: rhs "%expect-rr" "integer literal" */
2548 { grammar_current_rule_expect_rr ((yyvsp
[0].INT_LITERAL
), (yylsp
[0])); }
2551 case 111: /* named_ref.opt: %empty */
2552 { (yyval
.yykind_97
) = NULL
; }
2555 case 112: /* named_ref.opt: "[identifier]" */
2556 { (yyval
.yykind_97
) = named_ref_new ((yyvsp
[0].BRACKETED_ID
), (yylsp
[0])); }
2559 case 114: /* value: %empty */
2560 { (yyval
.value
).kind
= muscle_keyword
; (yyval
.value
).chars
= ""; }
2563 case 115: /* value: "identifier" */
2564 { (yyval
.value
).kind
= muscle_keyword
; (yyval
.value
).chars
= (yyvsp
[0].ID
); }
2567 case 116: /* value: "string" */
2568 { (yyval
.value
).kind
= muscle_string
; (yyval
.value
).chars
= unquote ((yyvsp
[0].STRING
)); gram_scanner_last_string_free ();}
2571 case 117: /* value: "{...}" */
2572 { (yyval
.value
).kind
= muscle_code
; (yyval
.value
).chars
= strip_braces ((yyvsp
[0].BRACED_CODE
)); gram_scanner_last_string_free (); }
2575 case 118: /* id: "identifier" */
2576 { (yyval
.id
) = symbol_from_uniqstr ((yyvsp
[0].ID
), (yylsp
[0])); }
2579 case 119: /* id: "character literal" */
2581 const char *var
= "api.token.raw";
2582 if (current_class
== nterm_sym
)
2584 complain (&(yylsp
[0]), complaint
,
2585 _("character literals cannot be nonterminals"));
2588 if (muscle_percent_define_ifdef (var
))
2590 complain (&(yylsp
[0]), complaint
,
2591 _("character literals cannot be used together"
2593 location loc
= muscle_percent_define_get_loc (var
);
2594 subcomplain (&loc
, complaint
, _("definition of %s"), var
);
2596 (yyval
.id
) = symbol_get (char_name ((yyvsp
[0].CHAR_LITERAL
)), (yylsp
[0]));
2597 symbol_class_set ((yyval
.id
), token_sym
, (yylsp
[0]), false);
2598 symbol_code_set ((yyval
.id
), (yyvsp
[0].CHAR_LITERAL
), (yylsp
[0]));
2602 case 120: /* id_colon: "identifier:" */
2603 { (yyval
.id_colon
) = symbol_from_uniqstr ((yyvsp
[0].ID_COLON
), (yylsp
[0])); }
2606 case 123: /* string_as_id: "string" */
2608 (yyval
.string_as_id
) = symbol_get ((yyvsp
[0].STRING
), (yylsp
[0]));
2609 symbol_class_set ((yyval
.string_as_id
), token_sym
, (yylsp
[0]), false);
2613 case 125: /* epilogue.opt: "%%" "epilogue" */
2615 muscle_code_grow ("epilogue", translate_code ((yyvsp
[0].EPILOGUE
), (yylsp
[0]), true), (yylsp
[0]));
2616 code_scanner_last_string_free ();
2624 if (yychar_backup
!= yychar
)
2625 YY_LAC_DISCARD ("yychar change");
2627 /* User semantic actions sometimes alter yychar, and that requires
2628 that yytoken be updated with the new translation. We take the
2629 approach of translating immediately before every use of yytoken.
2630 One alternative is translating here after every semantic action,
2631 but that translation would be missed if the semantic action invokes
2632 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2633 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2634 incorrect destructor might then be invoked immediately. In the
2635 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2636 to an incorrect destructor call or verbose syntax error message
2637 before the lookahead is translated. */
2638 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t
, yyr1
[yyn
]), &yyval
, &yyloc
);
2646 /* Now 'shift' the result of the reduction. Determine what state
2647 that goes to, based on the state we popped back to and the rule
2648 number reduced by. */
2650 const int yylhs
= yyr1
[yyn
] - YYNTOKENS
;
2651 const int yyi
= yypgoto
[yylhs
] + *yyssp
;
2652 yystate
= (0 <= yyi
&& yyi
<= YYLAST
&& yycheck
[yyi
] == *yyssp
2654 : yydefgoto
[yylhs
]);
2660 /*--------------------------------------.
2661 | yyerrlab -- here on detecting error. |
2662 `--------------------------------------*/
2664 /* Make sure we have latest lookahead translation. See comments at
2665 user semantic actions for why this is necessary. */
2666 yytoken
= yychar
== GRAM_EMPTY
? YYSYMBOL_YYEMPTY
: YYTRANSLATE (yychar
);
2667 /* If not already recovering from an error, report this error. */
2673 = {yyssp
, yyesa
, &yyes
, &yyes_capacity
, yytoken
, &yylloc
};
2674 if (yychar
!= GRAM_EMPTY
)
2676 if (yyreport_syntax_error (&yyctx
) == 2)
2681 yyerror_range
[1] = yylloc
;
2682 if (yyerrstatus
== 3)
2684 /* If just tried and failed to reuse lookahead token after an
2685 error, discard it. */
2687 if (yychar
<= GRAM_EOF
)
2689 /* Return failure if at end of input. */
2690 if (yychar
== GRAM_EOF
)
2695 yydestruct ("Error: discarding",
2696 yytoken
, &yylval
, &yylloc
);
2697 yychar
= GRAM_EMPTY
;
2701 /* Else will try to reuse lookahead token after shifting the error
2706 /*---------------------------------------------------.
2707 | yyerrorlab -- error raised explicitly by YYERROR. |
2708 `---------------------------------------------------*/
2710 /* Pacify compilers when the user code never invokes YYERROR and the
2711 label yyerrorlab therefore never appears in user code. */
2716 /* Do not reclaim the symbols of the rule whose action triggered
2720 YY_STACK_PRINT (yyss
, yyssp
);
2725 /*-------------------------------------------------------------.
2726 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2727 `-------------------------------------------------------------*/
2729 yyerrstatus
= 3; /* Each real token shifted decrements this. */
2731 /* Pop stack until we find a state that shifts the error token. */
2734 yyn
= yypact
[yystate
];
2735 if (!yypact_value_is_default (yyn
))
2737 yyn
+= YYSYMBOL_YYerror
;
2738 if (0 <= yyn
&& yyn
<= YYLAST
&& yycheck
[yyn
] == YYSYMBOL_YYerror
)
2746 /* Pop the current state because it cannot handle the error token. */
2750 yyerror_range
[1] = *yylsp
;
2751 yydestruct ("Error: popping",
2752 YY_ACCESSING_SYMBOL (yystate
), yyvsp
, yylsp
);
2755 YY_STACK_PRINT (yyss
, yyssp
);
2758 /* If the stack popping above didn't lose the initial context for the
2759 current lookahead token, the shift below will for sure. */
2760 YY_LAC_DISCARD ("error recovery");
2762 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2764 YY_IGNORE_MAYBE_UNINITIALIZED_END
2766 yyerror_range
[2] = yylloc
;
2768 YYLLOC_DEFAULT (*yylsp
, yyerror_range
, 2);
2770 /* Shift the error token. */
2771 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn
), yyvsp
, yylsp
);
2777 /*-------------------------------------.
2778 | yyacceptlab -- YYACCEPT comes here. |
2779 `-------------------------------------*/
2785 /*-----------------------------------.
2786 | yyabortlab -- YYABORT comes here. |
2787 `-----------------------------------*/
2793 /*-----------------------------------------------------------.
2794 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
2795 `-----------------------------------------------------------*/
2797 yyerror (&yylloc
, YY_("memory exhausted"));
2802 /*----------------------------------------------------------.
2803 | yyreturnlab -- parsing is finished, clean up and return. |
2804 `----------------------------------------------------------*/
2806 if (yychar
!= GRAM_EMPTY
)
2808 /* Make sure we have latest lookahead translation. See comments at
2809 user semantic actions for why this is necessary. */
2810 yytoken
= YYTRANSLATE (yychar
);
2811 yydestruct ("Cleanup: discarding lookahead",
2812 yytoken
, &yylval
, &yylloc
);
2814 /* Do not reclaim the symbols of the rule whose action triggered
2815 this YYABORT or YYACCEPT. */
2817 YY_STACK_PRINT (yyss
, yyssp
);
2818 while (yyssp
!= yyss
)
2820 yydestruct ("Cleanup: popping",
2821 YY_ACCESSING_SYMBOL (+*yyssp
), yyvsp
, yylsp
);
2826 YYSTACK_FREE (yyss
);
2829 YYSTACK_FREE (yyes
);
2837 yyreport_syntax_error (const yypcontext_t
*ctx
)
2840 /* Arguments of format: reported tokens (one for the "unexpected",
2841 one per "expected"). */
2842 enum { ARGS_MAX
= 5 };
2843 const char *argv
[ARGS_MAX
];
2845 yysymbol_kind_t unexpected
= yypcontext_token (ctx
);
2846 if (unexpected
!= YYSYMBOL_YYEMPTY
)
2848 argv
[argc
++] = yysymbol_name (unexpected
);
2849 yysymbol_kind_t expected
[ARGS_MAX
- 1];
2850 int nexpected
= yypcontext_expected_tokens (ctx
, expected
, ARGS_MAX
- 1);
2854 for (int i
= 0; i
< nexpected
; ++i
)
2855 argv
[argc
++] = yysymbol_name (expected
[i
]);
2857 syntax_error (*yypcontext_location (ctx
), argc
, argv
);
2862 /* Return the location of the left-hand side of a rule whose
2863 right-hand side is RHS[1] ... RHS[N]. Ignore empty nonterminals in
2864 the right-hand side, and return an empty location equal to the end
2865 boundary of RHS[0] if the right-hand side is empty. */
2868 lloc_default (YYLTYPE
const *rhs
, int n
)
2872 /* SGI MIPSpro 7.4.1m miscompiles "loc.start = loc.end = rhs[n].end;".
2873 The bug is fixed in 7.4.2m, but play it safe for now. */
2874 loc
.start
= rhs
[n
].end
;
2875 loc
.end
= rhs
[n
].end
;
2877 /* Ignore empty nonterminals the start of the right-hand side.
2878 Do not bother to ignore them at the end of the right-hand side,
2879 since empty nonterminals have the same end as their predecessors. */
2880 for (int i
= 1; i
<= n
; i
++)
2881 if (! equal_boundaries (rhs
[i
].start
, rhs
[i
].end
))
2883 loc
.start
= rhs
[i
].start
;
2891 char *strip_braces (char *code
)
2893 code
[strlen (code
) - 1] = 0;
2899 translate_code (char *code
, location loc
, bool plain
)
2901 code_props plain_code
;
2903 code_props_plain_init (&plain_code
, code
, loc
);
2905 code_props_symbol_action_init (&plain_code
, code
, loc
);
2906 code_props_translate_code (&plain_code
);
2907 gram_scanner_last_string_free ();
2908 return plain_code
.code
;
2913 translate_code_braceless (char *code
, location loc
)
2915 return translate_code (strip_braces (code
), loc
, true);
2919 add_param (param_type type
, char *decl
, location loc
)
2921 static char const alphanum
[26 + 26 + 1 + 10 + 1] =
2922 "abcdefghijklmnopqrstuvwxyz"
2923 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
2927 char const *name_start
= NULL
;
2930 /* Stop on last actual character. */
2931 for (p
= decl
; p
[1]; p
++)
2933 || ! memchr (alphanum
, p
[-1], sizeof alphanum
- 1))
2934 && memchr (alphanum
, p
[0], sizeof alphanum
- 10 - 1))
2937 /* Strip the surrounding '{' and '}', and any blanks just inside
2940 while (c_isspace ((unsigned char) *p
))
2944 while (c_isspace ((unsigned char) *decl
))
2949 complain (&loc
, complaint
, _("missing identifier in parameter declaration"));
2952 char *name
= xmemdup0 (name_start
, strspn (name_start
, alphanum
));
2953 if (type
& param_lex
)
2954 muscle_pair_list_grow ("lex_param", decl
, name
);
2955 if (type
& param_parse
)
2956 muscle_pair_list_grow ("parse_param", decl
, name
);
2960 gram_scanner_last_string_free ();
2965 handle_header (char const *value
)
2970 char *file
= unquote (value
);
2971 spec_header_file
= xstrdup (file
);
2972 gram_scanner_last_string_free ();
2973 unquote_free (file
);
2979 handle_error_verbose (location
const *loc
, char const *directive
)
2981 bison_directive (loc
, directive
);
2982 muscle_percent_define_insert (directive
, *loc
, muscle_keyword
, "",
2983 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
);
2988 handle_file_prefix (location
const *loc
,
2989 location
const *dir_loc
,
2990 char const *directive
, char const *value_quoted
)
2992 char *value
= unquote (value_quoted
);
2993 bison_directive (loc
, directive
);
2994 bool warned
= false;
2996 if (location_empty (spec_file_prefix_loc
))
2998 spec_file_prefix_loc
= *loc
;
2999 spec_file_prefix
= value
;
3003 duplicate_directive (directive
, spec_file_prefix_loc
, *loc
);
3008 && STRNEQ (directive
, "%file-prefix"))
3009 deprecated_directive (dir_loc
, directive
, "%file-prefix");
3013 handle_language (location
const *loc
, char const *lang
)
3015 language_argmatch (unquote (lang
), grammar_prio
, *loc
);
3020 handle_name_prefix (location
const *loc
,
3021 char const *directive
, char const *value_quoted
)
3023 char *value
= unquote (value_quoted
);
3024 bison_directive (loc
, directive
);
3027 size_t len1
= sizeof (buf1
);
3028 char *old
= asnprintf (buf1
, &len1
, "%s\"%s\"", directive
, value
);
3032 if (location_empty (spec_name_prefix_loc
))
3034 spec_name_prefix
= value
;
3035 spec_name_prefix_loc
= *loc
;
3038 size_t len2
= sizeof (buf2
);
3039 char *new = asnprintf (buf2
, &len2
, "%%define api.prefix {%s}", value
);
3042 deprecated_directive (loc
, old
, new);
3047 duplicate_directive (old
, spec_file_prefix_loc
, *loc
);
3055 handle_pure_parser (location
const *loc
, char const *directive
)
3057 bison_directive (loc
, directive
);
3058 deprecated_directive (loc
, directive
, "%define api.pure");
3059 muscle_percent_define_insert ("api.pure", *loc
, muscle_keyword
, "",
3060 MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE
);
3065 handle_require (location
const *loc
, char const *version_quoted
)
3067 char *version
= unquote (version_quoted
);
3068 required_version
= strversion_to_int (version
);
3069 if (required_version
== -1)
3071 complain (loc
, complaint
, _("invalid version requirement: %s"),
3073 required_version
= 0;
3077 const char* package_version
=
3078 0 < strverscmp (api_version
, PACKAGE_VERSION
)
3079 ? api_version
: PACKAGE_VERSION
;
3080 if (0 < strverscmp (version
, package_version
))
3082 complain (loc
, complaint
, _("require bison %s, but have %s"),
3083 version
, package_version
);
3087 unquote_free (version
);
3088 gram_scanner_last_string_free ();
3092 handle_skeleton (location
const *loc
, char const *skel_quoted
)
3094 char *skel
= unquote (skel_quoted
);
3095 char const *skeleton_user
= skel
;
3096 if (strchr (skeleton_user
, '/'))
3098 size_t dir_length
= strlen (grammar_file
);
3099 while (dir_length
&& grammar_file
[dir_length
- 1] != '/')
3101 while (dir_length
&& grammar_file
[dir_length
- 1] == '/')
3103 char *skeleton_build
=
3104 xmalloc (dir_length
+ 1 + strlen (skeleton_user
) + 1);
3107 memcpy (skeleton_build
, grammar_file
, dir_length
);
3108 skeleton_build
[dir_length
++] = '/';
3110 strcpy (skeleton_build
+ dir_length
, skeleton_user
);
3111 skeleton_user
= uniqstr_new (skeleton_build
);
3112 free (skeleton_build
);
3114 skeleton_arg (skeleton_user
, grammar_prio
, *loc
);
3119 handle_yacc (location
const *loc
)
3121 const char *directive
= "%yacc";
3122 bison_directive (loc
, directive
);
3123 if (location_empty (yacc_loc
))
3126 duplicate_directive (directive
, yacc_loc
, *loc
);
3131 gram_error (location
const *loc
, char const *msg
)
3133 complain (loc
, complaint
, "%s", msg
);
3144 buf
[0] = '\''; buf
[1] = c
; buf
[2] = '\''; buf
[3] = '\0';
3145 return quotearg_style (escape_quoting_style
, buf
);
3150 current_lhs (symbol
*sym
, location loc
, named_ref
*ref
)
3152 current_lhs_symbol
= sym
;
3153 current_lhs_loc
= loc
;
3155 symbol_location_as_lhs_set (sym
, loc
);
3156 /* In order to simplify memory management, named references for lhs
3157 are always assigned by deep copy into the current symbol_list
3158 node. This is because a single named-ref in the grammar may
3159 result in several uses when the user factors lhs between several
3160 rules using "|". Therefore free the parser's original copy. */
3161 free (current_lhs_named_ref
);
3162 current_lhs_named_ref
= ref
;
3165 static void tron (FILE *yyo
)
3167 begin_use_class ("value", yyo
);
3170 static void troff (FILE *yyo
)
3172 end_use_class ("value", yyo
);
3180 struct obstack obstack_for_unquote
;
3185 obstack_init (&obstack_for_unquote
);
3191 obstack_free (&obstack_for_unquote
, 0);
3195 unquote_free (char *last_string
)
3197 obstack_free (&obstack_for_unquote
, last_string
);
3201 unquote (const char *cp
)
3203 #define GROW(Char) \
3204 obstack_1grow (&obstack_for_unquote, Char);
3205 for (++cp
; *cp
&& *cp
!= '"'; ++cp
)
3214 case '0': case '1': case '2': case '3': case '4':
3215 case '5': case '6': case '7': case '8': case '9':
3217 int c
= cp
[0] - '0';
3218 if (c_isdigit (cp
[1]))
3221 c
= c
* 8 + cp
[0] - '0';
3223 if (c_isdigit (cp
[1]))
3226 c
= c
* 8 + cp
[0] - '0';
3232 case 'a': GROW ('\a'); break;
3233 case 'b': GROW ('\b'); break;
3234 case 'f': GROW ('\f'); break;
3235 case 'n': GROW ('\n'); break;
3236 case 'r': GROW ('\r'); break;
3237 case 't': GROW ('\t'); break;
3238 case 'v': GROW ('\v'); break;
3243 while (c_isxdigit (cp
[1]))
3246 c
= (c
* 16 + (c_isdigit (cp
[0]) ? cp
[0] - '0'
3247 : c_isupper (cp
[0]) ? cp
[0] - 'A'
3260 assert (*cp
== '"');
3262 assert (*cp
== '\0');
3264 return obstack_finish0 (&obstack_for_unquote
);