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