1 /* A Bison parser, made by GNU Bison 3.8.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <https://www.gnu.org/licenses/>. */
21 /* As a special exception, you may create a larger work that contains
22 part or all of the Bison parser skeleton and distribute that work
23 under terms of your choice, so long as that work isn't itself a
24 parser generator using the skeleton or a modified version thereof
25 as a parser skeleton. Alternatively, if you modify or redistribute
26 the parser skeleton itself, you may (at your option) remove this
27 special exception, which will cause the skeleton and the resulting
28 Bison output files to be licensed under the GNU General Public
29 License without this special exception.
31 This special exception was added by the Free Software Foundation in
32 version 2.2 of Bison. */
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35 simplifying the original so-called "semantic" parser. */
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 especially those whose name start with YY_ or yy_. They are
39 private implementation details that can be changed or removed. */
41 /* All symbols defined below should begin with yy or YY, to avoid
42 infringing on user name space. This should be done even for local
43 variables, as they might otherwise be expanded by user macros.
44 There are some unavoidable exceptions within include files to
45 define necessary library symbols; they are noted "INFRINGES ON
46 USER NAME SPACE" below. */
48 /* Identify Bison output, and Bison version. */
51 /* Bison version string. */
52 #define YYBISON_VERSION "3.8.2"
55 #define YYSKELETON_NAME "yacc.c"
69 /* First part of user prologue. */
71 #include "fmd_scanner.h"
76 struct flashmap_descriptor *res = NULL;
81 # define YY_CAST(Type, Val) static_cast<Type> (Val)
82 # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
84 # define YY_CAST(Type, Val) ((Type) (Val))
85 # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
89 # if defined __cplusplus
90 # if 201103L <= __cplusplus
91 # define YY_NULLPTR nullptr
96 # define YY_NULLPTR ((void*)0)
100 #include "fmd_parser.h_shipped"
104 YYSYMBOL_YYEMPTY = -2,
105 YYSYMBOL_YYEOF = 0, /* "end of file" */
106 YYSYMBOL_YYerror = 1, /* error */
107 YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
108 YYSYMBOL_INTEGER = 3, /* INTEGER */
109 YYSYMBOL_OCTAL = 4, /* OCTAL */
110 YYSYMBOL_STRING = 5, /* STRING */
111 YYSYMBOL_FLAG_CBFS = 6, /* FLAG_CBFS */
112 YYSYMBOL_FLAG_PRESERVE = 7, /* FLAG_PRESERVE */
113 YYSYMBOL_8_ = 8, /* '(' */
114 YYSYMBOL_9_ = 9, /* ')' */
115 YYSYMBOL_10_ = 10, /* '@' */
116 YYSYMBOL_11_ = 11, /* '{' */
117 YYSYMBOL_12_ = 12, /* '}' */
118 YYSYMBOL_YYACCEPT = 13, /* $accept */
119 YYSYMBOL_flash_chip = 14, /* flash_chip */
120 YYSYMBOL_flash_region = 15, /* flash_region */
121 YYSYMBOL_region_name = 16, /* region_name */
122 YYSYMBOL_region_flags_opt = 17, /* region_flags_opt */
123 YYSYMBOL_region_flags = 18, /* region_flags */
124 YYSYMBOL_region_flag = 19, /* region_flag */
125 YYSYMBOL_region_offset_opt = 20, /* region_offset_opt */
126 YYSYMBOL_region_offset = 21, /* region_offset */
127 YYSYMBOL_region_size_opt = 22, /* region_size_opt */
128 YYSYMBOL_region_size = 23, /* region_size */
129 YYSYMBOL_region_list_opt = 24, /* region_list_opt */
130 YYSYMBOL_region_list = 25, /* region_list */
131 YYSYMBOL_region_list_entries = 26 /* region_list_entries */
133 typedef enum yysymbol_kind_t yysymbol_kind_t;
142 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
143 <limits.h> and (if available) <stdint.h> are included
144 so that the code can choose integer types of a good width. */
146 #ifndef __PTRDIFF_MAX__
147 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
148 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
149 # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
154 /* Narrow types that promote to a signed type and that can represent a
155 signed or unsigned integer of at least N bits. In tables they can
156 save space and decrease cache pressure. Promoting to a signed type
157 helps avoid bugs in integer arithmetic. */
159 #ifdef __INT_LEAST8_MAX__
160 typedef __INT_LEAST8_TYPE__ yytype_int8;
161 #elif defined YY_STDINT_H
162 typedef int_least8_t yytype_int8;
164 typedef signed char yytype_int8;
167 #ifdef __INT_LEAST16_MAX__
168 typedef __INT_LEAST16_TYPE__ yytype_int16;
169 #elif defined YY_STDINT_H
170 typedef int_least16_t yytype_int16;
172 typedef short yytype_int16;
175 /* Work around bug in HP-UX 11.23, which defines these macros
176 incorrectly for preprocessor constants. This workaround can likely
177 be removed in 2023, as HPE has promised support for HP-UX 11.23
178 (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
179 <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
181 # undef UINT_LEAST8_MAX
182 # undef UINT_LEAST16_MAX
183 # define UINT_LEAST8_MAX 255
184 # define UINT_LEAST16_MAX 65535
187 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
188 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
189 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
190 && UINT_LEAST8_MAX <= INT_MAX)
191 typedef uint_least8_t yytype_uint8;
192 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
193 typedef unsigned char yytype_uint8;
195 typedef short yytype_uint8;
198 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
199 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
200 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
201 && UINT_LEAST16_MAX <= INT_MAX)
202 typedef uint_least16_t yytype_uint16;
203 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
204 typedef unsigned short yytype_uint16;
206 typedef int yytype_uint16;
210 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
211 # define YYPTRDIFF_T __PTRDIFF_TYPE__
212 # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
213 # elif defined PTRDIFF_MAX
215 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
217 # define YYPTRDIFF_T ptrdiff_t
218 # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
220 # define YYPTRDIFF_T long
221 # define YYPTRDIFF_MAXIMUM LONG_MAX
226 # ifdef __SIZE_TYPE__
227 # define YYSIZE_T __SIZE_TYPE__
228 # elif defined size_t
229 # define YYSIZE_T size_t
230 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
231 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
232 # define YYSIZE_T size_t
234 # define YYSIZE_T unsigned
238 #define YYSIZE_MAXIMUM \
239 YY_CAST (YYPTRDIFF_T, \
240 (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
241 ? YYPTRDIFF_MAXIMUM \
242 : YY_CAST (YYSIZE_T, -1)))
244 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
247 /* Stored state numbers (used for stacks). */
248 typedef yytype_int8 yy_state_t;
250 /* State numbers in computations. */
251 typedef int yy_state_fast_t;
254 # if defined YYENABLE_NLS && YYENABLE_NLS
256 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
257 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
261 # define YY_(Msgid) Msgid
266 #ifndef YY_ATTRIBUTE_PURE
267 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
268 # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
270 # define YY_ATTRIBUTE_PURE
274 #ifndef YY_ATTRIBUTE_UNUSED
275 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
276 # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
278 # define YY_ATTRIBUTE_UNUSED
282 /* Suppress unused-variable warnings by "using" E. */
283 #if ! defined lint || defined __GNUC__
284 # define YY_USE(E) ((void) (E))
286 # define YY_USE(E) /* empty */
289 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
290 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
291 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
292 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
293 _Pragma ("GCC diagnostic push") \
294 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
296 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
297 _Pragma ("GCC diagnostic push") \
298 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
299 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
301 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
302 _Pragma ("GCC diagnostic pop")
304 # define YY_INITIAL_VALUE(Value) Value
306 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
307 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
308 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
310 #ifndef YY_INITIAL_VALUE
311 # define YY_INITIAL_VALUE(Value) /* Nothing. */
314 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
315 # define YY_IGNORE_USELESS_CAST_BEGIN \
316 _Pragma ("GCC diagnostic push") \
317 _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
318 # define YY_IGNORE_USELESS_CAST_END \
319 _Pragma ("GCC diagnostic pop")
321 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
322 # define YY_IGNORE_USELESS_CAST_BEGIN
323 # define YY_IGNORE_USELESS_CAST_END
327 #define YY_ASSERT(E) ((void) (0 && (E)))
329 #if !defined yyoverflow
331 /* The parser invokes alloca or malloc; define the necessary symbols. */
333 # ifdef YYSTACK_USE_ALLOCA
334 # if YYSTACK_USE_ALLOCA
336 # define YYSTACK_ALLOC __builtin_alloca
337 # elif defined __BUILTIN_VA_ARG_INCR
338 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
340 # define YYSTACK_ALLOC __alloca
341 # elif defined _MSC_VER
342 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
343 # define alloca _alloca
345 # define YYSTACK_ALLOC alloca
346 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
347 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
348 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
349 # ifndef EXIT_SUCCESS
350 # define EXIT_SUCCESS 0
357 # ifdef YYSTACK_ALLOC
358 /* Pacify GCC's 'empty if-body' warning. */
359 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
360 # ifndef YYSTACK_ALLOC_MAXIMUM
361 /* The OS might guarantee only one guard page at the bottom of the stack,
362 and a page size can be as small as 4096 bytes. So we cannot safely
363 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
364 to allow for a few compiler-allocated temporary stack slots. */
365 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
368 # define YYSTACK_ALLOC YYMALLOC
369 # define YYSTACK_FREE YYFREE
370 # ifndef YYSTACK_ALLOC_MAXIMUM
371 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
373 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
374 && ! ((defined YYMALLOC || defined malloc) \
375 && (defined YYFREE || defined free)))
376 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
377 # ifndef EXIT_SUCCESS
378 # define EXIT_SUCCESS 0
382 # define YYMALLOC malloc
383 # if ! defined malloc && ! defined EXIT_SUCCESS
384 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
389 # if ! defined free && ! defined EXIT_SUCCESS
390 void free (void *); /* INFRINGES ON USER NAME SPACE */
394 #endif /* !defined yyoverflow */
396 #if (! defined yyoverflow \
397 && (! defined __cplusplus \
398 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
400 /* A type that is properly aligned for any stack member. */
403 yy_state_t yyss_alloc;
407 /* The size of the maximum gap between one aligned stack and the next. */
408 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
410 /* The size of an array large to enough to hold all stacks, each with
412 # define YYSTACK_BYTES(N) \
413 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
414 + YYSTACK_GAP_MAXIMUM)
416 # define YYCOPY_NEEDED 1
418 /* Relocate STACK from its old location to the new one. The
419 local variables YYSIZE and YYSTACKSIZE give the old and new number of
420 elements in the stack, and YYPTR gives the new location of the
421 stack. Advance YYPTR to a properly aligned location for the next
423 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
426 YYPTRDIFF_T yynewbytes; \
427 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
428 Stack = &yyptr->Stack_alloc; \
429 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
430 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
436 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
437 /* Copy COUNT objects from SRC to DST. The source and destination do
440 # if defined __GNUC__ && 1 < __GNUC__
441 # define YYCOPY(Dst, Src, Count) \
442 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
444 # define YYCOPY(Dst, Src, Count) \
448 for (yyi = 0; yyi < (Count); yyi++) \
449 (Dst)[yyi] = (Src)[yyi]; \
454 #endif /* !YYCOPY_NEEDED */
456 /* YYFINAL -- State number of the termination state. */
458 /* YYLAST -- Last index in YYTABLE. */
461 /* YYNTOKENS -- Number of terminals. */
463 /* YYNNTS -- Number of nonterminals. */
465 /* YYNRULES -- Number of rules. */
467 /* YYNSTATES -- Number of states. */
470 /* YYMAXUTOK -- Last valid token kind. */
471 #define YYMAXUTOK 262
474 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
475 as returned by yylex, with out-of-bounds checking. */
476 #define YYTRANSLATE(YYX) \
477 (0 <= (YYX) && (YYX) <= YYMAXUTOK \
478 ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
481 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
482 as returned by yylex. */
483 static const yytype_int8 yytranslate[] =
485 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
486 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
487 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
488 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
489 8, 9, 2, 2, 2, 2, 2, 2, 2, 2,
490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
491 2, 2, 2, 2, 10, 2, 2, 2, 2, 2,
492 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
493 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
494 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
495 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
496 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
497 2, 2, 2, 11, 2, 12, 2, 2, 2, 2,
498 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
499 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
500 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
501 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
502 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
503 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
504 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
505 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
506 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
507 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
508 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
509 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
510 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
515 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
516 static const yytype_int8 yyrline[] =
518 0, 68, 68, 74, 88, 95, 96, 97, 97, 98,
519 99, 100, 101, 102, 103, 104, 105, 107, 111, 112,
524 /** Accessing symbol of state STATE. */
525 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
528 /* The user-facing name of the symbol whose (internal) number is
529 YYSYMBOL. No bounds checking. */
530 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
532 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
533 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
534 static const char *const yytname[] =
536 "\"end of file\"", "error", "\"invalid token\"", "INTEGER", "OCTAL",
537 "STRING", "FLAG_CBFS", "FLAG_PRESERVE", "'('", "')'", "'@'", "'{'",
538 "'}'", "$accept", "flash_chip", "flash_region", "region_name",
539 "region_flags_opt", "region_flags", "region_flag", "region_offset_opt",
540 "region_offset", "region_size_opt", "region_size", "region_list_opt",
541 "region_list", "region_list_entries", YY_NULLPTR
545 yysymbol_name (yysymbol_kind_t yysymbol)
547 return yytname[yysymbol];
551 #define YYPACT_NINF (-12)
553 #define yypact_value_is_default(Yyn) \
554 ((Yyn) == YYPACT_NINF)
556 #define YYTABLE_NINF (-1)
558 #define yytable_value_is_error(Yyn) \
561 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
563 static const yytype_int8 yypact[] =
565 -1, -12, 1, -2, -12, 2, 3, -12, -12, -12,
566 0, -1, -12, -12, 4, -5, -4, -2, -12, -12,
567 -12, -12, 5, -4, 3, -12, -12, 0, -12, -12,
571 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
572 Performed when YYTABLE does not specify something else to do. Zero
573 means the default is an error. */
574 static const yytype_int8 yydefact[] =
576 0, 4, 0, 11, 1, 0, 0, 12, 13, 16,
577 0, 0, 2, 20, 5, 0, 0, 11, 19, 21,
578 9, 10, 0, 7, 14, 6, 8, 17, 15, 3,
582 /* YYPGOTO[NTERM-NUM]. */
583 static const yytype_int8 yypgoto[] =
585 -12, -12, -6, 10, -12, -10, -12, 6, -12, -12,
589 /* YYDEFGOTO[NTERM-NUM]. */
590 static const yytype_int8 yydefgoto[] =
592 0, 2, 13, 14, 17, 22, 23, 6, 7, 27,
596 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
597 positive, shift that token. If negative, reduce the rule whose
598 number is the opposite. If YYTABLE_NINF, syntax error. */
599 static const yytype_int8 yytable[] =
601 1, 4, 20, 21, 1, 8, 9, 18, 5, 19,
602 3, 11, 16, 26, 25, 28, 30, 0, 0, 0,
606 static const yytype_int8 yycheck[] =
608 5, 0, 6, 7, 5, 3, 3, 12, 10, 15,
609 0, 11, 8, 23, 9, 24, 27, -1, -1, -1,
613 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
615 static const yytype_int8 yystos[] =
617 0, 5, 14, 16, 0, 10, 20, 21, 3, 3,
618 23, 11, 25, 15, 16, 26, 8, 17, 12, 15,
619 6, 7, 18, 19, 20, 9, 18, 22, 23, 24,
623 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
624 static const yytype_int8 yyr1[] =
626 0, 13, 14, 15, 16, 17, 17, 18, 18, 19,
627 19, 20, 20, 21, 22, 22, 23, 24, 24, 25,
631 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
632 static const yytype_int8 yyr2[] =
634 0, 2, 4, 5, 1, 0, 3, 1, 2, 1,
635 1, 0, 1, 2, 0, 1, 1, 0, 1, 3,
640 enum { YYENOMEM = -2 };
642 #define yyerrok (yyerrstatus = 0)
643 #define yyclearin (yychar = YYEMPTY)
645 #define YYACCEPT goto yyacceptlab
646 #define YYABORT goto yyabortlab
647 #define YYERROR goto yyerrorlab
648 #define YYNOMEM goto yyexhaustedlab
651 #define YYRECOVERING() (!!yyerrstatus)
653 #define YYBACKUP(Token, Value) \
655 if (yychar == YYEMPTY) \
659 YYPOPSTACK (yylen); \
665 yyerror (YY_("syntax error: cannot back up")); \
670 /* Backward compatibility with an undocumented macro.
671 Use YYerror or YYUNDEF. */
672 #define YYERRCODE YYUNDEF
675 /* Enable debugging if requested. */
679 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
680 # define YYFPRINTF fprintf
683 # define YYDPRINTF(Args) \
692 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
696 YYFPRINTF (stderr, "%s ", Title); \
697 yy_symbol_print (stderr, \
699 YYFPRINTF (stderr, "\n"); \
704 /*-----------------------------------.
705 | Print this symbol's value on YYO. |
706 `-----------------------------------*/
709 yy_symbol_value_print (FILE *yyo,
710 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
712 FILE *yyoutput = yyo;
716 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
718 YY_IGNORE_MAYBE_UNINITIALIZED_END
722 /*---------------------------.
723 | Print this symbol on YYO. |
724 `---------------------------*/
727 yy_symbol_print (FILE *yyo,
728 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
730 YYFPRINTF (yyo, "%s %s (",
731 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
733 yy_symbol_value_print (yyo, yykind, yyvaluep);
734 YYFPRINTF (yyo, ")");
737 /*------------------------------------------------------------------.
738 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
740 `------------------------------------------------------------------*/
743 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
745 YYFPRINTF (stderr, "Stack now");
746 for (; yybottom <= yytop; yybottom++)
748 int yybot = *yybottom;
749 YYFPRINTF (stderr, " %d", yybot);
751 YYFPRINTF (stderr, "\n");
754 # define YY_STACK_PRINT(Bottom, Top) \
757 yy_stack_print ((Bottom), (Top)); \
761 /*------------------------------------------------.
762 | Report that the YYRULE is going to be reduced. |
763 `------------------------------------------------*/
766 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
769 int yylno = yyrline[yyrule];
770 int yynrhs = yyr2[yyrule];
772 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
774 /* The symbols being reduced. */
775 for (yyi = 0; yyi < yynrhs; yyi++)
777 YYFPRINTF (stderr, " $%d = ", yyi + 1);
778 yy_symbol_print (stderr,
779 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
780 &yyvsp[(yyi + 1) - (yynrhs)]);
781 YYFPRINTF (stderr, "\n");
785 # define YY_REDUCE_PRINT(Rule) \
788 yy_reduce_print (yyssp, yyvsp, Rule); \
791 /* Nonzero means print parse trace. It is left uninitialized so that
792 multiple parsers can coexist. */
795 # define YYDPRINTF(Args) ((void) 0)
796 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
797 # define YY_STACK_PRINT(Bottom, Top)
798 # define YY_REDUCE_PRINT(Rule)
799 #endif /* !YYDEBUG */
802 /* YYINITDEPTH -- initial size of the parser's stacks. */
804 # define YYINITDEPTH 200
807 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
808 if the built-in stack extension method is used).
810 Do not make this value too large; the results are undefined if
811 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
812 evaluated with infinite-precision integer arithmetic. */
815 # define YYMAXDEPTH 10000
823 /*-----------------------------------------------.
824 | Release the memory associated to this symbol. |
825 `-----------------------------------------------*/
828 yydestruct (const char *yymsg,
829 yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
834 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
836 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
838 YY_IGNORE_MAYBE_UNINITIALIZED_END
842 /* Lookahead token kind. */
845 /* The semantic value of the lookahead symbol. */
847 /* Number of syntax errors so far. */
860 yy_state_fast_t yystate = 0;
861 /* Number of tokens to shift before error messages enabled. */
864 /* Refer to the stacks through separate pointers, to allow yyoverflow
865 to reallocate them elsewhere. */
868 YYPTRDIFF_T yystacksize = YYINITDEPTH;
870 /* The state stack: array, bottom, top. */
871 yy_state_t yyssa[YYINITDEPTH];
872 yy_state_t *yyss = yyssa;
873 yy_state_t *yyssp = yyss;
875 /* The semantic value stack: array, bottom, top. */
876 YYSTYPE yyvsa[YYINITDEPTH];
877 YYSTYPE *yyvs = yyvsa;
878 YYSTYPE *yyvsp = yyvs;
881 /* The return value of yyparse. */
883 /* Lookahead symbol kind. */
884 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
885 /* The variables used to return semantic value and location from the
891 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
893 /* The number of symbols on the RHS of the reduced rule.
894 Keep to zero when no symbol should be popped. */
897 YYDPRINTF ((stderr, "Starting parse\n"));
899 yychar = YYEMPTY; /* Cause a token to be read. */
904 /*------------------------------------------------------------.
905 | yynewstate -- push a new state, which is found in yystate. |
906 `------------------------------------------------------------*/
908 /* In all cases, when you get here, the value and location stacks
909 have just been pushed. So pushing a state here evens the stacks. */
913 /*--------------------------------------------------------------------.
914 | yysetstate -- set current state (the top of the stack) to yystate. |
915 `--------------------------------------------------------------------*/
917 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
918 YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
919 YY_IGNORE_USELESS_CAST_BEGIN
920 *yyssp = YY_CAST (yy_state_t, yystate);
921 YY_IGNORE_USELESS_CAST_END
922 YY_STACK_PRINT (yyss, yyssp);
924 if (yyss + yystacksize - 1 <= yyssp)
925 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
929 /* Get the current used size of the three stacks, in elements. */
930 YYPTRDIFF_T yysize = yyssp - yyss + 1;
932 # if defined yyoverflow
934 /* Give user a chance to reallocate the stack. Use copies of
935 these so that the &'s don't force the real ones into
937 yy_state_t *yyss1 = yyss;
938 YYSTYPE *yyvs1 = yyvs;
940 /* Each stack pointer address is followed by the size of the
941 data in use in that stack, in bytes. This used to be a
942 conditional around just the two extra args, but that might
943 be undefined if yyoverflow is a macro. */
944 yyoverflow (YY_("memory exhausted"),
945 &yyss1, yysize * YYSIZEOF (*yyssp),
946 &yyvs1, yysize * YYSIZEOF (*yyvsp),
951 # else /* defined YYSTACK_RELOCATE */
952 /* Extend the stack our own way. */
953 if (YYMAXDEPTH <= yystacksize)
956 if (YYMAXDEPTH < yystacksize)
957 yystacksize = YYMAXDEPTH;
960 yy_state_t *yyss1 = yyss;
961 union yyalloc *yyptr =
962 YY_CAST (union yyalloc *,
963 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
966 YYSTACK_RELOCATE (yyss_alloc, yyss);
967 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
968 # undef YYSTACK_RELOCATE
970 YYSTACK_FREE (yyss1);
974 yyssp = yyss + yysize - 1;
975 yyvsp = yyvs + yysize - 1;
977 YY_IGNORE_USELESS_CAST_BEGIN
978 YYDPRINTF ((stderr, "Stack size increased to %ld\n",
979 YY_CAST (long, yystacksize)));
980 YY_IGNORE_USELESS_CAST_END
982 if (yyss + yystacksize - 1 <= yyssp)
985 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
988 if (yystate == YYFINAL)
998 /* Do appropriate processing given the current state. Read a
999 lookahead token if we need one and don't already have one. */
1001 /* First try to decide what to do without reference to lookahead token. */
1002 yyn = yypact[yystate];
1003 if (yypact_value_is_default (yyn))
1006 /* Not known => get a lookahead token if don't already have one. */
1008 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1009 if (yychar == YYEMPTY)
1011 YYDPRINTF ((stderr, "Reading a token\n"));
1015 if (yychar <= YYEOF)
1018 yytoken = YYSYMBOL_YYEOF;
1019 YYDPRINTF ((stderr, "Now at end of input.\n"));
1021 else if (yychar == YYerror)
1023 /* The scanner already issued an error message, process directly
1024 to error recovery. But do not keep the error token as
1025 lookahead, it is too special and may lead us to an endless
1026 loop in error recovery. */
1028 yytoken = YYSYMBOL_YYerror;
1033 yytoken = YYTRANSLATE (yychar);
1034 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1037 /* If the proper action on seeing token YYTOKEN is to reduce or to
1038 detect an error, take that action. */
1040 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1045 if (yytable_value_is_error (yyn))
1051 /* Count tokens shifted since error; after three, turn off error
1056 /* Shift the lookahead token. */
1057 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1059 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1061 YY_IGNORE_MAYBE_UNINITIALIZED_END
1063 /* Discard the shifted token. */
1068 /*-----------------------------------------------------------.
1069 | yydefault -- do the default action for the current state. |
1070 `-----------------------------------------------------------*/
1072 yyn = yydefact[yystate];
1078 /*-----------------------------.
1079 | yyreduce -- do a reduction. |
1080 `-----------------------------*/
1082 /* yyn is the number of a rule to reduce with. */
1085 /* If YYLEN is nonzero, implement the default value of the action:
1088 Otherwise, the following line sets YYVAL to garbage.
1089 This behavior is undocumented and Bison
1090 users should not rely upon it. Assigning to YYVAL
1091 unconditionally makes the parser a bit smaller, and it avoids a
1092 GCC warning that YYVAL may be used uninitialized. */
1093 yyval = yyvsp[1-yylen];
1096 YY_REDUCE_PRINT (yyn);
1099 case 2: /* flash_chip: region_name region_offset_opt region_size region_list */
1101 union flashmap_flags flags = { .v=0 };
1102 if (!(res = parse_descriptor((yyvsp[-3].strval), flags, (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr))))
1107 case 3: /* flash_region: region_name region_flags_opt region_offset_opt region_size_opt region_list_opt */
1109 struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-3].flags), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
1113 if (node->flags.f.cbfs && !fmd_process_flag_cbfs(node)) {
1114 ERROR("Section '%s' cannot have flag 'CBFS''\n", node->name);
1118 (yyval.region_ptr) = node;
1122 case 4: /* region_name: STRING */
1124 if (!(yyvsp[0].strval)) {
1125 perror("E: While allocating section name");
1131 case 5: /* region_flags_opt: %empty */
1132 { (yyval.flags) = (union flashmap_flags){ .v=0 }; }
1135 case 6: /* region_flags_opt: '(' region_flags ')' */
1136 { (yyval.flags) = (yyvsp[-1].flags); }
1139 case 8: /* region_flags: region_flag region_flags */
1140 { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; }
1143 case 9: /* region_flag: FLAG_CBFS */
1144 { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; }
1147 case 10: /* region_flag: FLAG_PRESERVE */
1148 { (yyval.flags).v = 0; (yyval.flags).f.preserve = 1; }
1151 case 11: /* region_offset_opt: %empty */
1152 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1155 case 13: /* region_offset: '@' INTEGER */
1156 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1159 case 14: /* region_size_opt: %empty */
1160 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1163 case 16: /* region_size: INTEGER */
1164 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1167 case 17: /* region_list_opt: %empty */
1169 (yyval.region_listhdr) = (struct descriptor_list)
1170 {.len = 0, .head = NULL, .tail = NULL};
1174 case 19: /* region_list: '{' region_list_entries '}' */
1175 { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
1178 case 20: /* region_list_entries: flash_region */
1180 struct descriptor_node *node = malloc(sizeof(*node));
1182 perror("E: While allocating linked list node");
1185 node->val = (yyvsp[0].region_ptr);
1187 (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
1191 case 21: /* region_list_entries: region_list_entries flash_region */
1193 struct descriptor_node *node = malloc(sizeof(*node));
1195 perror("E: While allocating linked list node");
1198 node->val = (yyvsp[0].region_ptr);
1201 (yyvsp[-1].region_listhdr).tail->next = node;
1202 (yyval.region_listhdr) = (struct descriptor_list)
1203 {.len = (yyvsp[-1].region_listhdr).len + 1, .head = (yyvsp[-1].region_listhdr).head, .tail = node};
1211 /* User semantic actions sometimes alter yychar, and that requires
1212 that yytoken be updated with the new translation. We take the
1213 approach of translating immediately before every use of yytoken.
1214 One alternative is translating here after every semantic action,
1215 but that translation would be missed if the semantic action invokes
1216 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1217 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1218 incorrect destructor might then be invoked immediately. In the
1219 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1220 to an incorrect destructor call or verbose syntax error message
1221 before the lookahead is translated. */
1222 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1229 /* Now 'shift' the result of the reduction. Determine what state
1230 that goes to, based on the state we popped back to and the rule
1231 number reduced by. */
1233 const int yylhs = yyr1[yyn] - YYNTOKENS;
1234 const int yyi = yypgoto[yylhs] + *yyssp;
1235 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1237 : yydefgoto[yylhs]);
1243 /*--------------------------------------.
1244 | yyerrlab -- here on detecting error. |
1245 `--------------------------------------*/
1247 /* Make sure we have latest lookahead translation. See comments at
1248 user semantic actions for why this is necessary. */
1249 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1250 /* If not already recovering from an error, report this error. */
1254 yyerror (YY_("syntax error"));
1257 if (yyerrstatus == 3)
1259 /* If just tried and failed to reuse lookahead token after an
1260 error, discard it. */
1262 if (yychar <= YYEOF)
1264 /* Return failure if at end of input. */
1265 if (yychar == YYEOF)
1270 yydestruct ("Error: discarding",
1276 /* Else will try to reuse lookahead token after shifting the error
1281 /*---------------------------------------------------.
1282 | yyerrorlab -- error raised explicitly by YYERROR. |
1283 `---------------------------------------------------*/
1285 /* Pacify compilers when the user code never invokes YYERROR and the
1286 label yyerrorlab therefore never appears in user code. */
1291 /* Do not reclaim the symbols of the rule whose action triggered
1295 YY_STACK_PRINT (yyss, yyssp);
1300 /*-------------------------------------------------------------.
1301 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1302 `-------------------------------------------------------------*/
1304 yyerrstatus = 3; /* Each real token shifted decrements this. */
1306 /* Pop stack until we find a state that shifts the error token. */
1309 yyn = yypact[yystate];
1310 if (!yypact_value_is_default (yyn))
1312 yyn += YYSYMBOL_YYerror;
1313 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1321 /* Pop the current state because it cannot handle the error token. */
1326 yydestruct ("Error: popping",
1327 YY_ACCESSING_SYMBOL (yystate), yyvsp);
1330 YY_STACK_PRINT (yyss, yyssp);
1333 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1335 YY_IGNORE_MAYBE_UNINITIALIZED_END
1338 /* Shift the error token. */
1339 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1345 /*-------------------------------------.
1346 | yyacceptlab -- YYACCEPT comes here. |
1347 `-------------------------------------*/
1353 /*-----------------------------------.
1354 | yyabortlab -- YYABORT comes here. |
1355 `-----------------------------------*/
1361 /*-----------------------------------------------------------.
1362 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1363 `-----------------------------------------------------------*/
1365 yyerror (YY_("memory exhausted"));
1370 /*----------------------------------------------------------.
1371 | yyreturnlab -- parsing is finished, clean up and return. |
1372 `----------------------------------------------------------*/
1374 if (yychar != YYEMPTY)
1376 /* Make sure we have latest lookahead translation. See comments at
1377 user semantic actions for why this is necessary. */
1378 yytoken = YYTRANSLATE (yychar);
1379 yydestruct ("Cleanup: discarding lookahead",
1382 /* Do not reclaim the symbols of the rule whose action triggered
1383 this YYABORT or YYACCEPT. */
1385 YY_STACK_PRINT (yyss, yyssp);
1386 while (yyssp != yyss)
1388 yydestruct ("Cleanup: popping",
1389 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1394 YYSTACK_FREE (yyss);
1402 struct flashmap_descriptor *parse_descriptor(
1403 char *name, union flashmap_flags flags, struct unsigned_option offset,
1404 struct unsigned_option size, struct descriptor_list children)
1406 struct flashmap_descriptor *region = malloc(sizeof(*region));
1408 perror("E: While allocating descriptor section");
1411 region->name = name;
1412 region->flags = flags;
1413 region->offset_known = offset.val_known;
1414 region->offset = offset.val;
1415 region->size_known = size.val_known;
1416 region->size = size.val;
1417 region->list_len = children.len;
1418 if (region->list_len) {
1419 region->list = malloc(region->list_len * sizeof(*region->list));
1420 if (!region->list) {
1421 perror("E: While allocating node children array");
1424 struct descriptor_node *cur_node = children.head;
1425 for (unsigned idx = 0; idx < region->list_len; ++idx) {
1426 region->list[idx] = cur_node->val;
1428 struct descriptor_node *next_node = cur_node->next;
1430 cur_node = next_node;
1433 region->list = NULL;
1438 void yyerror(const char *s)
1440 fprintf(stderr, "%s\n", s);