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