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