blob: 56e33b389661b39e270d30a8a56b0f4b931a151d [file] [log] [blame]
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001/* A Bison parser, made by GNU Bison 3.8.2. */
Sol Boucher69b88bf2015-02-26 11:47:19 -08002
3/* Bison implementation for Yacc-like parsers in C
4
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08005 Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 Inc.
Sol Boucher69b88bf2015-02-26 11:47:19 -08007
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
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080019 along with this program. If not, see <https://www.gnu.org/licenses/>. */
Sol Boucher69b88bf2015-02-26 11:47:19 -080020
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
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080037/* 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
Sol Boucher69b88bf2015-02-26 11:47:19 -080041/* 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
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080048/* Identify Bison output, and Bison version. */
49#define YYBISON 30802
Sol Boucher69b88bf2015-02-26 11:47:19 -080050
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080051/* Bison version string. */
52#define YYBISON_VERSION "3.8.2"
Sol Boucher69b88bf2015-02-26 11:47:19 -080053
54/* Skeleton name. */
55#define YYSKELETON_NAME "yacc.c"
56
57/* Pure parsers. */
58#define YYPURE 0
59
60/* Push parsers. */
61#define YYPUSH 0
62
63/* Pull parsers. */
64#define YYPULL 1
65
66
67
68
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080069/* First part of user prologue. */
Sol Boucher69b88bf2015-02-26 11:47:19 -080070
71#include "fmd_scanner.h"
Sol Boucherb9740812015-03-18 10:13:48 -070072#include "common.h"
Sol Boucher69b88bf2015-02-26 11:47:19 -080073
74#include <stdlib.h>
75
76struct flashmap_descriptor *res = NULL;
77
Sol Boucher69b88bf2015-02-26 11:47:19 -080078
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080079# ifndef YY_CAST
80# ifdef __cplusplus
81# define YY_CAST(Type, Val) static_cast<Type> (Val)
82# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
Sol Boucher69b88bf2015-02-26 11:47:19 -080083# else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +080084# define YY_CAST(Type, Val) ((Type) (Val))
85# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
86# endif
87# endif
88# ifndef YY_NULLPTR
89# if defined __cplusplus
90# if 201103L <= __cplusplus
91# define YY_NULLPTR nullptr
92# else
93# define YY_NULLPTR 0
94# endif
95# else
96# define YY_NULLPTR ((void*)0)
Sol Boucher69b88bf2015-02-26 11:47:19 -080097# endif
98# endif
99
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800100#include "fmd_parser.h_shipped"
101/* Symbol kind. */
102enum yysymbol_kind_t
Sol Boucher69b88bf2015-02-26 11:47:19 -0800103{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800104 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 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800132};
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800133typedef enum yysymbol_kind_t yysymbol_kind_t;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800134
135
Sol Boucher69b88bf2015-02-26 11:47:19 -0800136
Sol Boucher69b88bf2015-02-26 11:47:19 -0800137
138#ifdef short
139# undef short
140#endif
141
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800142/* 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. */
145
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 */
150# define YY_STDINT_H
151# endif
Sol Boucher69b88bf2015-02-26 11:47:19 -0800152#endif
153
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800154/* 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. */
158
159#ifdef __INT_LEAST8_MAX__
160typedef __INT_LEAST8_TYPE__ yytype_int8;
161#elif defined YY_STDINT_H
162typedef int_least8_t yytype_int8;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800163#else
164typedef signed char yytype_int8;
165#endif
166
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800167#ifdef __INT_LEAST16_MAX__
168typedef __INT_LEAST16_TYPE__ yytype_int16;
169#elif defined YY_STDINT_H
170typedef int_least16_t yytype_int16;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800171#else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800172typedef short yytype_int16;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800173#endif
174
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800175/* 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>. */
180#ifdef __hpux
181# undef UINT_LEAST8_MAX
182# undef UINT_LEAST16_MAX
183# define UINT_LEAST8_MAX 255
184# define UINT_LEAST16_MAX 65535
185#endif
186
187#if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
188typedef __UINT_LEAST8_TYPE__ yytype_uint8;
189#elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
190 && UINT_LEAST8_MAX <= INT_MAX)
191typedef uint_least8_t yytype_uint8;
192#elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
193typedef unsigned char yytype_uint8;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800194#else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800195typedef short yytype_uint8;
196#endif
197
198#if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
199typedef __UINT_LEAST16_TYPE__ yytype_uint16;
200#elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
201 && UINT_LEAST16_MAX <= INT_MAX)
202typedef uint_least16_t yytype_uint16;
203#elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
204typedef unsigned short yytype_uint16;
205#else
206typedef int yytype_uint16;
207#endif
208
209#ifndef YYPTRDIFF_T
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
214# ifndef ptrdiff_t
215# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
216# endif
217# define YYPTRDIFF_T ptrdiff_t
218# define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
219# else
220# define YYPTRDIFF_T long
221# define YYPTRDIFF_MAXIMUM LONG_MAX
222# endif
Sol Boucher69b88bf2015-02-26 11:47:19 -0800223#endif
224
225#ifndef YYSIZE_T
226# ifdef __SIZE_TYPE__
227# define YYSIZE_T __SIZE_TYPE__
228# elif defined size_t
229# define YYSIZE_T size_t
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800230# elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
Sol Boucher69b88bf2015-02-26 11:47:19 -0800231# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
232# define YYSIZE_T size_t
233# else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800234# define YYSIZE_T unsigned
Sol Boucher69b88bf2015-02-26 11:47:19 -0800235# endif
236#endif
237
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800238#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)))
243
244#define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
245
246
247/* Stored state numbers (used for stacks). */
248typedef yytype_int8 yy_state_t;
249
250/* State numbers in computations. */
251typedef int yy_state_fast_t;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800252
253#ifndef YY_
254# if defined YYENABLE_NLS && YYENABLE_NLS
255# if ENABLE_NLS
256# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
257# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
258# endif
259# endif
260# ifndef YY_
261# define YY_(Msgid) Msgid
262# endif
263#endif
264
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800265
266#ifndef YY_ATTRIBUTE_PURE
267# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
268# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
Sol Boucher69b88bf2015-02-26 11:47:19 -0800269# else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800270# define YY_ATTRIBUTE_PURE
Sol Boucher69b88bf2015-02-26 11:47:19 -0800271# endif
272#endif
273
Sol Boucher69b88bf2015-02-26 11:47:19 -0800274#ifndef YY_ATTRIBUTE_UNUSED
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800275# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
276# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
Sol Boucher69b88bf2015-02-26 11:47:19 -0800277# else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800278# define YY_ATTRIBUTE_UNUSED
Sol Boucher69b88bf2015-02-26 11:47:19 -0800279# endif
280#endif
281
282/* Suppress unused-variable warnings by "using" E. */
283#if ! defined lint || defined __GNUC__
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800284# define YY_USE(E) ((void) (E))
Sol Boucher69b88bf2015-02-26 11:47:19 -0800285#else
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800286# define YY_USE(E) /* empty */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800287#endif
288
Sol Boucher69b88bf2015-02-26 11:47:19 -0800289/* Suppress an incorrect diagnostic about yylval being uninitialized. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800290#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\"")
295# else
296# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
297 _Pragma ("GCC diagnostic push") \
298 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800299 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800300# endif
301# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800302 _Pragma ("GCC diagnostic pop")
303#else
304# define YY_INITIAL_VALUE(Value) Value
305#endif
306#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
307# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
308# define YY_IGNORE_MAYBE_UNINITIALIZED_END
309#endif
310#ifndef YY_INITIAL_VALUE
311# define YY_INITIAL_VALUE(Value) /* Nothing. */
312#endif
313
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800314#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")
320#endif
321#ifndef YY_IGNORE_USELESS_CAST_BEGIN
322# define YY_IGNORE_USELESS_CAST_BEGIN
323# define YY_IGNORE_USELESS_CAST_END
324#endif
Sol Boucher69b88bf2015-02-26 11:47:19 -0800325
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800326
327#define YY_ASSERT(E) ((void) (0 && (E)))
328
329#if !defined yyoverflow
Sol Boucher69b88bf2015-02-26 11:47:19 -0800330
331/* The parser invokes alloca or malloc; define the necessary symbols. */
332
333# ifdef YYSTACK_USE_ALLOCA
334# if YYSTACK_USE_ALLOCA
335# ifdef __GNUC__
336# define YYSTACK_ALLOC __builtin_alloca
337# elif defined __BUILTIN_VA_ARG_INCR
338# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
339# elif defined _AIX
340# define YYSTACK_ALLOC __alloca
341# elif defined _MSC_VER
342# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
343# define alloca _alloca
344# else
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
351# endif
352# endif
353# endif
354# endif
355# endif
356
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 */
366# endif
367# else
368# define YYSTACK_ALLOC YYMALLOC
369# define YYSTACK_FREE YYFREE
370# ifndef YYSTACK_ALLOC_MAXIMUM
371# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
372# endif
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
379# endif
380# endif
381# ifndef YYMALLOC
382# define YYMALLOC malloc
383# if ! defined malloc && ! defined EXIT_SUCCESS
384void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
385# endif
386# endif
387# ifndef YYFREE
388# define YYFREE free
389# if ! defined free && ! defined EXIT_SUCCESS
390void free (void *); /* INFRINGES ON USER NAME SPACE */
391# endif
392# endif
393# endif
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800394#endif /* !defined yyoverflow */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800395
396#if (! defined yyoverflow \
397 && (! defined __cplusplus \
398 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
399
400/* A type that is properly aligned for any stack member. */
401union yyalloc
402{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800403 yy_state_t yyss_alloc;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800404 YYSTYPE yyvs_alloc;
405};
406
407/* The size of the maximum gap between one aligned stack and the next. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800408# define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800409
410/* The size of an array large to enough to hold all stacks, each with
411 N elements. */
412# define YYSTACK_BYTES(N) \
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800413 ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800414 + YYSTACK_GAP_MAXIMUM)
415
416# define YYCOPY_NEEDED 1
417
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
422 stack. */
423# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
424 do \
425 { \
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800426 YYPTRDIFF_T yynewbytes; \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800427 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
428 Stack = &yyptr->Stack_alloc; \
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800429 yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
430 yyptr += yynewbytes / YYSIZEOF (*yyptr); \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800431 } \
432 while (0)
433
434#endif
435
436#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
437/* Copy COUNT objects from SRC to DST. The source and destination do
438 not overlap. */
439# ifndef YYCOPY
440# if defined __GNUC__ && 1 < __GNUC__
441# define YYCOPY(Dst, Src, Count) \
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800442 __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
Sol Boucher69b88bf2015-02-26 11:47:19 -0800443# else
444# define YYCOPY(Dst, Src, Count) \
445 do \
446 { \
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800447 YYPTRDIFF_T yyi; \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800448 for (yyi = 0; yyi < (Count); yyi++) \
449 (Dst)[yyi] = (Src)[yyi]; \
450 } \
451 while (0)
452# endif
453# endif
454#endif /* !YYCOPY_NEEDED */
455
456/* YYFINAL -- State number of the termination state. */
457#define YYFINAL 4
458/* YYLAST -- Last index in YYTABLE. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800459#define YYLAST 23
Sol Boucher69b88bf2015-02-26 11:47:19 -0800460
461/* YYNTOKENS -- Number of terminals. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800462#define YYNTOKENS 13
Sol Boucher69b88bf2015-02-26 11:47:19 -0800463/* YYNNTS -- Number of nonterminals. */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800464#define YYNNTS 14
Sol Boucher69b88bf2015-02-26 11:47:19 -0800465/* YYNRULES -- Number of rules. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800466#define YYNRULES 21
Sol Boucher69b88bf2015-02-26 11:47:19 -0800467/* YYNSTATES -- Number of states. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800468#define YYNSTATES 31
Sol Boucher69b88bf2015-02-26 11:47:19 -0800469
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800470/* YYMAXUTOK -- Last valid token kind. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800471#define YYMAXUTOK 262
Sol Boucher69b88bf2015-02-26 11:47:19 -0800472
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800473
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]) \
479 : YYSYMBOL_YYUNDEF)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800480
481/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800482 as returned by yylex. */
483static const yytype_int8 yytranslate[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800484{
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,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800489 8, 9, 2, 2, 2, 2, 2, 2, 2, 2,
Sol Boucher69b88bf2015-02-26 11:47:19 -0800490 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800491 2, 2, 2, 2, 10, 2, 2, 2, 2, 2,
Sol Boucher69b88bf2015-02-26 11:47:19 -0800492 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,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800497 2, 2, 2, 11, 2, 12, 2, 2, 2, 2,
Sol Boucher69b88bf2015-02-26 11:47:19 -0800498 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,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800511 5, 6, 7
Sol Boucher69b88bf2015-02-26 11:47:19 -0800512};
513
514#if YYDEBUG
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800515/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
516static const yytype_int8 yyrline[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800517{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800518 0, 68, 68, 74, 88, 95, 96, 97, 97, 98,
519 99, 100, 101, 102, 103, 104, 105, 107, 111, 112,
520 113, 124
Sol Boucher69b88bf2015-02-26 11:47:19 -0800521};
522#endif
523
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800524/** Accessing symbol of state STATE. */
525#define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
526
527#if YYDEBUG || 0
528/* The user-facing name of the symbol whose (internal) number is
529 YYSYMBOL. No bounds checking. */
530static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
531
Sol Boucher69b88bf2015-02-26 11:47:19 -0800532/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
533 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
534static const char *const yytname[] =
535{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800536 "\"end of file\"", "error", "\"invalid token\"", "INTEGER", "OCTAL",
537 "STRING", "FLAG_CBFS", "FLAG_PRESERVE", "'('", "')'", "'@'", "'{'",
538 "'}'", "$accept", "flash_chip", "flash_region", "region_name",
Hung-Te Lin49a44502019-03-04 15:41:09 +0800539 "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
Sol Boucher69b88bf2015-02-26 11:47:19 -0800542};
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800543
544static const char *
545yysymbol_name (yysymbol_kind_t yysymbol)
546{
547 return yytname[yysymbol];
548}
Sol Boucher69b88bf2015-02-26 11:47:19 -0800549#endif
550
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800551#define YYPACT_NINF (-12)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800552
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800553#define yypact_value_is_default(Yyn) \
554 ((Yyn) == YYPACT_NINF)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800555
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800556#define YYTABLE_NINF (-1)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800557
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800558#define yytable_value_is_error(Yyn) \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800559 0
560
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800561/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
562 STATE-NUM. */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800563static const yytype_int8 yypact[] =
564{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800565 -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,
568 -12
Sol Boucher69b88bf2015-02-26 11:47:19 -0800569};
570
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800571/* 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. */
574static const yytype_int8 yydefact[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800575{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800576 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,
579 18
Sol Boucher69b88bf2015-02-26 11:47:19 -0800580};
581
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800582/* YYPGOTO[NTERM-NUM]. */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800583static const yytype_int8 yypgoto[] =
584{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800585 -12, -12, -6, 10, -12, -10, -12, 6, -12, -12,
586 -9, -12, -11, -12
Sol Boucher69b88bf2015-02-26 11:47:19 -0800587};
588
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800589/* YYDEFGOTO[NTERM-NUM]. */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800590static const yytype_int8 yydefgoto[] =
591{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800592 0, 2, 13, 14, 17, 22, 23, 6, 7, 27,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800593 10, 29, 12, 15
Sol Boucher69b88bf2015-02-26 11:47:19 -0800594};
595
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800596/* 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. */
599static const yytype_int8 yytable[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800600{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800601 1, 4, 20, 21, 1, 8, 9, 18, 5, 19,
602 3, 11, 16, 26, 25, 28, 30, 0, 0, 0,
603 0, 0, 0, 24
Sol Boucher69b88bf2015-02-26 11:47:19 -0800604};
605
606static const yytype_int8 yycheck[] =
607{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800608 5, 0, 6, 7, 5, 3, 3, 12, 10, 15,
609 0, 11, 8, 23, 9, 24, 27, -1, -1, -1,
610 -1, -1, -1, 17
Sol Boucher69b88bf2015-02-26 11:47:19 -0800611};
612
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800613/* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
614 state STATE-NUM. */
615static const yytype_int8 yystos[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800616{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800617 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,
620 25
Sol Boucher69b88bf2015-02-26 11:47:19 -0800621};
622
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800623/* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */
624static const yytype_int8 yyr1[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800625{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800626 0, 13, 14, 15, 16, 17, 17, 18, 18, 19,
627 19, 20, 20, 21, 22, 22, 23, 24, 24, 25,
628 26, 26
Sol Boucher69b88bf2015-02-26 11:47:19 -0800629};
630
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800631/* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */
632static const yytype_int8 yyr2[] =
Sol Boucher69b88bf2015-02-26 11:47:19 -0800633{
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800634 0, 2, 4, 5, 1, 0, 3, 1, 2, 1,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800635 1, 0, 1, 2, 0, 1, 1, 0, 1, 3,
636 1, 2
Sol Boucher69b88bf2015-02-26 11:47:19 -0800637};
638
639
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800640enum { YYENOMEM = -2 };
641
Sol Boucher69b88bf2015-02-26 11:47:19 -0800642#define yyerrok (yyerrstatus = 0)
643#define yyclearin (yychar = YYEMPTY)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800644
645#define YYACCEPT goto yyacceptlab
646#define YYABORT goto yyabortlab
647#define YYERROR goto yyerrorlab
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800648#define YYNOMEM goto yyexhaustedlab
Sol Boucher69b88bf2015-02-26 11:47:19 -0800649
650
651#define YYRECOVERING() (!!yyerrstatus)
652
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800653#define YYBACKUP(Token, Value) \
654 do \
655 if (yychar == YYEMPTY) \
656 { \
657 yychar = (Token); \
658 yylval = (Value); \
659 YYPOPSTACK (yylen); \
660 yystate = *yyssp; \
661 goto yybackup; \
662 } \
663 else \
664 { \
665 yyerror (YY_("syntax error: cannot back up")); \
666 YYERROR; \
667 } \
668 while (0)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800669
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800670/* Backward compatibility with an undocumented macro.
671 Use YYerror or YYUNDEF. */
672#define YYERRCODE YYUNDEF
Sol Boucher69b88bf2015-02-26 11:47:19 -0800673
674
675/* Enable debugging if requested. */
676#if YYDEBUG
677
678# ifndef YYFPRINTF
679# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
680# define YYFPRINTF fprintf
681# endif
682
683# define YYDPRINTF(Args) \
684do { \
685 if (yydebug) \
686 YYFPRINTF Args; \
687} while (0)
688
Sol Boucher69b88bf2015-02-26 11:47:19 -0800689
690
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800691
692# define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800693do { \
694 if (yydebug) \
695 { \
696 YYFPRINTF (stderr, "%s ", Title); \
697 yy_symbol_print (stderr, \
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800698 Kind, Value); \
Sol Boucher69b88bf2015-02-26 11:47:19 -0800699 YYFPRINTF (stderr, "\n"); \
700 } \
701} while (0)
702
703
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800704/*-----------------------------------.
705| Print this symbol's value on YYO. |
706`-----------------------------------*/
Sol Boucher69b88bf2015-02-26 11:47:19 -0800707
708static void
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800709yy_symbol_value_print (FILE *yyo,
710 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800711{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800712 FILE *yyoutput = yyo;
713 YY_USE (yyoutput);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800714 if (!yyvaluep)
715 return;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800716 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
717 YY_USE (yykind);
718 YY_IGNORE_MAYBE_UNINITIALIZED_END
Sol Boucher69b88bf2015-02-26 11:47:19 -0800719}
720
721
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800722/*---------------------------.
723| Print this symbol on YYO. |
724`---------------------------*/
Sol Boucher69b88bf2015-02-26 11:47:19 -0800725
726static void
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800727yy_symbol_print (FILE *yyo,
728 yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800729{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800730 YYFPRINTF (yyo, "%s %s (",
731 yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
Sol Boucher69b88bf2015-02-26 11:47:19 -0800732
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800733 yy_symbol_value_print (yyo, yykind, yyvaluep);
734 YYFPRINTF (yyo, ")");
Sol Boucher69b88bf2015-02-26 11:47:19 -0800735}
736
737/*------------------------------------------------------------------.
738| yy_stack_print -- Print the state stack from its BOTTOM up to its |
739| TOP (included). |
740`------------------------------------------------------------------*/
741
742static void
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800743yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800744{
745 YYFPRINTF (stderr, "Stack now");
746 for (; yybottom <= yytop; yybottom++)
747 {
748 int yybot = *yybottom;
749 YYFPRINTF (stderr, " %d", yybot);
750 }
751 YYFPRINTF (stderr, "\n");
752}
753
754# define YY_STACK_PRINT(Bottom, Top) \
755do { \
756 if (yydebug) \
757 yy_stack_print ((Bottom), (Top)); \
758} while (0)
759
760
761/*------------------------------------------------.
762| Report that the YYRULE is going to be reduced. |
763`------------------------------------------------*/
764
765static void
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800766yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
767 int yyrule)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800768{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800769 int yylno = yyrline[yyrule];
Sol Boucher69b88bf2015-02-26 11:47:19 -0800770 int yynrhs = yyr2[yyrule];
771 int yyi;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800772 YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
Sol Boucher69b88bf2015-02-26 11:47:19 -0800773 yyrule - 1, yylno);
774 /* The symbols being reduced. */
775 for (yyi = 0; yyi < yynrhs; yyi++)
776 {
777 YYFPRINTF (stderr, " $%d = ", yyi + 1);
778 yy_symbol_print (stderr,
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800779 YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
780 &yyvsp[(yyi + 1) - (yynrhs)]);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800781 YYFPRINTF (stderr, "\n");
782 }
783}
784
785# define YY_REDUCE_PRINT(Rule) \
786do { \
787 if (yydebug) \
788 yy_reduce_print (yyssp, yyvsp, Rule); \
789} while (0)
790
791/* Nonzero means print parse trace. It is left uninitialized so that
792 multiple parsers can coexist. */
793int yydebug;
794#else /* !YYDEBUG */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800795# define YYDPRINTF(Args) ((void) 0)
796# define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800797# define YY_STACK_PRINT(Bottom, Top)
798# define YY_REDUCE_PRINT(Rule)
799#endif /* !YYDEBUG */
800
801
802/* YYINITDEPTH -- initial size of the parser's stacks. */
803#ifndef YYINITDEPTH
804# define YYINITDEPTH 200
805#endif
806
807/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
808 if the built-in stack extension method is used).
809
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. */
813
814#ifndef YYMAXDEPTH
815# define YYMAXDEPTH 10000
816#endif
817
818
Sol Boucher69b88bf2015-02-26 11:47:19 -0800819
Sol Boucher69b88bf2015-02-26 11:47:19 -0800820
Sol Boucher69b88bf2015-02-26 11:47:19 -0800821
Sol Boucher69b88bf2015-02-26 11:47:19 -0800822
823/*-----------------------------------------------.
824| Release the memory associated to this symbol. |
825`-----------------------------------------------*/
826
827static void
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800828yydestruct (const char *yymsg,
829 yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
Sol Boucher69b88bf2015-02-26 11:47:19 -0800830{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800831 YY_USE (yyvaluep);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800832 if (!yymsg)
833 yymsg = "Deleting";
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800834 YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800835
836 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800837 YY_USE (yykind);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800838 YY_IGNORE_MAYBE_UNINITIALIZED_END
839}
840
841
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800842/* Lookahead token kind. */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800843int yychar;
844
845/* The semantic value of the lookahead symbol. */
846YYSTYPE yylval;
847/* Number of syntax errors so far. */
848int yynerrs;
849
850
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800851
852
Sol Boucher69b88bf2015-02-26 11:47:19 -0800853/*----------.
854| yyparse. |
855`----------*/
856
857int
858yyparse (void)
859{
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800860 yy_state_fast_t yystate = 0;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800861 /* Number of tokens to shift before error messages enabled. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800862 int yyerrstatus = 0;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800863
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800864 /* Refer to the stacks through separate pointers, to allow yyoverflow
Sol Boucher69b88bf2015-02-26 11:47:19 -0800865 to reallocate them elsewhere. */
866
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800867 /* Their size. */
868 YYPTRDIFF_T yystacksize = YYINITDEPTH;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800869
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800870 /* The state stack: array, bottom, top. */
871 yy_state_t yyssa[YYINITDEPTH];
872 yy_state_t *yyss = yyssa;
873 yy_state_t *yyssp = yyss;
874
875 /* The semantic value stack: array, bottom, top. */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800876 YYSTYPE yyvsa[YYINITDEPTH];
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800877 YYSTYPE *yyvs = yyvsa;
878 YYSTYPE *yyvsp = yyvs;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800879
880 int yyn;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800881 /* The return value of yyparse. */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800882 int yyresult;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800883 /* Lookahead symbol kind. */
884 yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800885 /* The variables used to return semantic value and location from the
886 action routines. */
887 YYSTYPE yyval;
888
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800889
Sol Boucher69b88bf2015-02-26 11:47:19 -0800890
891#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
892
893 /* The number of symbols on the RHS of the reduced rule.
894 Keep to zero when no symbol should be popped. */
895 int yylen = 0;
896
Sol Boucher69b88bf2015-02-26 11:47:19 -0800897 YYDPRINTF ((stderr, "Starting parse\n"));
898
Sol Boucher69b88bf2015-02-26 11:47:19 -0800899 yychar = YYEMPTY; /* Cause a token to be read. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800900
Sol Boucher69b88bf2015-02-26 11:47:19 -0800901 goto yysetstate;
902
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800903
Sol Boucher69b88bf2015-02-26 11:47:19 -0800904/*------------------------------------------------------------.
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800905| yynewstate -- push a new state, which is found in yystate. |
Sol Boucher69b88bf2015-02-26 11:47:19 -0800906`------------------------------------------------------------*/
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800907yynewstate:
Sol Boucher69b88bf2015-02-26 11:47:19 -0800908 /* 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. */
910 yyssp++;
911
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800912
913/*--------------------------------------------------------------------.
914| yysetstate -- set current state (the top of the stack) to yystate. |
915`--------------------------------------------------------------------*/
916yysetstate:
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);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800923
924 if (yyss + yystacksize - 1 <= yyssp)
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800925#if !defined yyoverflow && !defined YYSTACK_RELOCATE
926 YYNOMEM;
927#else
Sol Boucher69b88bf2015-02-26 11:47:19 -0800928 {
929 /* Get the current used size of the three stacks, in elements. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800930 YYPTRDIFF_T yysize = yyssp - yyss + 1;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800931
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800932# if defined yyoverflow
Sol Boucher69b88bf2015-02-26 11:47:19 -0800933 {
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
936 memory. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800937 yy_state_t *yyss1 = yyss;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800938 YYSTYPE *yyvs1 = yyvs;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800939
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"),
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800945 &yyss1, yysize * YYSIZEOF (*yyssp),
946 &yyvs1, yysize * YYSIZEOF (*yyvsp),
Sol Boucher69b88bf2015-02-26 11:47:19 -0800947 &yystacksize);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800948 yyss = yyss1;
949 yyvs = yyvs1;
950 }
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800951# else /* defined YYSTACK_RELOCATE */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800952 /* Extend the stack our own way. */
953 if (YYMAXDEPTH <= yystacksize)
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800954 YYNOMEM;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800955 yystacksize *= 2;
956 if (YYMAXDEPTH < yystacksize)
957 yystacksize = YYMAXDEPTH;
958
959 {
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800960 yy_state_t *yyss1 = yyss;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800961 union yyalloc *yyptr =
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800962 YY_CAST (union yyalloc *,
963 YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
Sol Boucher69b88bf2015-02-26 11:47:19 -0800964 if (! yyptr)
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800965 YYNOMEM;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800966 YYSTACK_RELOCATE (yyss_alloc, yyss);
967 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
968# undef YYSTACK_RELOCATE
969 if (yyss1 != yyssa)
970 YYSTACK_FREE (yyss1);
971 }
972# endif
Sol Boucher69b88bf2015-02-26 11:47:19 -0800973
974 yyssp = yyss + yysize - 1;
975 yyvsp = yyvs + yysize - 1;
976
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800977 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
Sol Boucher69b88bf2015-02-26 11:47:19 -0800981
982 if (yyss + yystacksize - 1 <= yyssp)
983 YYABORT;
984 }
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800985#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800986
Sol Boucher69b88bf2015-02-26 11:47:19 -0800987
988 if (yystate == YYFINAL)
989 YYACCEPT;
990
991 goto yybackup;
992
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +0800993
Sol Boucher69b88bf2015-02-26 11:47:19 -0800994/*-----------.
995| yybackup. |
996`-----------*/
997yybackup:
Sol Boucher69b88bf2015-02-26 11:47:19 -0800998 /* Do appropriate processing given the current state. Read a
999 lookahead token if we need one and don't already have one. */
1000
1001 /* First try to decide what to do without reference to lookahead token. */
1002 yyn = yypact[yystate];
1003 if (yypact_value_is_default (yyn))
1004 goto yydefault;
1005
1006 /* Not known => get a lookahead token if don't already have one. */
1007
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001008 /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001009 if (yychar == YYEMPTY)
1010 {
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001011 YYDPRINTF ((stderr, "Reading a token\n"));
Sol Boucher69b88bf2015-02-26 11:47:19 -08001012 yychar = yylex ();
1013 }
1014
1015 if (yychar <= YYEOF)
1016 {
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001017 yychar = YYEOF;
1018 yytoken = YYSYMBOL_YYEOF;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001019 YYDPRINTF ((stderr, "Now at end of input.\n"));
1020 }
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001021 else if (yychar == YYerror)
1022 {
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. */
1027 yychar = YYUNDEF;
1028 yytoken = YYSYMBOL_YYerror;
1029 goto yyerrlab1;
1030 }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001031 else
1032 {
1033 yytoken = YYTRANSLATE (yychar);
1034 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1035 }
1036
1037 /* If the proper action on seeing token YYTOKEN is to reduce or to
1038 detect an error, take that action. */
1039 yyn += yytoken;
1040 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1041 goto yydefault;
1042 yyn = yytable[yyn];
1043 if (yyn <= 0)
1044 {
1045 if (yytable_value_is_error (yyn))
1046 goto yyerrlab;
1047 yyn = -yyn;
1048 goto yyreduce;
1049 }
1050
1051 /* Count tokens shifted since error; after three, turn off error
1052 status. */
1053 if (yyerrstatus)
1054 yyerrstatus--;
1055
1056 /* Shift the lookahead token. */
1057 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001058 yystate = yyn;
1059 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1060 *++yyvsp = yylval;
1061 YY_IGNORE_MAYBE_UNINITIALIZED_END
1062
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001063 /* Discard the shifted token. */
1064 yychar = YYEMPTY;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001065 goto yynewstate;
1066
1067
1068/*-----------------------------------------------------------.
1069| yydefault -- do the default action for the current state. |
1070`-----------------------------------------------------------*/
1071yydefault:
1072 yyn = yydefact[yystate];
1073 if (yyn == 0)
1074 goto yyerrlab;
1075 goto yyreduce;
1076
1077
1078/*-----------------------------.
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001079| yyreduce -- do a reduction. |
Sol Boucher69b88bf2015-02-26 11:47:19 -08001080`-----------------------------*/
1081yyreduce:
1082 /* yyn is the number of a rule to reduce with. */
1083 yylen = yyr2[yyn];
1084
1085 /* If YYLEN is nonzero, implement the default value of the action:
1086 '$$ = $1'.
1087
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];
1094
1095
1096 YY_REDUCE_PRINT (yyn);
1097 switch (yyn)
1098 {
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001099 case 2: /* flash_chip: region_name region_offset_opt region_size region_list */
1100{
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001101 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))))
Sol Boucher69b88bf2015-02-26 11:47:19 -08001103 YYABORT;
1104}
Sol Boucher69b88bf2015-02-26 11:47:19 -08001105 break;
1106
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001107 case 3: /* flash_region: region_name region_flags_opt region_offset_opt region_size_opt region_list_opt */
1108{
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001109 struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-3].flags), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
Sol Boucher69b88bf2015-02-26 11:47:19 -08001110 if (!node)
1111 YYABORT;
1112
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001113 if (node->flags.f.cbfs && !fmd_process_flag_cbfs(node)) {
1114 ERROR("Section '%s' cannot have flag 'CBFS''\n", node->name);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001115 YYABORT;
1116 }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001117
1118 (yyval.region_ptr) = node;
1119}
Sol Boucher69b88bf2015-02-26 11:47:19 -08001120 break;
1121
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001122 case 4: /* region_name: STRING */
1123{
Sol Boucher69b88bf2015-02-26 11:47:19 -08001124 if (!(yyvsp[0].strval)) {
Sol Boucherb9740812015-03-18 10:13:48 -07001125 perror("E: While allocating section name");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001126 YYABORT;
1127 }
1128}
Sol Boucher69b88bf2015-02-26 11:47:19 -08001129 break;
1130
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001131 case 5: /* region_flags_opt: %empty */
1132 { (yyval.flags) = (union flashmap_flags){ .v=0 }; }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001133 break;
1134
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001135 case 6: /* region_flags_opt: '(' region_flags ')' */
1136 { (yyval.flags) = (yyvsp[-1].flags); }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001137 break;
1138
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001139 case 8: /* region_flags: region_flag region_flags */
1140 { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001141 break;
1142
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001143 case 9: /* region_flag: FLAG_CBFS */
1144 { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001145 break;
1146
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001147 case 10: /* region_flag: FLAG_PRESERVE */
1148 { (yyval.flags).v = 0; (yyval.flags).f.preserve = 1; }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001149 break;
1150
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001151 case 11: /* region_offset_opt: %empty */
1152 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001153 break;
1154
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001155 case 13: /* region_offset: '@' INTEGER */
1156 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001157 break;
1158
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001159 case 14: /* region_size_opt: %empty */
1160 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001161 break;
1162
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001163 case 16: /* region_size: INTEGER */
1164 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
Hung-Te Lin49a44502019-03-04 15:41:09 +08001165 break;
1166
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001167 case 17: /* region_list_opt: %empty */
1168{
Sol Boucher69b88bf2015-02-26 11:47:19 -08001169 (yyval.region_listhdr) = (struct descriptor_list)
1170 {.len = 0, .head = NULL, .tail = NULL};
1171}
Sol Boucher69b88bf2015-02-26 11:47:19 -08001172 break;
1173
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001174 case 19: /* region_list: '{' region_list_entries '}' */
1175 { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
Hung-Te Lin49a44502019-03-04 15:41:09 +08001176 break;
1177
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001178 case 20: /* region_list_entries: flash_region */
1179{
Sol Boucher69b88bf2015-02-26 11:47:19 -08001180 struct descriptor_node *node = malloc(sizeof(*node));
1181 if (!node) {
Sol Boucherb9740812015-03-18 10:13:48 -07001182 perror("E: While allocating linked list node");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001183 YYABORT;
1184 }
1185 node->val = (yyvsp[0].region_ptr);
1186 node->next = NULL;
1187 (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
1188}
Sol Boucher69b88bf2015-02-26 11:47:19 -08001189 break;
1190
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001191 case 21: /* region_list_entries: region_list_entries flash_region */
1192{
Sol Boucher69b88bf2015-02-26 11:47:19 -08001193 struct descriptor_node *node = malloc(sizeof(*node));
1194 if (!node) {
Sol Boucherb9740812015-03-18 10:13:48 -07001195 perror("E: While allocating linked list node");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001196 YYABORT;
1197 }
1198 node->val = (yyvsp[0].region_ptr);
1199 node->next = NULL;
1200
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};
1204}
Sol Boucher69b88bf2015-02-26 11:47:19 -08001205 break;
1206
1207
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001208
Sol Boucher69b88bf2015-02-26 11:47:19 -08001209 default: break;
1210 }
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. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001222 YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001223
1224 YYPOPSTACK (yylen);
1225 yylen = 0;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001226
1227 *++yyvsp = yyval;
1228
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. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001232 {
1233 const int yylhs = yyr1[yyn] - YYNTOKENS;
1234 const int yyi = yypgoto[yylhs] + *yyssp;
1235 yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1236 ? yytable[yyi]
1237 : yydefgoto[yylhs]);
1238 }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001239
1240 goto yynewstate;
1241
1242
1243/*--------------------------------------.
1244| yyerrlab -- here on detecting error. |
1245`--------------------------------------*/
1246yyerrlab:
1247 /* Make sure we have latest lookahead translation. See comments at
1248 user semantic actions for why this is necessary. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001249 yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001250 /* If not already recovering from an error, report this error. */
1251 if (!yyerrstatus)
1252 {
1253 ++yynerrs;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001254 yyerror (YY_("syntax error"));
Sol Boucher69b88bf2015-02-26 11:47:19 -08001255 }
1256
Sol Boucher69b88bf2015-02-26 11:47:19 -08001257 if (yyerrstatus == 3)
1258 {
1259 /* If just tried and failed to reuse lookahead token after an
1260 error, discard it. */
1261
1262 if (yychar <= YYEOF)
1263 {
1264 /* Return failure if at end of input. */
1265 if (yychar == YYEOF)
1266 YYABORT;
1267 }
1268 else
1269 {
1270 yydestruct ("Error: discarding",
1271 yytoken, &yylval);
1272 yychar = YYEMPTY;
1273 }
1274 }
1275
1276 /* Else will try to reuse lookahead token after shifting the error
1277 token. */
1278 goto yyerrlab1;
1279
1280
1281/*---------------------------------------------------.
1282| yyerrorlab -- error raised explicitly by YYERROR. |
1283`---------------------------------------------------*/
1284yyerrorlab:
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001285 /* Pacify compilers when the user code never invokes YYERROR and the
1286 label yyerrorlab therefore never appears in user code. */
1287 if (0)
1288 YYERROR;
1289 ++yynerrs;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001290
1291 /* Do not reclaim the symbols of the rule whose action triggered
1292 this YYERROR. */
1293 YYPOPSTACK (yylen);
1294 yylen = 0;
1295 YY_STACK_PRINT (yyss, yyssp);
1296 yystate = *yyssp;
1297 goto yyerrlab1;
1298
1299
1300/*-------------------------------------------------------------.
1301| yyerrlab1 -- common code for both syntax error and YYERROR. |
1302`-------------------------------------------------------------*/
1303yyerrlab1:
1304 yyerrstatus = 3; /* Each real token shifted decrements this. */
1305
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001306 /* Pop stack until we find a state that shifts the error token. */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001307 for (;;)
1308 {
1309 yyn = yypact[yystate];
1310 if (!yypact_value_is_default (yyn))
1311 {
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001312 yyn += YYSYMBOL_YYerror;
1313 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
Sol Boucher69b88bf2015-02-26 11:47:19 -08001314 {
1315 yyn = yytable[yyn];
1316 if (0 < yyn)
1317 break;
1318 }
1319 }
1320
1321 /* Pop the current state because it cannot handle the error token. */
1322 if (yyssp == yyss)
1323 YYABORT;
1324
1325
1326 yydestruct ("Error: popping",
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001327 YY_ACCESSING_SYMBOL (yystate), yyvsp);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001328 YYPOPSTACK (1);
1329 yystate = *yyssp;
1330 YY_STACK_PRINT (yyss, yyssp);
1331 }
1332
1333 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1334 *++yyvsp = yylval;
1335 YY_IGNORE_MAYBE_UNINITIALIZED_END
1336
1337
1338 /* Shift the error token. */
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001339 YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001340
1341 yystate = yyn;
1342 goto yynewstate;
1343
1344
1345/*-------------------------------------.
1346| yyacceptlab -- YYACCEPT comes here. |
1347`-------------------------------------*/
1348yyacceptlab:
1349 yyresult = 0;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001350 goto yyreturnlab;
1351
Sol Boucher69b88bf2015-02-26 11:47:19 -08001352
1353/*-----------------------------------.
1354| yyabortlab -- YYABORT comes here. |
1355`-----------------------------------*/
1356yyabortlab:
1357 yyresult = 1;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001358 goto yyreturnlab;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001359
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001360
1361/*-----------------------------------------------------------.
1362| yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here. |
1363`-----------------------------------------------------------*/
Sol Boucher69b88bf2015-02-26 11:47:19 -08001364yyexhaustedlab:
1365 yyerror (YY_("memory exhausted"));
1366 yyresult = 2;
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001367 goto yyreturnlab;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001368
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001369
1370/*----------------------------------------------------------.
1371| yyreturnlab -- parsing is finished, clean up and return. |
1372`----------------------------------------------------------*/
1373yyreturnlab:
Sol Boucher69b88bf2015-02-26 11:47:19 -08001374 if (yychar != YYEMPTY)
1375 {
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",
1380 yytoken, &yylval);
1381 }
1382 /* Do not reclaim the symbols of the rule whose action triggered
1383 this YYABORT or YYACCEPT. */
1384 YYPOPSTACK (yylen);
1385 YY_STACK_PRINT (yyss, yyssp);
1386 while (yyssp != yyss)
1387 {
1388 yydestruct ("Cleanup: popping",
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001389 YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001390 YYPOPSTACK (1);
1391 }
1392#ifndef yyoverflow
1393 if (yyss != yyssa)
1394 YYSTACK_FREE (yyss);
1395#endif
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001396
Sol Boucher69b88bf2015-02-26 11:47:19 -08001397 return yyresult;
1398}
Hung-Te Lin8cb45aa2023-06-15 15:26:40 +08001399
Sol Boucher69b88bf2015-02-26 11:47:19 -08001400
1401
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001402struct flashmap_descriptor *parse_descriptor(
1403 char *name, union flashmap_flags flags, struct unsigned_option offset,
1404 struct unsigned_option size, struct descriptor_list children)
Sol Boucher69b88bf2015-02-26 11:47:19 -08001405{
1406 struct flashmap_descriptor *region = malloc(sizeof(*region));
1407 if (!region) {
Sol Boucherb9740812015-03-18 10:13:48 -07001408 perror("E: While allocating descriptor section");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001409 return NULL;
1410 }
1411 region->name = name;
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001412 region->flags = flags;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001413 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) {
Sol Boucherb9740812015-03-18 10:13:48 -07001421 perror("E: While allocating node children array");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001422 return NULL;
1423 }
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;
1427
1428 struct descriptor_node *next_node = cur_node->next;
1429 free(cur_node);
1430 cur_node = next_node;
1431 }
1432 } else {
1433 region->list = NULL;
1434 }
1435 return region;
1436}
1437
1438void yyerror(const char *s)
1439{
1440 fprintf(stderr, "%s\n", s);
1441}