1 /* A Bison parser, made by GNU Bison 3.0.4. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.4"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 1
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62 /* Substitute the variable and function names. */
63 #define yyparse libconfig_yyparse
64 #define yylex libconfig_yylex
65 #define yyerror libconfig_yyerror
66 #define yydebug libconfig_yydebug
67 #define yynerrs libconfig_yynerrs
68
69
70 /* Copy the first part of user declarations. */
71 #line 32 "grammar.y" /* yacc.c:339 */
72
73 #include <string.h>
74 #include <stdlib.h>
75
76 #include "libconfig.h"
77 #include "parsectx.h"
78 #include "scanctx.h"
79 #include "util.h"
80 #include "wincompat.h"
81
82 /* These declarations are provided to suppress compiler warnings. */
83 extern int libconfig_yylex();
84 extern int libconfig_yyget_lineno();
85
86 static const char *err_array_elem_type = "mismatched element type in array";
87 static const char *err_duplicate_setting = "duplicate setting name";
88
89 #define IN_ARRAY() \
90 (ctx->parent && (ctx->parent->type == CONFIG_TYPE_ARRAY))
91
92 #define IN_LIST() \
93 (ctx->parent && (ctx->parent->type == CONFIG_TYPE_LIST))
94
capture_parse_pos(void * scanner,struct scan_context * scan_ctx,config_setting_t * setting)95 static void capture_parse_pos(void *scanner, struct scan_context *scan_ctx,
96 config_setting_t *setting)
97 {
98 setting->line = (unsigned int)libconfig_yyget_lineno(scanner);
99 setting->file = scanctx_current_filename(scan_ctx);
100 }
101
102 #define CAPTURE_PARSE_POS(S) \
103 capture_parse_pos(scanner, scan_ctx, (S))
104
libconfig_yyerror(void * scanner,struct parse_context * ctx,struct scan_context * scan_ctx,char const * s)105 void libconfig_yyerror(void *scanner, struct parse_context *ctx,
106 struct scan_context *scan_ctx, char const *s)
107 {
108 if(ctx->config->error_text) return;
109 ctx->config->error_line = libconfig_yyget_lineno(scanner);
110 ctx->config->error_text = s;
111 }
112
113
114 #line 115 "grammar.c" /* yacc.c:339 */
115
116 # ifndef YY_NULLPTR
117 # if defined __cplusplus && 201103L <= __cplusplus
118 # define YY_NULLPTR nullptr
119 # else
120 # define YY_NULLPTR 0
121 # endif
122 # endif
123
124 /* Enabling verbose error messages. */
125 #ifdef YYERROR_VERBOSE
126 # undef YYERROR_VERBOSE
127 # define YYERROR_VERBOSE 1
128 #else
129 # define YYERROR_VERBOSE 0
130 #endif
131
132 /* In a future release of Bison, this section will be replaced
133 by #include "y.tab.h". */
134 #ifndef YY_LIBCONFIG_YY_GRAMMAR_H_INCLUDED
135 # define YY_LIBCONFIG_YY_GRAMMAR_H_INCLUDED
136 /* Debug traces. */
137 #ifndef YYDEBUG
138 # define YYDEBUG 0
139 #endif
140 #if YYDEBUG
141 extern int libconfig_yydebug;
142 #endif
143
144 /* Token type. */
145 #ifndef YYTOKENTYPE
146 # define YYTOKENTYPE
147 enum yytokentype
148 {
149 TOK_BOOLEAN = 258,
150 TOK_INTEGER = 259,
151 TOK_HEX = 260,
152 TOK_INTEGER64 = 261,
153 TOK_HEX64 = 262,
154 TOK_FLOAT = 263,
155 TOK_STRING = 264,
156 TOK_NAME = 265,
157 TOK_EQUALS = 266,
158 TOK_NEWLINE = 267,
159 TOK_ARRAY_START = 268,
160 TOK_ARRAY_END = 269,
161 TOK_LIST_START = 270,
162 TOK_LIST_END = 271,
163 TOK_COMMA = 272,
164 TOK_GROUP_START = 273,
165 TOK_GROUP_END = 274,
166 TOK_SEMICOLON = 275,
167 TOK_GARBAGE = 276,
168 TOK_ERROR = 277
169 };
170 #endif
171 /* Tokens. */
172 #define TOK_BOOLEAN 258
173 #define TOK_INTEGER 259
174 #define TOK_HEX 260
175 #define TOK_INTEGER64 261
176 #define TOK_HEX64 262
177 #define TOK_FLOAT 263
178 #define TOK_STRING 264
179 #define TOK_NAME 265
180 #define TOK_EQUALS 266
181 #define TOK_NEWLINE 267
182 #define TOK_ARRAY_START 268
183 #define TOK_ARRAY_END 269
184 #define TOK_LIST_START 270
185 #define TOK_LIST_END 271
186 #define TOK_COMMA 272
187 #define TOK_GROUP_START 273
188 #define TOK_GROUP_END 274
189 #define TOK_SEMICOLON 275
190 #define TOK_GARBAGE 276
191 #define TOK_ERROR 277
192
193 /* Value type. */
194 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
195
196 union YYSTYPE
197 {
198 #line 76 "grammar.y" /* yacc.c:355 */
199
200 int ival;
201 long long llval;
202 double fval;
203 char *sval;
204
205 #line 206 "grammar.c" /* yacc.c:355 */
206 };
207
208 typedef union YYSTYPE YYSTYPE;
209 # define YYSTYPE_IS_TRIVIAL 1
210 # define YYSTYPE_IS_DECLARED 1
211 #endif
212
213
214
215 int libconfig_yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx);
216
217 #endif /* !YY_LIBCONFIG_YY_GRAMMAR_H_INCLUDED */
218
219 /* Copy the second part of user declarations. */
220
221 #line 222 "grammar.c" /* yacc.c:358 */
222
223 #ifdef short
224 # undef short
225 #endif
226
227 #ifdef YYTYPE_UINT8
228 typedef YYTYPE_UINT8 yytype_uint8;
229 #else
230 typedef unsigned char yytype_uint8;
231 #endif
232
233 #ifdef YYTYPE_INT8
234 typedef YYTYPE_INT8 yytype_int8;
235 #else
236 typedef signed char yytype_int8;
237 #endif
238
239 #ifdef YYTYPE_UINT16
240 typedef YYTYPE_UINT16 yytype_uint16;
241 #else
242 typedef unsigned short int yytype_uint16;
243 #endif
244
245 #ifdef YYTYPE_INT16
246 typedef YYTYPE_INT16 yytype_int16;
247 #else
248 typedef short int yytype_int16;
249 #endif
250
251 #ifndef YYSIZE_T
252 # ifdef __SIZE_TYPE__
253 # define YYSIZE_T __SIZE_TYPE__
254 # elif defined size_t
255 # define YYSIZE_T size_t
256 # elif ! defined YYSIZE_T
257 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
258 # define YYSIZE_T size_t
259 # else
260 # define YYSIZE_T unsigned int
261 # endif
262 #endif
263
264 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
265
266 #ifndef YY_
267 # if defined YYENABLE_NLS && YYENABLE_NLS
268 # if ENABLE_NLS
269 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
270 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
271 # endif
272 # endif
273 # ifndef YY_
274 # define YY_(Msgid) Msgid
275 # endif
276 #endif
277
278 #ifndef YY_ATTRIBUTE
279 # if (defined __GNUC__ \
280 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
281 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
282 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
283 # else
284 # define YY_ATTRIBUTE(Spec) /* empty */
285 # endif
286 #endif
287
288 #ifndef YY_ATTRIBUTE_PURE
289 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
290 #endif
291
292 #ifndef YY_ATTRIBUTE_UNUSED
293 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
294 #endif
295
296 #if !defined _Noreturn \
297 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
298 # if defined _MSC_VER && 1200 <= _MSC_VER
299 # define _Noreturn __declspec (noreturn)
300 # else
301 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
302 # endif
303 #endif
304
305 /* Suppress unused-variable warnings by "using" E. */
306 #if ! defined lint || defined __GNUC__
307 # define YYUSE(E) ((void) (E))
308 #else
309 # define YYUSE(E) /* empty */
310 #endif
311
312 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
313 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
314 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
315 _Pragma ("GCC diagnostic push") \
316 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
317 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
318 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
319 _Pragma ("GCC diagnostic pop")
320 #else
321 # define YY_INITIAL_VALUE(Value) Value
322 #endif
323 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
324 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
325 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
326 #endif
327 #ifndef YY_INITIAL_VALUE
328 # define YY_INITIAL_VALUE(Value) /* Nothing. */
329 #endif
330
331
332 #if ! defined yyoverflow || YYERROR_VERBOSE
333
334 /* The parser invokes alloca or malloc; define the necessary symbols. */
335
336 # ifdef YYSTACK_USE_ALLOCA
337 # if YYSTACK_USE_ALLOCA
338 # ifdef __GNUC__
339 # define YYSTACK_ALLOC __builtin_alloca
340 # elif defined __BUILTIN_VA_ARG_INCR
341 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
342 # elif defined _AIX
343 # define YYSTACK_ALLOC __alloca
344 # elif defined _MSC_VER
345 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
346 # define alloca _alloca
347 # else
348 # define YYSTACK_ALLOC alloca
349 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
350 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
351 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
352 # ifndef EXIT_SUCCESS
353 # define EXIT_SUCCESS 0
354 # endif
355 # endif
356 # endif
357 # endif
358 # endif
359
360 # ifdef YYSTACK_ALLOC
361 /* Pacify GCC's 'empty if-body' warning. */
362 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
363 # ifndef YYSTACK_ALLOC_MAXIMUM
364 /* The OS might guarantee only one guard page at the bottom of the stack,
365 and a page size can be as small as 4096 bytes. So we cannot safely
366 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
367 to allow for a few compiler-allocated temporary stack slots. */
368 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
369 # endif
370 # else
371 # define YYSTACK_ALLOC YYMALLOC
372 # define YYSTACK_FREE YYFREE
373 # ifndef YYSTACK_ALLOC_MAXIMUM
374 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
375 # endif
376 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
377 && ! ((defined YYMALLOC || defined malloc) \
378 && (defined YYFREE || defined free)))
379 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
380 # ifndef EXIT_SUCCESS
381 # define EXIT_SUCCESS 0
382 # endif
383 # endif
384 # ifndef YYMALLOC
385 # define YYMALLOC malloc
386 # if ! defined malloc && ! defined EXIT_SUCCESS
387 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
388 # endif
389 # endif
390 # ifndef YYFREE
391 # define YYFREE free
392 # if ! defined free && ! defined EXIT_SUCCESS
393 void free (void *); /* INFRINGES ON USER NAME SPACE */
394 # endif
395 # endif
396 # endif
397 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
398
399
400 #if (! defined yyoverflow \
401 && (! defined __cplusplus \
402 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
403
404 /* A type that is properly aligned for any stack member. */
405 union yyalloc
406 {
407 yytype_int16 yyss_alloc;
408 YYSTYPE yyvs_alloc;
409 };
410
411 /* The size of the maximum gap between one aligned stack and the next. */
412 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
413
414 /* The size of an array large to enough to hold all stacks, each with
415 N elements. */
416 # define YYSTACK_BYTES(N) \
417 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
418 + YYSTACK_GAP_MAXIMUM)
419
420 # define YYCOPY_NEEDED 1
421
422 /* Relocate STACK from its old location to the new one. The
423 local variables YYSIZE and YYSTACKSIZE give the old and new number of
424 elements in the stack, and YYPTR gives the new location of the
425 stack. Advance YYPTR to a properly aligned location for the next
426 stack. */
427 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
428 do \
429 { \
430 YYSIZE_T yynewbytes; \
431 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
432 Stack = &yyptr->Stack_alloc; \
433 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
434 yyptr += yynewbytes / sizeof (*yyptr); \
435 } \
436 while (0)
437
438 #endif
439
440 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
441 /* Copy COUNT objects from SRC to DST. The source and destination do
442 not overlap. */
443 # ifndef YYCOPY
444 # if defined __GNUC__ && 1 < __GNUC__
445 # define YYCOPY(Dst, Src, Count) \
446 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
447 # else
448 # define YYCOPY(Dst, Src, Count) \
449 do \
450 { \
451 YYSIZE_T yyi; \
452 for (yyi = 0; yyi < (Count); yyi++) \
453 (Dst)[yyi] = (Src)[yyi]; \
454 } \
455 while (0)
456 # endif
457 # endif
458 #endif /* !YYCOPY_NEEDED */
459
460 /* YYFINAL -- State number of the termination state. */
461 #define YYFINAL 6
462 /* YYLAST -- Last index in YYTABLE. */
463 #define YYLAST 35
464
465 /* YYNTOKENS -- Number of terminals. */
466 #define YYNTOKENS 23
467 /* YYNNTS -- Number of nonterminals. */
468 #define YYNNTS 20
469 /* YYNRULES -- Number of rules. */
470 #define YYNRULES 41
471 /* YYNSTATES -- Number of states. */
472 #define YYNSTATES 47
473
474 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
475 by yylex, with out-of-bounds checking. */
476 #define YYUNDEFTOK 2
477 #define YYMAXUTOK 277
478
479 #define YYTRANSLATE(YYX) \
480 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
481
482 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
483 as returned by yylex, without out-of-bounds checking. */
484 static const yytype_uint8 yytranslate[] =
485 {
486 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
511 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
512 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
513 15, 16, 17, 18, 19, 20, 21, 22
514 };
515
516 #if YYDEBUG
517 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
518 static const yytype_uint16 yyrline[] =
519 {
520 0, 91, 91, 93, 97, 98, 101, 103, 106, 108,
521 109, 114, 113, 133, 132, 156, 155, 178, 179, 180,
522 181, 185, 186, 190, 210, 232, 254, 276, 298, 316,
523 344, 345, 346, 349, 351, 355, 356, 357, 360, 362,
524 367, 366
525 };
526 #endif
527
528 #if YYDEBUG || YYERROR_VERBOSE || 0
529 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
530 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
531 static const char *const yytname[] =
532 {
533 "$end", "error", "$undefined", "TOK_BOOLEAN", "TOK_INTEGER", "TOK_HEX",
534 "TOK_INTEGER64", "TOK_HEX64", "TOK_FLOAT", "TOK_STRING", "TOK_NAME",
535 "TOK_EQUALS", "TOK_NEWLINE", "TOK_ARRAY_START", "TOK_ARRAY_END",
536 "TOK_LIST_START", "TOK_LIST_END", "TOK_COMMA", "TOK_GROUP_START",
537 "TOK_GROUP_END", "TOK_SEMICOLON", "TOK_GARBAGE", "TOK_ERROR", "$accept",
538 "configuration", "setting_list", "setting_list_optional",
539 "setting_terminator", "setting", "$@1", "array", "$@2", "list", "$@3",
540 "value", "string", "simple_value", "value_list", "value_list_optional",
541 "simple_value_list", "simple_value_list_optional", "group", "$@4", YY_NULLPTR
542 };
543 #endif
544
545 # ifdef YYPRINT
546 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
547 (internal) symbol number NUM (which must be that of a token). */
548 static const yytype_uint16 yytoknum[] =
549 {
550 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
551 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
552 275, 276, 277
553 };
554 # endif
555
556 #define YYPACT_NINF -26
557
558 #define yypact_value_is_default(Yystate) \
559 (!!((Yystate) == (-26)))
560
561 #define YYTABLE_NINF -1
562
563 #define yytable_value_is_error(Yytable_value) \
564 0
565
566 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
567 STATE-NUM. */
568 static const yytype_int8 yypact[] =
569 {
570 -8, -26, 12, -8, -26, 5, -26, -26, 0, -26,
571 -26, -26, -26, -26, -26, -26, -26, -26, -26, -26,
572 -26, -6, 10, -26, -26, 23, 0, -8, -26, -26,
573 -26, -26, -26, 3, 7, -26, 6, 8, -8, 14,
574 23, -26, 0, -26, -26, -26, -26
575 };
576
577 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
578 Performed when YYTABLE does not specify something else to do. Zero
579 means the default is an error. */
580 static const yytype_uint8 yydefact[] =
581 {
582 2, 11, 0, 3, 4, 0, 1, 5, 0, 23,
583 24, 26, 25, 27, 28, 21, 13, 15, 40, 18,
584 19, 8, 29, 17, 20, 38, 33, 6, 10, 9,
585 12, 22, 35, 39, 0, 30, 34, 0, 7, 0,
586 37, 14, 32, 16, 41, 36, 31
587 };
588
589 /* YYPGOTO[NTERM-NUM]. */
590 static const yytype_int8 yypgoto[] =
591 {
592 -26, -26, -5, -26, -26, -3, -26, -26, -26, -26,
593 -26, -25, -26, -15, -26, -26, -26, -26, -26, -26
594 };
595
596 /* YYDEFGOTO[NTERM-NUM]. */
597 static const yytype_int8 yydefgoto[] =
598 {
599 -1, 2, 3, 39, 30, 4, 5, 19, 25, 20,
600 26, 21, 22, 23, 36, 37, 33, 34, 24, 27
601 };
602
603 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
604 positive, shift that token. If negative, reduce the rule whose
605 number is the opposite. If YYTABLE_NINF, syntax error. */
606 static const yytype_uint8 yytable[] =
607 {
608 7, 35, 1, 9, 10, 11, 12, 13, 14, 15,
609 32, 28, 6, 16, 29, 17, 8, 46, 18, 31,
610 40, 41, 38, 42, 43, 45, 9, 10, 11, 12,
611 13, 14, 15, 44, 0, 7
612 };
613
614 static const yytype_int8 yycheck[] =
615 {
616 3, 26, 10, 3, 4, 5, 6, 7, 8, 9,
617 25, 17, 0, 13, 20, 15, 11, 42, 18, 9,
618 17, 14, 27, 17, 16, 40, 3, 4, 5, 6,
619 7, 8, 9, 19, -1, 38
620 };
621
622 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
623 symbol of state STATE-NUM. */
624 static const yytype_uint8 yystos[] =
625 {
626 0, 10, 24, 25, 28, 29, 0, 28, 11, 3,
627 4, 5, 6, 7, 8, 9, 13, 15, 18, 30,
628 32, 34, 35, 36, 41, 31, 33, 42, 17, 20,
629 27, 9, 36, 39, 40, 34, 37, 38, 25, 26,
630 17, 14, 17, 16, 19, 36, 34
631 };
632
633 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
634 static const yytype_uint8 yyr1[] =
635 {
636 0, 23, 24, 24, 25, 25, 26, 26, 27, 27,
637 27, 29, 28, 31, 30, 33, 32, 34, 34, 34,
638 34, 35, 35, 36, 36, 36, 36, 36, 36, 36,
639 37, 37, 37, 38, 38, 39, 39, 39, 40, 40,
640 42, 41
641 };
642
643 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
644 static const yytype_uint8 yyr2[] =
645 {
646 0, 2, 0, 1, 1, 2, 0, 1, 0, 1,
647 1, 0, 5, 0, 4, 0, 4, 1, 1, 1,
648 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
649 1, 3, 2, 0, 1, 1, 3, 2, 0, 1,
650 0, 4
651 };
652
653
654 #define yyerrok (yyerrstatus = 0)
655 #define yyclearin (yychar = YYEMPTY)
656 #define YYEMPTY (-2)
657 #define YYEOF 0
658
659 #define YYACCEPT goto yyacceptlab
660 #define YYABORT goto yyabortlab
661 #define YYERROR goto yyerrorlab
662
663
664 #define YYRECOVERING() (!!yyerrstatus)
665
666 #define YYBACKUP(Token, Value) \
667 do \
668 if (yychar == YYEMPTY) \
669 { \
670 yychar = (Token); \
671 yylval = (Value); \
672 YYPOPSTACK (yylen); \
673 yystate = *yyssp; \
674 goto yybackup; \
675 } \
676 else \
677 { \
678 yyerror (scanner, ctx, scan_ctx, YY_("syntax error: cannot back up")); \
679 YYERROR; \
680 } \
681 while (0)
682
683 /* Error token number */
684 #define YYTERROR 1
685 #define YYERRCODE 256
686
687
688
689 /* Enable debugging if requested. */
690 #if YYDEBUG
691
692 # ifndef YYFPRINTF
693 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
694 # define YYFPRINTF fprintf
695 # endif
696
697 # define YYDPRINTF(Args) \
698 do { \
699 if (yydebug) \
700 YYFPRINTF Args; \
701 } while (0)
702
703 /* This macro is provided for backward compatibility. */
704 #ifndef YY_LOCATION_PRINT
705 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
706 #endif
707
708
709 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
710 do { \
711 if (yydebug) \
712 { \
713 YYFPRINTF (stderr, "%s ", Title); \
714 yy_symbol_print (stderr, \
715 Type, Value, scanner, ctx, scan_ctx); \
716 YYFPRINTF (stderr, "\n"); \
717 } \
718 } while (0)
719
720
721 /*----------------------------------------.
722 | Print this symbol's value on YYOUTPUT. |
723 `----------------------------------------*/
724
725 static void
yy_symbol_value_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,void * scanner,struct parse_context * ctx,struct scan_context * scan_ctx)726 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
727 {
728 FILE *yyo = yyoutput;
729 YYUSE (yyo);
730 YYUSE (scanner);
731 YYUSE (ctx);
732 YYUSE (scan_ctx);
733 if (!yyvaluep)
734 return;
735 # ifdef YYPRINT
736 if (yytype < YYNTOKENS)
737 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
738 # endif
739 YYUSE (yytype);
740 }
741
742
743 /*--------------------------------.
744 | Print this symbol on YYOUTPUT. |
745 `--------------------------------*/
746
747 static void
yy_symbol_print(FILE * yyoutput,int yytype,YYSTYPE const * const yyvaluep,void * scanner,struct parse_context * ctx,struct scan_context * scan_ctx)748 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
749 {
750 YYFPRINTF (yyoutput, "%s %s (",
751 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
752
753 yy_symbol_value_print (yyoutput, yytype, yyvaluep, scanner, ctx, scan_ctx);
754 YYFPRINTF (yyoutput, ")");
755 }
756
757 /*------------------------------------------------------------------.
758 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
759 | TOP (included). |
760 `------------------------------------------------------------------*/
761
762 static void
yy_stack_print(yytype_int16 * yybottom,yytype_int16 * yytop)763 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
764 {
765 YYFPRINTF (stderr, "Stack now");
766 for (; yybottom <= yytop; yybottom++)
767 {
768 int yybot = *yybottom;
769 YYFPRINTF (stderr, " %d", yybot);
770 }
771 YYFPRINTF (stderr, "\n");
772 }
773
774 # define YY_STACK_PRINT(Bottom, Top) \
775 do { \
776 if (yydebug) \
777 yy_stack_print ((Bottom), (Top)); \
778 } while (0)
779
780
781 /*------------------------------------------------.
782 | Report that the YYRULE is going to be reduced. |
783 `------------------------------------------------*/
784
785 static void
yy_reduce_print(yytype_int16 * yyssp,YYSTYPE * yyvsp,int yyrule,void * scanner,struct parse_context * ctx,struct scan_context * scan_ctx)786 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
787 {
788 unsigned long int yylno = yyrline[yyrule];
789 int yynrhs = yyr2[yyrule];
790 int yyi;
791 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
792 yyrule - 1, yylno);
793 /* The symbols being reduced. */
794 for (yyi = 0; yyi < yynrhs; yyi++)
795 {
796 YYFPRINTF (stderr, " $%d = ", yyi + 1);
797 yy_symbol_print (stderr,
798 yystos[yyssp[yyi + 1 - yynrhs]],
799 &(yyvsp[(yyi + 1) - (yynrhs)])
800 , scanner, ctx, scan_ctx);
801 YYFPRINTF (stderr, "\n");
802 }
803 }
804
805 # define YY_REDUCE_PRINT(Rule) \
806 do { \
807 if (yydebug) \
808 yy_reduce_print (yyssp, yyvsp, Rule, scanner, ctx, scan_ctx); \
809 } while (0)
810
811 /* Nonzero means print parse trace. It is left uninitialized so that
812 multiple parsers can coexist. */
813 int yydebug;
814 #else /* !YYDEBUG */
815 # define YYDPRINTF(Args)
816 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
817 # define YY_STACK_PRINT(Bottom, Top)
818 # define YY_REDUCE_PRINT(Rule)
819 #endif /* !YYDEBUG */
820
821
822 /* YYINITDEPTH -- initial size of the parser's stacks. */
823 #ifndef YYINITDEPTH
824 # define YYINITDEPTH 200
825 #endif
826
827 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
828 if the built-in stack extension method is used).
829
830 Do not make this value too large; the results are undefined if
831 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
832 evaluated with infinite-precision integer arithmetic. */
833
834 #ifndef YYMAXDEPTH
835 # define YYMAXDEPTH 10000
836 #endif
837
838
839 #if YYERROR_VERBOSE
840
841 # ifndef yystrlen
842 # if defined __GLIBC__ && defined _STRING_H
843 # define yystrlen strlen
844 # else
845 /* Return the length of YYSTR. */
846 static YYSIZE_T
yystrlen(const char * yystr)847 yystrlen (const char *yystr)
848 {
849 YYSIZE_T yylen;
850 for (yylen = 0; yystr[yylen]; yylen++)
851 continue;
852 return yylen;
853 }
854 # endif
855 # endif
856
857 # ifndef yystpcpy
858 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
859 # define yystpcpy stpcpy
860 # else
861 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
862 YYDEST. */
863 static char *
yystpcpy(char * yydest,const char * yysrc)864 yystpcpy (char *yydest, const char *yysrc)
865 {
866 char *yyd = yydest;
867 const char *yys = yysrc;
868
869 while ((*yyd++ = *yys++) != '\0')
870 continue;
871
872 return yyd - 1;
873 }
874 # endif
875 # endif
876
877 # ifndef yytnamerr
878 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
879 quotes and backslashes, so that it's suitable for yyerror. The
880 heuristic is that double-quoting is unnecessary unless the string
881 contains an apostrophe, a comma, or backslash (other than
882 backslash-backslash). YYSTR is taken from yytname. If YYRES is
883 null, do not copy; instead, return the length of what the result
884 would have been. */
885 static YYSIZE_T
yytnamerr(char * yyres,const char * yystr)886 yytnamerr (char *yyres, const char *yystr)
887 {
888 if (*yystr == '"')
889 {
890 YYSIZE_T yyn = 0;
891 char const *yyp = yystr;
892
893 for (;;)
894 switch (*++yyp)
895 {
896 case '\'':
897 case ',':
898 goto do_not_strip_quotes;
899
900 case '\\':
901 if (*++yyp != '\\')
902 goto do_not_strip_quotes;
903 /* Fall through. */
904 default:
905 if (yyres)
906 yyres[yyn] = *yyp;
907 yyn++;
908 break;
909
910 case '"':
911 if (yyres)
912 yyres[yyn] = '\0';
913 return yyn;
914 }
915 do_not_strip_quotes: ;
916 }
917
918 if (! yyres)
919 return yystrlen (yystr);
920
921 return yystpcpy (yyres, yystr) - yyres;
922 }
923 # endif
924
925 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
926 about the unexpected token YYTOKEN for the state stack whose top is
927 YYSSP.
928
929 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
930 not large enough to hold the message. In that case, also set
931 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
932 required number of bytes is too large to store. */
933 static int
yysyntax_error(YYSIZE_T * yymsg_alloc,char ** yymsg,yytype_int16 * yyssp,int yytoken)934 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
935 yytype_int16 *yyssp, int yytoken)
936 {
937 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
938 YYSIZE_T yysize = yysize0;
939 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
940 /* Internationalized format string. */
941 const char *yyformat = YY_NULLPTR;
942 /* Arguments of yyformat. */
943 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
944 /* Number of reported tokens (one for the "unexpected", one per
945 "expected"). */
946 int yycount = 0;
947
948 /* There are many possibilities here to consider:
949 - If this state is a consistent state with a default action, then
950 the only way this function was invoked is if the default action
951 is an error action. In that case, don't check for expected
952 tokens because there are none.
953 - The only way there can be no lookahead present (in yychar) is if
954 this state is a consistent state with a default action. Thus,
955 detecting the absence of a lookahead is sufficient to determine
956 that there is no unexpected or expected token to report. In that
957 case, just report a simple "syntax error".
958 - Don't assume there isn't a lookahead just because this state is a
959 consistent state with a default action. There might have been a
960 previous inconsistent state, consistent state with a non-default
961 action, or user semantic action that manipulated yychar.
962 - Of course, the expected token list depends on states to have
963 correct lookahead information, and it depends on the parser not
964 to perform extra reductions after fetching a lookahead from the
965 scanner and before detecting a syntax error. Thus, state merging
966 (from LALR or IELR) and default reductions corrupt the expected
967 token list. However, the list is correct for canonical LR with
968 one exception: it will still contain any token that will not be
969 accepted due to an error action in a later state.
970 */
971 if (yytoken != YYEMPTY)
972 {
973 int yyn = yypact[*yyssp];
974 yyarg[yycount++] = yytname[yytoken];
975 if (!yypact_value_is_default (yyn))
976 {
977 /* Start YYX at -YYN if negative to avoid negative indexes in
978 YYCHECK. In other words, skip the first -YYN actions for
979 this state because they are default actions. */
980 int yyxbegin = yyn < 0 ? -yyn : 0;
981 /* Stay within bounds of both yycheck and yytname. */
982 int yychecklim = YYLAST - yyn + 1;
983 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
984 int yyx;
985
986 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
987 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
988 && !yytable_value_is_error (yytable[yyx + yyn]))
989 {
990 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
991 {
992 yycount = 1;
993 yysize = yysize0;
994 break;
995 }
996 yyarg[yycount++] = yytname[yyx];
997 {
998 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
999 if (! (yysize <= yysize1
1000 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1001 return 2;
1002 yysize = yysize1;
1003 }
1004 }
1005 }
1006 }
1007
1008 switch (yycount)
1009 {
1010 # define YYCASE_(N, S) \
1011 case N: \
1012 yyformat = S; \
1013 break
1014 YYCASE_(0, YY_("syntax error"));
1015 YYCASE_(1, YY_("syntax error, unexpected %s"));
1016 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1017 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1018 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1019 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1020 # undef YYCASE_
1021 }
1022
1023 {
1024 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1025 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1026 return 2;
1027 yysize = yysize1;
1028 }
1029
1030 if (*yymsg_alloc < yysize)
1031 {
1032 *yymsg_alloc = 2 * yysize;
1033 if (! (yysize <= *yymsg_alloc
1034 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1035 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1036 return 1;
1037 }
1038
1039 /* Avoid sprintf, as that infringes on the user's name space.
1040 Don't have undefined behavior even if the translation
1041 produced a string with the wrong number of "%s"s. */
1042 {
1043 char *yyp = *yymsg;
1044 int yyi = 0;
1045 while ((*yyp = *yyformat) != '\0')
1046 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1047 {
1048 yyp += yytnamerr (yyp, yyarg[yyi++]);
1049 yyformat += 2;
1050 }
1051 else
1052 {
1053 yyp++;
1054 yyformat++;
1055 }
1056 }
1057 return 0;
1058 }
1059 #endif /* YYERROR_VERBOSE */
1060
1061 /*-----------------------------------------------.
1062 | Release the memory associated to this symbol. |
1063 `-----------------------------------------------*/
1064
1065 static void
yydestruct(const char * yymsg,int yytype,YYSTYPE * yyvaluep,void * scanner,struct parse_context * ctx,struct scan_context * scan_ctx)1066 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
1067 {
1068 YYUSE (yyvaluep);
1069 YYUSE (scanner);
1070 YYUSE (ctx);
1071 YYUSE (scan_ctx);
1072 if (!yymsg)
1073 yymsg = "Deleting";
1074 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1075
1076 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1077 YYUSE (yytype);
1078 YY_IGNORE_MAYBE_UNINITIALIZED_END
1079 }
1080
1081
1082
1083
1084 /*----------.
1085 | yyparse. |
1086 `----------*/
1087
1088 int
yyparse(void * scanner,struct parse_context * ctx,struct scan_context * scan_ctx)1089 yyparse (void *scanner, struct parse_context *ctx, struct scan_context *scan_ctx)
1090 {
1091 /* The lookahead symbol. */
1092 int yychar;
1093
1094
1095 /* The semantic value of the lookahead symbol. */
1096 /* Default value used for initialization, for pacifying older GCCs
1097 or non-GCC compilers. */
1098 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1099 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1100
1101 /* Number of syntax errors so far. */
1102 int yynerrs;
1103
1104 int yystate;
1105 /* Number of tokens to shift before error messages enabled. */
1106 int yyerrstatus;
1107
1108 /* The stacks and their tools:
1109 'yyss': related to states.
1110 'yyvs': related to semantic values.
1111
1112 Refer to the stacks through separate pointers, to allow yyoverflow
1113 to reallocate them elsewhere. */
1114
1115 /* The state stack. */
1116 yytype_int16 yyssa[YYINITDEPTH];
1117 yytype_int16 *yyss;
1118 yytype_int16 *yyssp;
1119
1120 /* The semantic value stack. */
1121 YYSTYPE yyvsa[YYINITDEPTH];
1122 YYSTYPE *yyvs;
1123 YYSTYPE *yyvsp;
1124
1125 YYSIZE_T yystacksize;
1126
1127 int yyn;
1128 int yyresult;
1129 /* Lookahead token as an internal (translated) token number. */
1130 int yytoken = 0;
1131 /* The variables used to return semantic value and location from the
1132 action routines. */
1133 YYSTYPE yyval;
1134
1135 #if YYERROR_VERBOSE
1136 /* Buffer for error messages, and its allocated size. */
1137 char yymsgbuf[128];
1138 char *yymsg = yymsgbuf;
1139 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1140 #endif
1141
1142 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1143
1144 /* The number of symbols on the RHS of the reduced rule.
1145 Keep to zero when no symbol should be popped. */
1146 int yylen = 0;
1147
1148 yyssp = yyss = yyssa;
1149 yyvsp = yyvs = yyvsa;
1150 yystacksize = YYINITDEPTH;
1151
1152 YYDPRINTF ((stderr, "Starting parse\n"));
1153
1154 yystate = 0;
1155 yyerrstatus = 0;
1156 yynerrs = 0;
1157 yychar = YYEMPTY; /* Cause a token to be read. */
1158 goto yysetstate;
1159
1160 /*------------------------------------------------------------.
1161 | yynewstate -- Push a new state, which is found in yystate. |
1162 `------------------------------------------------------------*/
1163 yynewstate:
1164 /* In all cases, when you get here, the value and location stacks
1165 have just been pushed. So pushing a state here evens the stacks. */
1166 yyssp++;
1167
1168 yysetstate:
1169 *yyssp = yystate;
1170
1171 if (yyss + yystacksize - 1 <= yyssp)
1172 {
1173 /* Get the current used size of the three stacks, in elements. */
1174 YYSIZE_T yysize = yyssp - yyss + 1;
1175
1176 #ifdef yyoverflow
1177 {
1178 /* Give user a chance to reallocate the stack. Use copies of
1179 these so that the &'s don't force the real ones into
1180 memory. */
1181 YYSTYPE *yyvs1 = yyvs;
1182 yytype_int16 *yyss1 = yyss;
1183
1184 /* Each stack pointer address is followed by the size of the
1185 data in use in that stack, in bytes. This used to be a
1186 conditional around just the two extra args, but that might
1187 be undefined if yyoverflow is a macro. */
1188 yyoverflow (YY_("memory exhausted"),
1189 &yyss1, yysize * sizeof (*yyssp),
1190 &yyvs1, yysize * sizeof (*yyvsp),
1191 &yystacksize);
1192
1193 yyss = yyss1;
1194 yyvs = yyvs1;
1195 }
1196 #else /* no yyoverflow */
1197 # ifndef YYSTACK_RELOCATE
1198 goto yyexhaustedlab;
1199 # else
1200 /* Extend the stack our own way. */
1201 if (YYMAXDEPTH <= yystacksize)
1202 goto yyexhaustedlab;
1203 yystacksize *= 2;
1204 if (YYMAXDEPTH < yystacksize)
1205 yystacksize = YYMAXDEPTH;
1206
1207 {
1208 yytype_int16 *yyss1 = yyss;
1209 union yyalloc *yyptr =
1210 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1211 if (! yyptr)
1212 goto yyexhaustedlab;
1213 YYSTACK_RELOCATE (yyss_alloc, yyss);
1214 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1215 # undef YYSTACK_RELOCATE
1216 if (yyss1 != yyssa)
1217 YYSTACK_FREE (yyss1);
1218 }
1219 # endif
1220 #endif /* no yyoverflow */
1221
1222 yyssp = yyss + yysize - 1;
1223 yyvsp = yyvs + yysize - 1;
1224
1225 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1226 (unsigned long int) yystacksize));
1227
1228 if (yyss + yystacksize - 1 <= yyssp)
1229 YYABORT;
1230 }
1231
1232 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1233
1234 if (yystate == YYFINAL)
1235 YYACCEPT;
1236
1237 goto yybackup;
1238
1239 /*-----------.
1240 | yybackup. |
1241 `-----------*/
1242 yybackup:
1243
1244 /* Do appropriate processing given the current state. Read a
1245 lookahead token if we need one and don't already have one. */
1246
1247 /* First try to decide what to do without reference to lookahead token. */
1248 yyn = yypact[yystate];
1249 if (yypact_value_is_default (yyn))
1250 goto yydefault;
1251
1252 /* Not known => get a lookahead token if don't already have one. */
1253
1254 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1255 if (yychar == YYEMPTY)
1256 {
1257 YYDPRINTF ((stderr, "Reading a token: "));
1258 yychar = yylex (&yylval, scanner);
1259 }
1260
1261 if (yychar <= YYEOF)
1262 {
1263 yychar = yytoken = YYEOF;
1264 YYDPRINTF ((stderr, "Now at end of input.\n"));
1265 }
1266 else
1267 {
1268 yytoken = YYTRANSLATE (yychar);
1269 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1270 }
1271
1272 /* If the proper action on seeing token YYTOKEN is to reduce or to
1273 detect an error, take that action. */
1274 yyn += yytoken;
1275 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1276 goto yydefault;
1277 yyn = yytable[yyn];
1278 if (yyn <= 0)
1279 {
1280 if (yytable_value_is_error (yyn))
1281 goto yyerrlab;
1282 yyn = -yyn;
1283 goto yyreduce;
1284 }
1285
1286 /* Count tokens shifted since error; after three, turn off error
1287 status. */
1288 if (yyerrstatus)
1289 yyerrstatus--;
1290
1291 /* Shift the lookahead token. */
1292 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1293
1294 /* Discard the shifted token. */
1295 yychar = YYEMPTY;
1296
1297 yystate = yyn;
1298 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1299 *++yyvsp = yylval;
1300 YY_IGNORE_MAYBE_UNINITIALIZED_END
1301
1302 goto yynewstate;
1303
1304
1305 /*-----------------------------------------------------------.
1306 | yydefault -- do the default action for the current state. |
1307 `-----------------------------------------------------------*/
1308 yydefault:
1309 yyn = yydefact[yystate];
1310 if (yyn == 0)
1311 goto yyerrlab;
1312 goto yyreduce;
1313
1314
1315 /*-----------------------------.
1316 | yyreduce -- Do a reduction. |
1317 `-----------------------------*/
1318 yyreduce:
1319 /* yyn is the number of a rule to reduce with. */
1320 yylen = yyr2[yyn];
1321
1322 /* If YYLEN is nonzero, implement the default value of the action:
1323 '$$ = $1'.
1324
1325 Otherwise, the following line sets YYVAL to garbage.
1326 This behavior is undocumented and Bison
1327 users should not rely upon it. Assigning to YYVAL
1328 unconditionally makes the parser a bit smaller, and it avoids a
1329 GCC warning that YYVAL may be used uninitialized. */
1330 yyval = yyvsp[1-yylen];
1331
1332
1333 YY_REDUCE_PRINT (yyn);
1334 switch (yyn)
1335 {
1336 case 11:
1337 #line 114 "grammar.y" /* yacc.c:1646 */
1338 {
1339 ctx->setting = config_setting_add(ctx->parent, (yyvsp[0].sval), CONFIG_TYPE_NONE);
1340
1341 if(ctx->setting == NULL)
1342 {
1343 libconfig_yyerror(scanner, ctx, scan_ctx, err_duplicate_setting);
1344 YYABORT;
1345 }
1346 else
1347 {
1348 CAPTURE_PARSE_POS(ctx->setting);
1349 }
1350 }
1351 #line 1352 "grammar.c" /* yacc.c:1646 */
1352 break;
1353
1354 case 13:
1355 #line 133 "grammar.y" /* yacc.c:1646 */
1356 {
1357 if(IN_LIST())
1358 {
1359 ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_ARRAY);
1360 CAPTURE_PARSE_POS(ctx->parent);
1361 }
1362 else
1363 {
1364 ctx->setting->type = CONFIG_TYPE_ARRAY;
1365 ctx->parent = ctx->setting;
1366 ctx->setting = NULL;
1367 }
1368 }
1369 #line 1370 "grammar.c" /* yacc.c:1646 */
1370 break;
1371
1372 case 14:
1373 #line 148 "grammar.y" /* yacc.c:1646 */
1374 {
1375 if(ctx->parent)
1376 ctx->parent = ctx->parent->parent;
1377 }
1378 #line 1379 "grammar.c" /* yacc.c:1646 */
1379 break;
1380
1381 case 15:
1382 #line 156 "grammar.y" /* yacc.c:1646 */
1383 {
1384 if(IN_LIST())
1385 {
1386 ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_LIST);
1387 CAPTURE_PARSE_POS(ctx->parent);
1388 }
1389 else
1390 {
1391 ctx->setting->type = CONFIG_TYPE_LIST;
1392 ctx->parent = ctx->setting;
1393 ctx->setting = NULL;
1394 }
1395 }
1396 #line 1397 "grammar.c" /* yacc.c:1646 */
1397 break;
1398
1399 case 16:
1400 #line 171 "grammar.y" /* yacc.c:1646 */
1401 {
1402 if(ctx->parent)
1403 ctx->parent = ctx->parent->parent;
1404 }
1405 #line 1406 "grammar.c" /* yacc.c:1646 */
1406 break;
1407
1408 case 21:
1409 #line 185 "grammar.y" /* yacc.c:1646 */
1410 { parsectx_append_string(ctx, (yyvsp[0].sval)); free((yyvsp[0].sval)); }
1411 #line 1412 "grammar.c" /* yacc.c:1646 */
1412 break;
1413
1414 case 22:
1415 #line 186 "grammar.y" /* yacc.c:1646 */
1416 { parsectx_append_string(ctx, (yyvsp[0].sval)); free((yyvsp[0].sval)); }
1417 #line 1418 "grammar.c" /* yacc.c:1646 */
1418 break;
1419
1420 case 23:
1421 #line 191 "grammar.y" /* yacc.c:1646 */
1422 {
1423 if(IN_ARRAY() || IN_LIST())
1424 {
1425 config_setting_t *e = config_setting_set_bool_elem(ctx->parent, -1,
1426 (int)(yyvsp[0].ival));
1427
1428 if(! e)
1429 {
1430 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1431 YYABORT;
1432 }
1433 else
1434 {
1435 CAPTURE_PARSE_POS(e);
1436 }
1437 }
1438 else
1439 config_setting_set_bool(ctx->setting, (int)(yyvsp[0].ival));
1440 }
1441 #line 1442 "grammar.c" /* yacc.c:1646 */
1442 break;
1443
1444 case 24:
1445 #line 211 "grammar.y" /* yacc.c:1646 */
1446 {
1447 if(IN_ARRAY() || IN_LIST())
1448 {
1449 config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[0].ival));
1450 if(! e)
1451 {
1452 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1453 YYABORT;
1454 }
1455 else
1456 {
1457 config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
1458 CAPTURE_PARSE_POS(e);
1459 }
1460 }
1461 else
1462 {
1463 config_setting_set_int(ctx->setting, (yyvsp[0].ival));
1464 config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
1465 }
1466 }
1467 #line 1468 "grammar.c" /* yacc.c:1646 */
1468 break;
1469
1470 case 25:
1471 #line 233 "grammar.y" /* yacc.c:1646 */
1472 {
1473 if(IN_ARRAY() || IN_LIST())
1474 {
1475 config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[0].llval));
1476 if(! e)
1477 {
1478 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1479 YYABORT;
1480 }
1481 else
1482 {
1483 config_setting_set_format(e, CONFIG_FORMAT_DEFAULT);
1484 CAPTURE_PARSE_POS(e);
1485 }
1486 }
1487 else
1488 {
1489 config_setting_set_int64(ctx->setting, (yyvsp[0].llval));
1490 config_setting_set_format(ctx->setting, CONFIG_FORMAT_DEFAULT);
1491 }
1492 }
1493 #line 1494 "grammar.c" /* yacc.c:1646 */
1494 break;
1495
1496 case 26:
1497 #line 255 "grammar.y" /* yacc.c:1646 */
1498 {
1499 if(IN_ARRAY() || IN_LIST())
1500 {
1501 config_setting_t *e = config_setting_set_int_elem(ctx->parent, -1, (yyvsp[0].ival));
1502 if(! e)
1503 {
1504 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1505 YYABORT;
1506 }
1507 else
1508 {
1509 config_setting_set_format(e, CONFIG_FORMAT_HEX);
1510 CAPTURE_PARSE_POS(e);
1511 }
1512 }
1513 else
1514 {
1515 config_setting_set_int(ctx->setting, (yyvsp[0].ival));
1516 config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
1517 }
1518 }
1519 #line 1520 "grammar.c" /* yacc.c:1646 */
1520 break;
1521
1522 case 27:
1523 #line 277 "grammar.y" /* yacc.c:1646 */
1524 {
1525 if(IN_ARRAY() || IN_LIST())
1526 {
1527 config_setting_t *e = config_setting_set_int64_elem(ctx->parent, -1, (yyvsp[0].llval));
1528 if(! e)
1529 {
1530 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1531 YYABORT;
1532 }
1533 else
1534 {
1535 config_setting_set_format(e, CONFIG_FORMAT_HEX);
1536 CAPTURE_PARSE_POS(e);
1537 }
1538 }
1539 else
1540 {
1541 config_setting_set_int64(ctx->setting, (yyvsp[0].llval));
1542 config_setting_set_format(ctx->setting, CONFIG_FORMAT_HEX);
1543 }
1544 }
1545 #line 1546 "grammar.c" /* yacc.c:1646 */
1546 break;
1547
1548 case 28:
1549 #line 299 "grammar.y" /* yacc.c:1646 */
1550 {
1551 if(IN_ARRAY() || IN_LIST())
1552 {
1553 config_setting_t *e = config_setting_set_float_elem(ctx->parent, -1, (yyvsp[0].fval));
1554 if(! e)
1555 {
1556 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1557 YYABORT;
1558 }
1559 else
1560 {
1561 CAPTURE_PARSE_POS(e);
1562 }
1563 }
1564 else
1565 config_setting_set_float(ctx->setting, (yyvsp[0].fval));
1566 }
1567 #line 1568 "grammar.c" /* yacc.c:1646 */
1568 break;
1569
1570 case 29:
1571 #line 317 "grammar.y" /* yacc.c:1646 */
1572 {
1573 if(IN_ARRAY() || IN_LIST())
1574 {
1575 const char *s = parsectx_take_string(ctx);
1576 config_setting_t *e = config_setting_set_string_elem(ctx->parent, -1, s);
1577 __delete(s);
1578
1579 if(! e)
1580 {
1581 libconfig_yyerror(scanner, ctx, scan_ctx, err_array_elem_type);
1582 YYABORT;
1583 }
1584 else
1585 {
1586 CAPTURE_PARSE_POS(e);
1587 }
1588 }
1589 else
1590 {
1591 const char *s = parsectx_take_string(ctx);
1592 config_setting_set_string(ctx->setting, s);
1593 __delete(s);
1594 }
1595 }
1596 #line 1597 "grammar.c" /* yacc.c:1646 */
1597 break;
1598
1599 case 40:
1600 #line 367 "grammar.y" /* yacc.c:1646 */
1601 {
1602 if(IN_LIST())
1603 {
1604 ctx->parent = config_setting_add(ctx->parent, NULL, CONFIG_TYPE_GROUP);
1605 CAPTURE_PARSE_POS(ctx->parent);
1606 }
1607 else
1608 {
1609 ctx->setting->type = CONFIG_TYPE_GROUP;
1610 ctx->parent = ctx->setting;
1611 ctx->setting = NULL;
1612 }
1613 }
1614 #line 1615 "grammar.c" /* yacc.c:1646 */
1615 break;
1616
1617 case 41:
1618 #line 382 "grammar.y" /* yacc.c:1646 */
1619 {
1620 if(ctx->parent)
1621 ctx->parent = ctx->parent->parent;
1622 }
1623 #line 1624 "grammar.c" /* yacc.c:1646 */
1624 break;
1625
1626
1627 #line 1628 "grammar.c" /* yacc.c:1646 */
1628 default: break;
1629 }
1630 /* User semantic actions sometimes alter yychar, and that requires
1631 that yytoken be updated with the new translation. We take the
1632 approach of translating immediately before every use of yytoken.
1633 One alternative is translating here after every semantic action,
1634 but that translation would be missed if the semantic action invokes
1635 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1636 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1637 incorrect destructor might then be invoked immediately. In the
1638 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1639 to an incorrect destructor call or verbose syntax error message
1640 before the lookahead is translated. */
1641 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1642
1643 YYPOPSTACK (yylen);
1644 yylen = 0;
1645 YY_STACK_PRINT (yyss, yyssp);
1646
1647 *++yyvsp = yyval;
1648
1649 /* Now 'shift' the result of the reduction. Determine what state
1650 that goes to, based on the state we popped back to and the rule
1651 number reduced by. */
1652
1653 yyn = yyr1[yyn];
1654
1655 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1656 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1657 yystate = yytable[yystate];
1658 else
1659 yystate = yydefgoto[yyn - YYNTOKENS];
1660
1661 goto yynewstate;
1662
1663
1664 /*--------------------------------------.
1665 | yyerrlab -- here on detecting error. |
1666 `--------------------------------------*/
1667 yyerrlab:
1668 /* Make sure we have latest lookahead translation. See comments at
1669 user semantic actions for why this is necessary. */
1670 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1671
1672 /* If not already recovering from an error, report this error. */
1673 if (!yyerrstatus)
1674 {
1675 ++yynerrs;
1676 #if ! YYERROR_VERBOSE
1677 yyerror (scanner, ctx, scan_ctx, YY_("syntax error"));
1678 #else
1679 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1680 yyssp, yytoken)
1681 {
1682 char const *yymsgp = YY_("syntax error");
1683 int yysyntax_error_status;
1684 yysyntax_error_status = YYSYNTAX_ERROR;
1685 if (yysyntax_error_status == 0)
1686 yymsgp = yymsg;
1687 else if (yysyntax_error_status == 1)
1688 {
1689 if (yymsg != yymsgbuf)
1690 YYSTACK_FREE (yymsg);
1691 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1692 if (!yymsg)
1693 {
1694 yymsg = yymsgbuf;
1695 yymsg_alloc = sizeof yymsgbuf;
1696 yysyntax_error_status = 2;
1697 }
1698 else
1699 {
1700 yysyntax_error_status = YYSYNTAX_ERROR;
1701 yymsgp = yymsg;
1702 }
1703 }
1704 yyerror (scanner, ctx, scan_ctx, yymsgp);
1705 if (yysyntax_error_status == 2)
1706 goto yyexhaustedlab;
1707 }
1708 # undef YYSYNTAX_ERROR
1709 #endif
1710 }
1711
1712
1713
1714 if (yyerrstatus == 3)
1715 {
1716 /* If just tried and failed to reuse lookahead token after an
1717 error, discard it. */
1718
1719 if (yychar <= YYEOF)
1720 {
1721 /* Return failure if at end of input. */
1722 if (yychar == YYEOF)
1723 YYABORT;
1724 }
1725 else
1726 {
1727 yydestruct ("Error: discarding",
1728 yytoken, &yylval, scanner, ctx, scan_ctx);
1729 yychar = YYEMPTY;
1730 }
1731 }
1732
1733 /* Else will try to reuse lookahead token after shifting the error
1734 token. */
1735 goto yyerrlab1;
1736
1737
1738 /*---------------------------------------------------.
1739 | yyerrorlab -- error raised explicitly by YYERROR. |
1740 `---------------------------------------------------*/
1741 yyerrorlab:
1742
1743 /* Pacify compilers like GCC when the user code never invokes
1744 YYERROR and the label yyerrorlab therefore never appears in user
1745 code. */
1746 if (/*CONSTCOND*/ 0)
1747 goto yyerrorlab;
1748
1749 /* Do not reclaim the symbols of the rule whose action triggered
1750 this YYERROR. */
1751 YYPOPSTACK (yylen);
1752 yylen = 0;
1753 YY_STACK_PRINT (yyss, yyssp);
1754 yystate = *yyssp;
1755 goto yyerrlab1;
1756
1757
1758 /*-------------------------------------------------------------.
1759 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1760 `-------------------------------------------------------------*/
1761 yyerrlab1:
1762 yyerrstatus = 3; /* Each real token shifted decrements this. */
1763
1764 for (;;)
1765 {
1766 yyn = yypact[yystate];
1767 if (!yypact_value_is_default (yyn))
1768 {
1769 yyn += YYTERROR;
1770 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1771 {
1772 yyn = yytable[yyn];
1773 if (0 < yyn)
1774 break;
1775 }
1776 }
1777
1778 /* Pop the current state because it cannot handle the error token. */
1779 if (yyssp == yyss)
1780 YYABORT;
1781
1782
1783 yydestruct ("Error: popping",
1784 yystos[yystate], yyvsp, scanner, ctx, scan_ctx);
1785 YYPOPSTACK (1);
1786 yystate = *yyssp;
1787 YY_STACK_PRINT (yyss, yyssp);
1788 }
1789
1790 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1791 *++yyvsp = yylval;
1792 YY_IGNORE_MAYBE_UNINITIALIZED_END
1793
1794
1795 /* Shift the error token. */
1796 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1797
1798 yystate = yyn;
1799 goto yynewstate;
1800
1801
1802 /*-------------------------------------.
1803 | yyacceptlab -- YYACCEPT comes here. |
1804 `-------------------------------------*/
1805 yyacceptlab:
1806 yyresult = 0;
1807 goto yyreturn;
1808
1809 /*-----------------------------------.
1810 | yyabortlab -- YYABORT comes here. |
1811 `-----------------------------------*/
1812 yyabortlab:
1813 yyresult = 1;
1814 goto yyreturn;
1815
1816 #if !defined yyoverflow || YYERROR_VERBOSE
1817 /*-------------------------------------------------.
1818 | yyexhaustedlab -- memory exhaustion comes here. |
1819 `-------------------------------------------------*/
1820 yyexhaustedlab:
1821 yyerror (scanner, ctx, scan_ctx, YY_("memory exhausted"));
1822 yyresult = 2;
1823 /* Fall through. */
1824 #endif
1825
1826 yyreturn:
1827 if (yychar != YYEMPTY)
1828 {
1829 /* Make sure we have latest lookahead translation. See comments at
1830 user semantic actions for why this is necessary. */
1831 yytoken = YYTRANSLATE (yychar);
1832 yydestruct ("Cleanup: discarding lookahead",
1833 yytoken, &yylval, scanner, ctx, scan_ctx);
1834 }
1835 /* Do not reclaim the symbols of the rule whose action triggered
1836 this YYABORT or YYACCEPT. */
1837 YYPOPSTACK (yylen);
1838 YY_STACK_PRINT (yyss, yyssp);
1839 while (yyssp != yyss)
1840 {
1841 yydestruct ("Cleanup: popping",
1842 yystos[*yyssp], yyvsp, scanner, ctx, scan_ctx);
1843 YYPOPSTACK (1);
1844 }
1845 #ifndef yyoverflow
1846 if (yyss != yyssa)
1847 YYSTACK_FREE (yyss);
1848 #endif
1849 #if YYERROR_VERBOSE
1850 if (yymsg != yymsgbuf)
1851 YYSTACK_FREE (yymsg);
1852 #endif
1853 return yyresult;
1854 }
1855 #line 388 "grammar.y" /* yacc.c:1906 */
1856
1857