/ util / cbfstool / fmd_parser.c_shipped
fmd_parser.c_shipped
   1  /* A Bison parser, made by GNU Bison 3.8.2.  */
   2  
   3  /* Bison implementation for Yacc-like parsers in C
   4  
   5     Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
   6     Inc.
   7  
   8     This program is free software: you can redistribute it and/or modify
   9     it under the terms of the GNU General Public License as published by
  10     the Free Software Foundation, either version 3 of the License, or
  11     (at your option) any later version.
  12  
  13     This program is distributed in the hope that it will be useful,
  14     but WITHOUT ANY WARRANTY; without even the implied warranty of
  15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16     GNU General Public License for more details.
  17  
  18     You should have received a copy of the GNU General Public License
  19     along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
  20  
  21  /* As a special exception, you may create a larger work that contains
  22     part or all of the Bison parser skeleton and distribute that work
  23     under terms of your choice, so long as that work isn't itself a
  24     parser generator using the skeleton or a modified version thereof
  25     as a parser skeleton.  Alternatively, if you modify or redistribute
  26     the parser skeleton itself, you may (at your option) remove this
  27     special exception, which will cause the skeleton and the resulting
  28     Bison output files to be licensed under the GNU General Public
  29     License without this special exception.
  30  
  31     This special exception was added by the Free Software Foundation in
  32     version 2.2 of Bison.  */
  33  
  34  /* C LALR(1) parser skeleton written by Richard Stallman, by
  35     simplifying the original so-called "semantic" parser.  */
  36  
  37  /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
  38     especially those whose name start with YY_ or yy_.  They are
  39     private implementation details that can be changed or removed.  */
  40  
  41  /* All symbols defined below should begin with yy or YY, to avoid
  42     infringing on user name space.  This should be done even for local
  43     variables, as they might otherwise be expanded by user macros.
  44     There are some unavoidable exceptions within include files to
  45     define necessary library symbols; they are noted "INFRINGES ON
  46     USER NAME SPACE" below.  */
  47  
  48  /* Identify Bison output, and Bison version.  */
  49  #define YYBISON 30802
  50  
  51  /* Bison version string.  */
  52  #define YYBISON_VERSION "3.8.2"
  53  
  54  /* Skeleton name.  */
  55  #define YYSKELETON_NAME "yacc.c"
  56  
  57  /* Pure parsers.  */
  58  #define YYPURE 0
  59  
  60  /* Push parsers.  */
  61  #define YYPUSH 0
  62  
  63  /* Pull parsers.  */
  64  #define YYPULL 1
  65  
  66  
  67  
  68  
  69  /* First part of user prologue.  */
  70  
  71  #include "fmd_scanner.h"
  72  #include "common.h"
  73  
  74  #include <stdlib.h>
  75  
  76  struct flashmap_descriptor *res = NULL;
  77  
  78  
  79  # 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)
  83  #  else
  84  #   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)
  97  #  endif
  98  # endif
  99  
 100  #include "fmd_parser.h_shipped"
 101  /* Symbol kind.  */
 102  enum yysymbol_kind_t
 103  {
 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  */
 132  };
 133  typedef enum yysymbol_kind_t yysymbol_kind_t;
 134  
 135  
 136  
 137  
 138  #ifdef short
 139  # undef short
 140  #endif
 141  
 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.  */
 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
 152  #endif
 153  
 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.  */
 158  
 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;
 163  #else
 164  typedef signed char yytype_int8;
 165  #endif
 166  
 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;
 171  #else
 172  typedef short yytype_int16;
 173  #endif
 174  
 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>.  */
 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__
 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;
 194  #else
 195  typedef short yytype_uint8;
 196  #endif
 197  
 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;
 205  #else
 206  typedef 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
 223  #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
 230  # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
 231  #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 232  #  define YYSIZE_T size_t
 233  # else
 234  #  define YYSIZE_T unsigned
 235  # endif
 236  #endif
 237  
 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)))
 243  
 244  #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
 245  
 246  
 247  /* Stored state numbers (used for stacks). */
 248  typedef yytype_int8 yy_state_t;
 249  
 250  /* State numbers in computations.  */
 251  typedef int yy_state_fast_t;
 252  
 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  
 265  
 266  #ifndef YY_ATTRIBUTE_PURE
 267  # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
 268  #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
 269  # else
 270  #  define YY_ATTRIBUTE_PURE
 271  # endif
 272  #endif
 273  
 274  #ifndef YY_ATTRIBUTE_UNUSED
 275  # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
 276  #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
 277  # else
 278  #  define YY_ATTRIBUTE_UNUSED
 279  # endif
 280  #endif
 281  
 282  /* Suppress unused-variable warnings by "using" E.  */
 283  #if ! defined lint || defined __GNUC__
 284  # define YY_USE(E) ((void) (E))
 285  #else
 286  # define YY_USE(E) /* empty */
 287  #endif
 288  
 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\"")
 295  # else
 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\"")
 300  # endif
 301  # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
 302      _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  
 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")
 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
 325  
 326  
 327  #define YY_ASSERT(E) ((void) (0 && (E)))
 328  
 329  #if !defined yyoverflow
 330  
 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
 384  void *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
 390  void free (void *); /* INFRINGES ON USER NAME SPACE */
 391  #   endif
 392  #  endif
 393  # endif
 394  #endif /* !defined yyoverflow */
 395  
 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.  */
 401  union yyalloc
 402  {
 403    yy_state_t yyss_alloc;
 404    YYSTYPE yyvs_alloc;
 405  };
 406  
 407  /* The size of the maximum gap between one aligned stack and the next.  */
 408  # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
 409  
 410  /* The size of an array large to enough to hold all stacks, each with
 411     N elements.  */
 412  # define YYSTACK_BYTES(N) \
 413       ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
 414        + 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        {                                                                 \
 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);                        \
 431        }                                                                 \
 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) \
 442        __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
 443  #  else
 444  #   define YYCOPY(Dst, Src, Count)              \
 445        do                                        \
 446          {                                       \
 447            YYPTRDIFF_T yyi;                      \
 448            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.  */
 459  #define YYLAST   23
 460  
 461  /* YYNTOKENS -- Number of terminals.  */
 462  #define YYNTOKENS  13
 463  /* YYNNTS -- Number of nonterminals.  */
 464  #define YYNNTS  14
 465  /* YYNRULES -- Number of rules.  */
 466  #define YYNRULES  21
 467  /* YYNSTATES -- Number of states.  */
 468  #define YYNSTATES  31
 469  
 470  /* YYMAXUTOK -- Last valid token kind.  */
 471  #define YYMAXUTOK   262
 472  
 473  
 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)
 480  
 481  /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
 482     as returned by yylex.  */
 483  static const yytype_int8 yytranslate[] =
 484  {
 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,
 511         5,     6,     7
 512  };
 513  
 514  #if YYDEBUG
 515  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 516  static const yytype_int8 yyrline[] =
 517  {
 518         0,    68,    68,    74,    88,    95,    96,    97,    97,    98,
 519        99,   100,   101,   102,   103,   104,   105,   107,   111,   112,
 520       113,   124
 521  };
 522  #endif
 523  
 524  /** 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.  */
 530  static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
 531  
 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[] =
 535  {
 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
 542  };
 543  
 544  static const char *
 545  yysymbol_name (yysymbol_kind_t yysymbol)
 546  {
 547    return yytname[yysymbol];
 548  }
 549  #endif
 550  
 551  #define YYPACT_NINF (-12)
 552  
 553  #define yypact_value_is_default(Yyn) \
 554    ((Yyn) == YYPACT_NINF)
 555  
 556  #define YYTABLE_NINF (-1)
 557  
 558  #define yytable_value_is_error(Yyn) \
 559    0
 560  
 561  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
 562     STATE-NUM.  */
 563  static const yytype_int8 yypact[] =
 564  {
 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,
 568       -12
 569  };
 570  
 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[] =
 575  {
 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,
 579        18
 580  };
 581  
 582  /* YYPGOTO[NTERM-NUM].  */
 583  static const yytype_int8 yypgoto[] =
 584  {
 585       -12,   -12,    -6,    10,   -12,   -10,   -12,     6,   -12,   -12,
 586        -9,   -12,   -11,   -12
 587  };
 588  
 589  /* YYDEFGOTO[NTERM-NUM].  */
 590  static const yytype_int8 yydefgoto[] =
 591  {
 592         0,     2,    13,    14,    17,    22,    23,     6,     7,    27,
 593        10,    29,    12,    15
 594  };
 595  
 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[] =
 600  {
 601         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
 604  };
 605  
 606  static const yytype_int8 yycheck[] =
 607  {
 608         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
 611  };
 612  
 613  /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
 614     state STATE-NUM.  */
 615  static const yytype_int8 yystos[] =
 616  {
 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,
 620        25
 621  };
 622  
 623  /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
 624  static const yytype_int8 yyr1[] =
 625  {
 626         0,    13,    14,    15,    16,    17,    17,    18,    18,    19,
 627        19,    20,    20,    21,    22,    22,    23,    24,    24,    25,
 628        26,    26
 629  };
 630  
 631  /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
 632  static const yytype_int8 yyr2[] =
 633  {
 634         0,     2,     4,     5,     1,     0,     3,     1,     2,     1,
 635         1,     0,     1,     2,     0,     1,     1,     0,     1,     3,
 636         1,     2
 637  };
 638  
 639  
 640  enum { YYENOMEM = -2 };
 641  
 642  #define yyerrok         (yyerrstatus = 0)
 643  #define yyclearin       (yychar = YYEMPTY)
 644  
 645  #define YYACCEPT        goto yyacceptlab
 646  #define YYABORT         goto yyabortlab
 647  #define YYERROR         goto yyerrorlab
 648  #define YYNOMEM         goto yyexhaustedlab
 649  
 650  
 651  #define YYRECOVERING()  (!!yyerrstatus)
 652  
 653  #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)
 669  
 670  /* Backward compatibility with an undocumented macro.
 671     Use YYerror or YYUNDEF. */
 672  #define YYERRCODE YYUNDEF
 673  
 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)                        \
 684  do {                                            \
 685    if (yydebug)                                  \
 686      YYFPRINTF Args;                             \
 687  } while (0)
 688  
 689  
 690  
 691  
 692  # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
 693  do {                                                                      \
 694    if (yydebug)                                                            \
 695      {                                                                     \
 696        YYFPRINTF (stderr, "%s ", Title);                                   \
 697        yy_symbol_print (stderr,                                            \
 698                    Kind, Value); \
 699        YYFPRINTF (stderr, "\n");                                           \
 700      }                                                                     \
 701  } while (0)
 702  
 703  
 704  /*-----------------------------------.
 705  | Print this symbol's value on YYO.  |
 706  `-----------------------------------*/
 707  
 708  static void
 709  yy_symbol_value_print (FILE *yyo,
 710                         yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
 711  {
 712    FILE *yyoutput = yyo;
 713    YY_USE (yyoutput);
 714    if (!yyvaluep)
 715      return;
 716    YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 717    YY_USE (yykind);
 718    YY_IGNORE_MAYBE_UNINITIALIZED_END
 719  }
 720  
 721  
 722  /*---------------------------.
 723  | Print this symbol on YYO.  |
 724  `---------------------------*/
 725  
 726  static void
 727  yy_symbol_print (FILE *yyo,
 728                   yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
 729  {
 730    YYFPRINTF (yyo, "%s %s (",
 731               yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
 732  
 733    yy_symbol_value_print (yyo, yykind, yyvaluep);
 734    YYFPRINTF (yyo, ")");
 735  }
 736  
 737  /*------------------------------------------------------------------.
 738  | yy_stack_print -- Print the state stack from its BOTTOM up to its |
 739  | TOP (included).                                                   |
 740  `------------------------------------------------------------------*/
 741  
 742  static void
 743  yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
 744  {
 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)                            \
 755  do {                                                            \
 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  
 765  static void
 766  yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
 767                   int yyrule)
 768  {
 769    int yylno = yyrline[yyrule];
 770    int yynrhs = yyr2[yyrule];
 771    int yyi;
 772    YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
 773               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,
 779                         YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
 780                         &yyvsp[(yyi + 1) - (yynrhs)]);
 781        YYFPRINTF (stderr, "\n");
 782      }
 783  }
 784  
 785  # define YY_REDUCE_PRINT(Rule)          \
 786  do {                                    \
 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.  */
 793  int yydebug;
 794  #else /* !YYDEBUG */
 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 */
 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  
 819  
 820  
 821  
 822  
 823  /*-----------------------------------------------.
 824  | Release the memory associated to this symbol.  |
 825  `-----------------------------------------------*/
 826  
 827  static void
 828  yydestruct (const char *yymsg,
 829              yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
 830  {
 831    YY_USE (yyvaluep);
 832    if (!yymsg)
 833      yymsg = "Deleting";
 834    YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
 835  
 836    YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
 837    YY_USE (yykind);
 838    YY_IGNORE_MAYBE_UNINITIALIZED_END
 839  }
 840  
 841  
 842  /* Lookahead token kind.  */
 843  int yychar;
 844  
 845  /* The semantic value of the lookahead symbol.  */
 846  YYSTYPE yylval;
 847  /* Number of syntax errors so far.  */
 848  int yynerrs;
 849  
 850  
 851  
 852  
 853  /*----------.
 854  | yyparse.  |
 855  `----------*/
 856  
 857  int
 858  yyparse (void)
 859  {
 860      yy_state_fast_t yystate = 0;
 861      /* Number of tokens to shift before error messages enabled.  */
 862      int yyerrstatus = 0;
 863  
 864      /* Refer to the stacks through separate pointers, to allow yyoverflow
 865         to reallocate them elsewhere.  */
 866  
 867      /* Their size.  */
 868      YYPTRDIFF_T yystacksize = YYINITDEPTH;
 869  
 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;
 874  
 875      /* The semantic value stack: array, bottom, top.  */
 876      YYSTYPE yyvsa[YYINITDEPTH];
 877      YYSTYPE *yyvs = yyvsa;
 878      YYSTYPE *yyvsp = yyvs;
 879  
 880    int yyn;
 881    /* The return value of yyparse.  */
 882    int yyresult;
 883    /* Lookahead symbol kind.  */
 884    yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
 885    /* The variables used to return semantic value and location from the
 886       action routines.  */
 887    YYSTYPE yyval;
 888  
 889  
 890  
 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  
 897    YYDPRINTF ((stderr, "Starting parse\n"));
 898  
 899    yychar = YYEMPTY; /* Cause a token to be read.  */
 900  
 901    goto yysetstate;
 902  
 903  
 904  /*------------------------------------------------------------.
 905  | yynewstate -- push a new state, which is found in yystate.  |
 906  `------------------------------------------------------------*/
 907  yynewstate:
 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.  */
 910    yyssp++;
 911  
 912  
 913  /*--------------------------------------------------------------------.
 914  | yysetstate -- set current state (the top of the stack) to yystate.  |
 915  `--------------------------------------------------------------------*/
 916  yysetstate:
 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);
 923  
 924    if (yyss + yystacksize - 1 <= yyssp)
 925  #if !defined yyoverflow && !defined YYSTACK_RELOCATE
 926      YYNOMEM;
 927  #else
 928      {
 929        /* Get the current used size of the three stacks, in elements.  */
 930        YYPTRDIFF_T yysize = yyssp - yyss + 1;
 931  
 932  # if defined yyoverflow
 933        {
 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.  */
 937          yy_state_t *yyss1 = yyss;
 938          YYSTYPE *yyvs1 = yyvs;
 939  
 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),
 947                      &yystacksize);
 948          yyss = yyss1;
 949          yyvs = yyvs1;
 950        }
 951  # else /* defined YYSTACK_RELOCATE */
 952        /* Extend the stack our own way.  */
 953        if (YYMAXDEPTH <= yystacksize)
 954          YYNOMEM;
 955        yystacksize *= 2;
 956        if (YYMAXDEPTH < yystacksize)
 957          yystacksize = YYMAXDEPTH;
 958  
 959        {
 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))));
 964          if (! yyptr)
 965            YYNOMEM;
 966          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
 973  
 974        yyssp = yyss + yysize - 1;
 975        yyvsp = yyvs + yysize - 1;
 976  
 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
 981  
 982        if (yyss + yystacksize - 1 <= yyssp)
 983          YYABORT;
 984      }
 985  #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
 986  
 987  
 988    if (yystate == YYFINAL)
 989      YYACCEPT;
 990  
 991    goto yybackup;
 992  
 993  
 994  /*-----------.
 995  | yybackup.  |
 996  `-----------*/
 997  yybackup:
 998    /* 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  
1008    /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1009    if (yychar == YYEMPTY)
1010      {
1011        YYDPRINTF ((stderr, "Reading a token\n"));
1012        yychar = yylex ();
1013      }
1014  
1015    if (yychar <= YYEOF)
1016      {
1017        yychar = YYEOF;
1018        yytoken = YYSYMBOL_YYEOF;
1019        YYDPRINTF ((stderr, "Now at end of input.\n"));
1020      }
1021    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      }
1031    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);
1058    yystate = yyn;
1059    YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1060    *++yyvsp = yylval;
1061    YY_IGNORE_MAYBE_UNINITIALIZED_END
1062  
1063    /* Discard the shifted token.  */
1064    yychar = YYEMPTY;
1065    goto yynewstate;
1066  
1067  
1068  /*-----------------------------------------------------------.
1069  | yydefault -- do the default action for the current state.  |
1070  `-----------------------------------------------------------*/
1071  yydefault:
1072    yyn = yydefact[yystate];
1073    if (yyn == 0)
1074      goto yyerrlab;
1075    goto yyreduce;
1076  
1077  
1078  /*-----------------------------.
1079  | yyreduce -- do a reduction.  |
1080  `-----------------------------*/
1081  yyreduce:
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      {
1099    case 2: /* flash_chip: region_name region_offset_opt region_size region_list  */
1100  {
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))))
1103  		YYABORT;
1104  }
1105      break;
1106  
1107    case 3: /* flash_region: region_name region_flags_opt region_offset_opt region_size_opt region_list_opt  */
1108  {
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));
1110  	if (!node)
1111  		YYABORT;
1112  
1113  	if (node->flags.f.cbfs && !fmd_process_flag_cbfs(node)) {
1114  		ERROR("Section '%s' cannot have flag 'CBFS''\n", node->name);
1115  		YYABORT;
1116  	}
1117  
1118  	(yyval.region_ptr) = node;
1119  }
1120      break;
1121  
1122    case 4: /* region_name: STRING  */
1123  {
1124  	if (!(yyvsp[0].strval)) {
1125  		perror("E: While allocating section name");
1126  		YYABORT;
1127  	}
1128  }
1129      break;
1130  
1131    case 5: /* region_flags_opt: %empty  */
1132                    { (yyval.flags) = (union flashmap_flags){ .v=0 }; }
1133      break;
1134  
1135    case 6: /* region_flags_opt: '(' region_flags ')'  */
1136                                 { (yyval.flags) = (yyvsp[-1].flags); }
1137      break;
1138  
1139    case 8: /* region_flags: region_flag region_flags  */
1140                                                       { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; }
1141      break;
1142  
1143    case 9: /* region_flag: FLAG_CBFS  */
1144                         { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; }
1145      break;
1146  
1147    case 10: /* region_flag: FLAG_PRESERVE  */
1148                             { (yyval.flags).v = 0; (yyval.flags).f.preserve = 1; }
1149      break;
1150  
1151    case 11: /* region_offset_opt: %empty  */
1152                     { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1153      break;
1154  
1155    case 13: /* region_offset: '@' INTEGER  */
1156                             { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1157      break;
1158  
1159    case 14: /* region_size_opt: %empty  */
1160                   { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1161      break;
1162  
1163    case 16: /* region_size: INTEGER  */
1164                       { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1165      break;
1166  
1167    case 17: /* region_list_opt: %empty  */
1168  {
1169  	(yyval.region_listhdr) = (struct descriptor_list)
1170  					{.len = 0, .head = NULL, .tail = NULL};
1171  }
1172      break;
1173  
1174    case 19: /* region_list: '{' region_list_entries '}'  */
1175                                           { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
1176      break;
1177  
1178    case 20: /* region_list_entries: flash_region  */
1179  {
1180  	struct descriptor_node *node = malloc(sizeof(*node));
1181  	if (!node) {
1182  		perror("E: While allocating linked list node");
1183  		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  }
1189      break;
1190  
1191    case 21: /* region_list_entries: region_list_entries flash_region  */
1192  {
1193  	struct descriptor_node *node = malloc(sizeof(*node));
1194  	if (!node) {
1195  		perror("E: While allocating linked list node");
1196  		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  }
1205      break;
1206  
1207  
1208  
1209        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.  */
1222    YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1223  
1224    YYPOPSTACK (yylen);
1225    yylen = 0;
1226  
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.  */
1232    {
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    }
1239  
1240    goto yynewstate;
1241  
1242  
1243  /*--------------------------------------.
1244  | yyerrlab -- here on detecting error.  |
1245  `--------------------------------------*/
1246  yyerrlab:
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.  */
1251    if (!yyerrstatus)
1252      {
1253        ++yynerrs;
1254        yyerror (YY_("syntax error"));
1255      }
1256  
1257    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  `---------------------------------------------------*/
1284  yyerrorlab:
1285    /* 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;
1290  
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  `-------------------------------------------------------------*/
1303  yyerrlab1:
1304    yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1305  
1306    /* Pop stack until we find a state that shifts the error token.  */
1307    for (;;)
1308      {
1309        yyn = yypact[yystate];
1310        if (!yypact_value_is_default (yyn))
1311          {
1312            yyn += YYSYMBOL_YYerror;
1313            if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1314              {
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",
1327                    YY_ACCESSING_SYMBOL (yystate), yyvsp);
1328        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.  */
1339    YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1340  
1341    yystate = yyn;
1342    goto yynewstate;
1343  
1344  
1345  /*-------------------------------------.
1346  | yyacceptlab -- YYACCEPT comes here.  |
1347  `-------------------------------------*/
1348  yyacceptlab:
1349    yyresult = 0;
1350    goto yyreturnlab;
1351  
1352  
1353  /*-----------------------------------.
1354  | yyabortlab -- YYABORT comes here.  |
1355  `-----------------------------------*/
1356  yyabortlab:
1357    yyresult = 1;
1358    goto yyreturnlab;
1359  
1360  
1361  /*-----------------------------------------------------------.
1362  | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
1363  `-----------------------------------------------------------*/
1364  yyexhaustedlab:
1365    yyerror (YY_("memory exhausted"));
1366    yyresult = 2;
1367    goto yyreturnlab;
1368  
1369  
1370  /*----------------------------------------------------------.
1371  | yyreturnlab -- parsing is finished, clean up and return.  |
1372  `----------------------------------------------------------*/
1373  yyreturnlab:
1374    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",
1389                    YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1390        YYPOPSTACK (1);
1391      }
1392  #ifndef yyoverflow
1393    if (yyss != yyssa)
1394      YYSTACK_FREE (yyss);
1395  #endif
1396  
1397    return yyresult;
1398  }
1399  
1400  
1401  
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)
1405  {
1406  	struct flashmap_descriptor *region = malloc(sizeof(*region));
1407  	if (!region) {
1408  		perror("E: While allocating descriptor section");
1409  		return NULL;
1410  	}
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");
1422  			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  
1438  void yyerror(const char *s)
1439  {
1440  	fprintf(stderr, "%s\n", s);
1441  }