1 /* A Bison parser, made by GNU Bison 3.0.4. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
43 /* Identify Bison output. */
47 #define YYBISON_VERSION "3.0.4"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
65 #line 16 "fmd_parser.y" /* yacc.c:339 */
67 #include "fmd_scanner.h"
72 struct flashmap_descriptor *res = NULL;
74 #line 75 "y.tab.c" /* yacc.c:339 */
77 # if defined __cplusplus && 201103L <= __cplusplus
78 # define YY_NULLPTR nullptr
84 /* Enabling verbose error messages. */
85 #ifdef YYERROR_VERBOSE
86 # undef YYERROR_VERBOSE
87 # define YYERROR_VERBOSE 1
89 # define YYERROR_VERBOSE 0
92 /* In a future release of Bison, this section will be replaced
93 by #include "y.tab.h". */
94 #ifndef YY_YY_Y_TAB_H_INCLUDED
95 # define YY_YY_Y_TAB_H_INCLUDED
103 /* "%code requires" blocks. */
104 #line 34 "fmd_parser.y" /* yacc.c:355 */
111 struct descriptor_node {
112 struct flashmap_descriptor *val;
113 struct descriptor_node *next;
116 struct descriptor_list {
118 struct descriptor_node *head;
119 struct descriptor_node *tail;
122 extern struct flashmap_descriptor *res;
124 struct flashmap_descriptor *parse_descriptor(
125 char *name, union flashmap_flags flags, struct unsigned_option offset,
126 struct unsigned_option size, struct descriptor_list children);
127 void yyerror(const char *s);
129 #line 130 "y.tab.c" /* yacc.c:355 */
147 #define FLAG_CBFS 261
148 #define FLAG_PRESERVE 262
151 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
155 #line 25 "fmd_parser.y" /* yacc.c:355 */
159 struct unsigned_option maybe_intval;
160 struct flashmap_descriptor *region_ptr;
161 union flashmap_flags flags;
162 struct descriptor_list region_listhdr;
164 #line 165 "y.tab.c" /* yacc.c:355 */
167 typedef union YYSTYPE YYSTYPE;
168 # define YYSTYPE_IS_TRIVIAL 1
169 # define YYSTYPE_IS_DECLARED 1
173 extern YYSTYPE yylval;
177 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
179 /* Copy the second part of user declarations. */
181 #line 182 "y.tab.c" /* yacc.c:358 */
188 typedef YYTYPE_UINT8 yytype_uint8;
190 typedef unsigned char yytype_uint8;
194 typedef YYTYPE_INT8 yytype_int8;
196 typedef signed char yytype_int8;
200 typedef YYTYPE_UINT16 yytype_uint16;
202 typedef unsigned short int yytype_uint16;
206 typedef YYTYPE_INT16 yytype_int16;
208 typedef short int yytype_int16;
212 # ifdef __SIZE_TYPE__
213 # define YYSIZE_T __SIZE_TYPE__
214 # elif defined size_t
215 # define YYSIZE_T size_t
216 # elif ! defined YYSIZE_T
217 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
218 # define YYSIZE_T size_t
220 # define YYSIZE_T unsigned int
224 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
227 # if defined YYENABLE_NLS && YYENABLE_NLS
229 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
230 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
234 # define YY_(Msgid) Msgid
239 # if (defined __GNUC__ \
240 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
241 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
242 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
244 # define YY_ATTRIBUTE(Spec) /* empty */
248 #ifndef YY_ATTRIBUTE_PURE
249 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
252 #ifndef YY_ATTRIBUTE_UNUSED
253 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
256 #if !defined _Noreturn \
257 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
258 # if defined _MSC_VER && 1200 <= _MSC_VER
259 # define _Noreturn __declspec (noreturn)
261 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
265 /* Suppress unused-variable warnings by "using" E. */
266 #if ! defined lint || defined __GNUC__
267 # define YYUSE(E) ((void) (E))
269 # define YYUSE(E) /* empty */
272 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
273 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
274 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
275 _Pragma ("GCC diagnostic push") \
276 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
277 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
278 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
279 _Pragma ("GCC diagnostic pop")
281 # define YY_INITIAL_VALUE(Value) Value
283 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
284 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
285 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
287 #ifndef YY_INITIAL_VALUE
288 # define YY_INITIAL_VALUE(Value) /* Nothing. */
292 #if ! defined yyoverflow || YYERROR_VERBOSE
294 /* The parser invokes alloca or malloc; define the necessary symbols. */
296 # ifdef YYSTACK_USE_ALLOCA
297 # if YYSTACK_USE_ALLOCA
299 # define YYSTACK_ALLOC __builtin_alloca
300 # elif defined __BUILTIN_VA_ARG_INCR
301 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
303 # define YYSTACK_ALLOC __alloca
304 # elif defined _MSC_VER
305 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
306 # define alloca _alloca
308 # define YYSTACK_ALLOC alloca
309 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
310 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
311 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
312 # ifndef EXIT_SUCCESS
313 # define EXIT_SUCCESS 0
320 # ifdef YYSTACK_ALLOC
321 /* Pacify GCC's 'empty if-body' warning. */
322 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
323 # ifndef YYSTACK_ALLOC_MAXIMUM
324 /* The OS might guarantee only one guard page at the bottom of the stack,
325 and a page size can be as small as 4096 bytes. So we cannot safely
326 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
327 to allow for a few compiler-allocated temporary stack slots. */
328 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
331 # define YYSTACK_ALLOC YYMALLOC
332 # define YYSTACK_FREE YYFREE
333 # ifndef YYSTACK_ALLOC_MAXIMUM
334 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
336 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
337 && ! ((defined YYMALLOC || defined malloc) \
338 && (defined YYFREE || defined free)))
339 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
340 # ifndef EXIT_SUCCESS
341 # define EXIT_SUCCESS 0
345 # define YYMALLOC malloc
346 # if ! defined malloc && ! defined EXIT_SUCCESS
347 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
352 # if ! defined free && ! defined EXIT_SUCCESS
353 void free (void *); /* INFRINGES ON USER NAME SPACE */
357 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
360 #if (! defined yyoverflow \
361 && (! defined __cplusplus \
362 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
364 /* A type that is properly aligned for any stack member. */
367 yytype_int16 yyss_alloc;
371 /* The size of the maximum gap between one aligned stack and the next. */
372 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
374 /* The size of an array large to enough to hold all stacks, each with
376 # define YYSTACK_BYTES(N) \
377 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
378 + YYSTACK_GAP_MAXIMUM)
380 # define YYCOPY_NEEDED 1
382 /* Relocate STACK from its old location to the new one. The
383 local variables YYSIZE and YYSTACKSIZE give the old and new number of
384 elements in the stack, and YYPTR gives the new location of the
385 stack. Advance YYPTR to a properly aligned location for the next
387 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
390 YYSIZE_T yynewbytes; \
391 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
392 Stack = &yyptr->Stack_alloc; \
393 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
394 yyptr += yynewbytes / sizeof (*yyptr); \
400 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
401 /* Copy COUNT objects from SRC to DST. The source and destination do
404 # if defined __GNUC__ && 1 < __GNUC__
405 # define YYCOPY(Dst, Src, Count) \
406 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
408 # define YYCOPY(Dst, Src, Count) \
412 for (yyi = 0; yyi < (Count); yyi++) \
413 (Dst)[yyi] = (Src)[yyi]; \
418 #endif /* !YYCOPY_NEEDED */
420 /* YYFINAL -- State number of the termination state. */
422 /* YYLAST -- Last index in YYTABLE. */
425 /* YYNTOKENS -- Number of terminals. */
427 /* YYNNTS -- Number of nonterminals. */
429 /* YYNRULES -- Number of rules. */
431 /* YYNSTATES -- Number of states. */
434 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
435 by yylex, with out-of-bounds checking. */
437 #define YYMAXUTOK 262
439 #define YYTRANSLATE(YYX) \
440 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
442 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
443 as returned by yylex, without out-of-bounds checking. */
444 static const yytype_uint8 yytranslate[] =
446 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
447 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
448 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
449 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
450 8, 9, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
452 2, 2, 2, 2, 10, 2, 2, 2, 2, 2,
453 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
454 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
455 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
456 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
457 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
458 2, 2, 2, 11, 2, 12, 2, 2, 2, 2,
459 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
460 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
461 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
462 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
464 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
465 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
466 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
467 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
468 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
469 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
470 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
471 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
476 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
477 static const yytype_uint8 yyrline[] =
479 0, 80, 80, 86, 100, 107, 108, 109, 109, 110,
480 111, 112, 113, 114, 115, 116, 117, 119, 123, 124,
485 #if YYDEBUG || YYERROR_VERBOSE || 0
486 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
487 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
488 static const char *const yytname[] =
490 "$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING",
491 "FLAG_CBFS", "FLAG_PRESERVE", "'('", "')'", "'@'", "'{'", "'}'",
492 "$accept", "flash_chip", "flash_region", "region_name",
493 "region_flags_opt", "region_flags", "region_flag", "region_offset_opt",
494 "region_offset", "region_size_opt", "region_size", "region_list_opt",
495 "region_list", "region_list_entries", YY_NULLPTR
500 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
501 (internal) symbol number NUM (which must be that of a token). */
502 static const yytype_uint16 yytoknum[] =
504 0, 256, 257, 258, 259, 260, 261, 262, 40, 41,
509 #define YYPACT_NINF -12
511 #define yypact_value_is_default(Yystate) \
512 (!!((Yystate) == (-12)))
514 #define YYTABLE_NINF -1
516 #define yytable_value_is_error(Yytable_value) \
519 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
521 static const yytype_int8 yypact[] =
523 -1, -12, 1, -2, -12, 2, 3, -12, -12, -12,
524 0, -1, -12, -12, 4, -5, -4, -2, -12, -12,
525 -12, -12, 5, -4, 3, -12, -12, 0, -12, -12,
529 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
530 Performed when YYTABLE does not specify something else to do. Zero
531 means the default is an error. */
532 static const yytype_uint8 yydefact[] =
534 0, 4, 0, 11, 1, 0, 0, 12, 13, 16,
535 0, 0, 2, 20, 5, 0, 0, 11, 19, 21,
536 9, 10, 0, 7, 14, 6, 8, 17, 15, 3,
540 /* YYPGOTO[NTERM-NUM]. */
541 static const yytype_int8 yypgoto[] =
543 -12, -12, -6, 10, -12, -10, -12, 6, -12, -12,
547 /* YYDEFGOTO[NTERM-NUM]. */
548 static const yytype_int8 yydefgoto[] =
550 -1, 2, 13, 14, 17, 22, 23, 6, 7, 27,
554 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
555 positive, shift that token. If negative, reduce the rule whose
556 number is the opposite. If YYTABLE_NINF, syntax error. */
557 static const yytype_uint8 yytable[] =
559 1, 4, 20, 21, 1, 8, 9, 18, 5, 19,
560 3, 11, 16, 26, 25, 28, 30, 0, 0, 0,
564 static const yytype_int8 yycheck[] =
566 5, 0, 6, 7, 5, 3, 3, 12, 10, 15,
567 0, 11, 8, 23, 9, 24, 27, -1, -1, -1,
571 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
572 symbol of state STATE-NUM. */
573 static const yytype_uint8 yystos[] =
575 0, 5, 14, 16, 0, 10, 20, 21, 3, 3,
576 23, 11, 25, 15, 16, 26, 8, 17, 12, 15,
577 6, 7, 18, 19, 20, 9, 18, 22, 23, 24,
581 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
582 static const yytype_uint8 yyr1[] =
584 0, 13, 14, 15, 16, 17, 17, 18, 18, 19,
585 19, 20, 20, 21, 22, 22, 23, 24, 24, 25,
589 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
590 static const yytype_uint8 yyr2[] =
592 0, 2, 4, 5, 1, 0, 3, 1, 2, 1,
593 1, 0, 1, 2, 0, 1, 1, 0, 1, 3,
598 #define yyerrok (yyerrstatus = 0)
599 #define yyclearin (yychar = YYEMPTY)
603 #define YYACCEPT goto yyacceptlab
604 #define YYABORT goto yyabortlab
605 #define YYERROR goto yyerrorlab
608 #define YYRECOVERING() (!!yyerrstatus)
610 #define YYBACKUP(Token, Value) \
612 if (yychar == YYEMPTY) \
616 YYPOPSTACK (yylen); \
622 yyerror (YY_("syntax error: cannot back up")); \
627 /* Error token number */
629 #define YYERRCODE 256
633 /* Enable debugging if requested. */
637 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
638 # define YYFPRINTF fprintf
641 # define YYDPRINTF(Args) \
647 /* This macro is provided for backward compatibility. */
648 #ifndef YY_LOCATION_PRINT
649 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
653 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
657 YYFPRINTF (stderr, "%s ", Title); \
658 yy_symbol_print (stderr, \
660 YYFPRINTF (stderr, "\n"); \
665 /*----------------------------------------.
666 | Print this symbol's value on YYOUTPUT. |
667 `----------------------------------------*/
670 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
672 FILE *yyo = yyoutput;
677 if (yytype < YYNTOKENS)
678 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
684 /*--------------------------------.
685 | Print this symbol on YYOUTPUT. |
686 `--------------------------------*/
689 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
691 YYFPRINTF (yyoutput, "%s %s (",
692 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
694 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
695 YYFPRINTF (yyoutput, ")");
698 /*------------------------------------------------------------------.
699 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
701 `------------------------------------------------------------------*/
704 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
706 YYFPRINTF (stderr, "Stack now");
707 for (; yybottom <= yytop; yybottom++)
709 int yybot = *yybottom;
710 YYFPRINTF (stderr, " %d", yybot);
712 YYFPRINTF (stderr, "\n");
715 # define YY_STACK_PRINT(Bottom, Top) \
718 yy_stack_print ((Bottom), (Top)); \
722 /*------------------------------------------------.
723 | Report that the YYRULE is going to be reduced. |
724 `------------------------------------------------*/
727 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
729 unsigned long int yylno = yyrline[yyrule];
730 int yynrhs = yyr2[yyrule];
732 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
734 /* The symbols being reduced. */
735 for (yyi = 0; yyi < yynrhs; yyi++)
737 YYFPRINTF (stderr, " $%d = ", yyi + 1);
738 yy_symbol_print (stderr,
739 yystos[yyssp[yyi + 1 - yynrhs]],
740 &(yyvsp[(yyi + 1) - (yynrhs)])
742 YYFPRINTF (stderr, "\n");
746 # define YY_REDUCE_PRINT(Rule) \
749 yy_reduce_print (yyssp, yyvsp, Rule); \
752 /* Nonzero means print parse trace. It is left uninitialized so that
753 multiple parsers can coexist. */
756 # define YYDPRINTF(Args)
757 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
758 # define YY_STACK_PRINT(Bottom, Top)
759 # define YY_REDUCE_PRINT(Rule)
760 #endif /* !YYDEBUG */
763 /* YYINITDEPTH -- initial size of the parser's stacks. */
765 # define YYINITDEPTH 200
768 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
769 if the built-in stack extension method is used).
771 Do not make this value too large; the results are undefined if
772 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
773 evaluated with infinite-precision integer arithmetic. */
776 # define YYMAXDEPTH 10000
783 # if defined __GLIBC__ && defined _STRING_H
784 # define yystrlen strlen
786 /* Return the length of YYSTR. */
788 yystrlen (const char *yystr)
791 for (yylen = 0; yystr[yylen]; yylen++)
799 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
800 # define yystpcpy stpcpy
802 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
805 yystpcpy (char *yydest, const char *yysrc)
808 const char *yys = yysrc;
810 while ((*yyd++ = *yys++) != '\0')
819 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
820 quotes and backslashes, so that it's suitable for yyerror. The
821 heuristic is that double-quoting is unnecessary unless the string
822 contains an apostrophe, a comma, or backslash (other than
823 backslash-backslash). YYSTR is taken from yytname. If YYRES is
824 null, do not copy; instead, return the length of what the result
827 yytnamerr (char *yyres, const char *yystr)
832 char const *yyp = yystr;
839 goto do_not_strip_quotes;
843 goto do_not_strip_quotes;
856 do_not_strip_quotes: ;
860 return yystrlen (yystr);
862 return yystpcpy (yyres, yystr) - yyres;
866 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
867 about the unexpected token YYTOKEN for the state stack whose top is
870 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
871 not large enough to hold the message. In that case, also set
872 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
873 required number of bytes is too large to store. */
875 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
876 yytype_int16 *yyssp, int yytoken)
878 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
879 YYSIZE_T yysize = yysize0;
880 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
881 /* Internationalized format string. */
882 const char *yyformat = YY_NULLPTR;
883 /* Arguments of yyformat. */
884 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
885 /* Number of reported tokens (one for the "unexpected", one per
889 /* There are many possibilities here to consider:
890 - If this state is a consistent state with a default action, then
891 the only way this function was invoked is if the default action
892 is an error action. In that case, don't check for expected
893 tokens because there are none.
894 - The only way there can be no lookahead present (in yychar) is if
895 this state is a consistent state with a default action. Thus,
896 detecting the absence of a lookahead is sufficient to determine
897 that there is no unexpected or expected token to report. In that
898 case, just report a simple "syntax error".
899 - Don't assume there isn't a lookahead just because this state is a
900 consistent state with a default action. There might have been a
901 previous inconsistent state, consistent state with a non-default
902 action, or user semantic action that manipulated yychar.
903 - Of course, the expected token list depends on states to have
904 correct lookahead information, and it depends on the parser not
905 to perform extra reductions after fetching a lookahead from the
906 scanner and before detecting a syntax error. Thus, state merging
907 (from LALR or IELR) and default reductions corrupt the expected
908 token list. However, the list is correct for canonical LR with
909 one exception: it will still contain any token that will not be
910 accepted due to an error action in a later state.
912 if (yytoken != YYEMPTY)
914 int yyn = yypact[*yyssp];
915 yyarg[yycount++] = yytname[yytoken];
916 if (!yypact_value_is_default (yyn))
918 /* Start YYX at -YYN if negative to avoid negative indexes in
919 YYCHECK. In other words, skip the first -YYN actions for
920 this state because they are default actions. */
921 int yyxbegin = yyn < 0 ? -yyn : 0;
922 /* Stay within bounds of both yycheck and yytname. */
923 int yychecklim = YYLAST - yyn + 1;
924 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
927 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
928 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
929 && !yytable_value_is_error (yytable[yyx + yyn]))
931 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
937 yyarg[yycount++] = yytname[yyx];
939 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
940 if (! (yysize <= yysize1
941 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
951 # define YYCASE_(N, S) \
955 YYCASE_(0, YY_("syntax error"));
956 YYCASE_(1, YY_("syntax error, unexpected %s"));
957 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
958 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
959 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
960 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
965 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
966 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
971 if (*yymsg_alloc < yysize)
973 *yymsg_alloc = 2 * yysize;
974 if (! (yysize <= *yymsg_alloc
975 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
976 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
980 /* Avoid sprintf, as that infringes on the user's name space.
981 Don't have undefined behavior even if the translation
982 produced a string with the wrong number of "%s"s. */
986 while ((*yyp = *yyformat) != '\0')
987 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
989 yyp += yytnamerr (yyp, yyarg[yyi++]);
1000 #endif /* YYERROR_VERBOSE */
1002 /*-----------------------------------------------.
1003 | Release the memory associated to this symbol. |
1004 `-----------------------------------------------*/
1007 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1012 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1014 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1016 YY_IGNORE_MAYBE_UNINITIALIZED_END
1022 /* The lookahead symbol. */
1025 /* The semantic value of the lookahead symbol. */
1027 /* Number of syntax errors so far. */
1039 /* Number of tokens to shift before error messages enabled. */
1042 /* The stacks and their tools:
1043 'yyss': related to states.
1044 'yyvs': related to semantic values.
1046 Refer to the stacks through separate pointers, to allow yyoverflow
1047 to reallocate them elsewhere. */
1049 /* The state stack. */
1050 yytype_int16 yyssa[YYINITDEPTH];
1052 yytype_int16 *yyssp;
1054 /* The semantic value stack. */
1055 YYSTYPE yyvsa[YYINITDEPTH];
1059 YYSIZE_T yystacksize;
1063 /* Lookahead token as an internal (translated) token number. */
1065 /* The variables used to return semantic value and location from the
1070 /* Buffer for error messages, and its allocated size. */
1072 char *yymsg = yymsgbuf;
1073 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1076 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1078 /* The number of symbols on the RHS of the reduced rule.
1079 Keep to zero when no symbol should be popped. */
1082 yyssp = yyss = yyssa;
1083 yyvsp = yyvs = yyvsa;
1084 yystacksize = YYINITDEPTH;
1086 YYDPRINTF ((stderr, "Starting parse\n"));
1091 yychar = YYEMPTY; /* Cause a token to be read. */
1094 /*------------------------------------------------------------.
1095 | yynewstate -- Push a new state, which is found in yystate. |
1096 `------------------------------------------------------------*/
1098 /* In all cases, when you get here, the value and location stacks
1099 have just been pushed. So pushing a state here evens the stacks. */
1105 if (yyss + yystacksize - 1 <= yyssp)
1107 /* Get the current used size of the three stacks, in elements. */
1108 YYSIZE_T yysize = yyssp - yyss + 1;
1112 /* Give user a chance to reallocate the stack. Use copies of
1113 these so that the &'s don't force the real ones into
1115 YYSTYPE *yyvs1 = yyvs;
1116 yytype_int16 *yyss1 = yyss;
1118 /* Each stack pointer address is followed by the size of the
1119 data in use in that stack, in bytes. This used to be a
1120 conditional around just the two extra args, but that might
1121 be undefined if yyoverflow is a macro. */
1122 yyoverflow (YY_("memory exhausted"),
1123 &yyss1, yysize * sizeof (*yyssp),
1124 &yyvs1, yysize * sizeof (*yyvsp),
1130 #else /* no yyoverflow */
1131 # ifndef YYSTACK_RELOCATE
1132 goto yyexhaustedlab;
1134 /* Extend the stack our own way. */
1135 if (YYMAXDEPTH <= yystacksize)
1136 goto yyexhaustedlab;
1138 if (YYMAXDEPTH < yystacksize)
1139 yystacksize = YYMAXDEPTH;
1142 yytype_int16 *yyss1 = yyss;
1143 union yyalloc *yyptr =
1144 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1146 goto yyexhaustedlab;
1147 YYSTACK_RELOCATE (yyss_alloc, yyss);
1148 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1149 # undef YYSTACK_RELOCATE
1151 YYSTACK_FREE (yyss1);
1154 #endif /* no yyoverflow */
1156 yyssp = yyss + yysize - 1;
1157 yyvsp = yyvs + yysize - 1;
1159 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1160 (unsigned long int) yystacksize));
1162 if (yyss + yystacksize - 1 <= yyssp)
1166 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1168 if (yystate == YYFINAL)
1178 /* Do appropriate processing given the current state. Read a
1179 lookahead token if we need one and don't already have one. */
1181 /* First try to decide what to do without reference to lookahead token. */
1182 yyn = yypact[yystate];
1183 if (yypact_value_is_default (yyn))
1186 /* Not known => get a lookahead token if don't already have one. */
1188 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1189 if (yychar == YYEMPTY)
1191 YYDPRINTF ((stderr, "Reading a token: "));
1195 if (yychar <= YYEOF)
1197 yychar = yytoken = YYEOF;
1198 YYDPRINTF ((stderr, "Now at end of input.\n"));
1202 yytoken = YYTRANSLATE (yychar);
1203 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1206 /* If the proper action on seeing token YYTOKEN is to reduce or to
1207 detect an error, take that action. */
1209 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1214 if (yytable_value_is_error (yyn))
1220 /* Count tokens shifted since error; after three, turn off error
1225 /* Shift the lookahead token. */
1226 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1228 /* Discard the shifted token. */
1232 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1234 YY_IGNORE_MAYBE_UNINITIALIZED_END
1239 /*-----------------------------------------------------------.
1240 | yydefault -- do the default action for the current state. |
1241 `-----------------------------------------------------------*/
1243 yyn = yydefact[yystate];
1249 /*-----------------------------.
1250 | yyreduce -- Do a reduction. |
1251 `-----------------------------*/
1253 /* yyn is the number of a rule to reduce with. */
1256 /* If YYLEN is nonzero, implement the default value of the action:
1259 Otherwise, the following line sets YYVAL to garbage.
1260 This behavior is undocumented and Bison
1261 users should not rely upon it. Assigning to YYVAL
1262 unconditionally makes the parser a bit smaller, and it avoids a
1263 GCC warning that YYVAL may be used uninitialized. */
1264 yyval = yyvsp[1-yylen];
1267 YY_REDUCE_PRINT (yyn);
1271 #line 81 "fmd_parser.y" /* yacc.c:1646 */
1273 union flashmap_flags flags = { .v=0 };
1274 if (!(res = parse_descriptor((yyvsp[-3].strval), flags, (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr))))
1277 #line 1278 "y.tab.c" /* yacc.c:1646 */
1281 #line 88 "fmd_parser.y" /* yacc.c:1646 */
1283 struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-3].flags), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
1287 if (node->flags.f.cbfs && !fmd_process_flag_cbfs(node)) {
1288 ERROR("Section '%s' cannot have flag 'CBFS''\n", node->name);
1292 (yyval.region_ptr) = node;
1294 #line 1295 "y.tab.c" /* yacc.c:1646 */
1298 #line 101 "fmd_parser.y" /* yacc.c:1646 */
1300 if (!(yyvsp[0].strval)) {
1301 perror("E: While allocating section name");
1305 #line 1306 "y.tab.c" /* yacc.c:1646 */
1309 #line 107 "fmd_parser.y" /* yacc.c:1646 */
1310 { (yyval.flags) = (union flashmap_flags){ .v=0 }; }
1311 #line 1312 "y.tab.c" /* yacc.c:1646 */
1315 #line 108 "fmd_parser.y" /* yacc.c:1646 */
1316 { (yyval.flags) = (yyvsp[-1].flags); }
1317 #line 1318 "y.tab.c" /* yacc.c:1646 */
1321 #line 109 "fmd_parser.y" /* yacc.c:1646 */
1322 { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; }
1323 #line 1324 "y.tab.c" /* yacc.c:1646 */
1327 #line 110 "fmd_parser.y" /* yacc.c:1646 */
1328 { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; }
1329 #line 1330 "y.tab.c" /* yacc.c:1646 */
1333 #line 111 "fmd_parser.y" /* yacc.c:1646 */
1334 { (yyval.flags).v = 0; (yyval.flags).f.preserve = 1; }
1335 #line 1336 "y.tab.c" /* yacc.c:1646 */
1339 #line 112 "fmd_parser.y" /* yacc.c:1646 */
1340 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1341 #line 1342 "y.tab.c" /* yacc.c:1646 */
1345 #line 114 "fmd_parser.y" /* yacc.c:1646 */
1346 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1347 #line 1348 "y.tab.c" /* yacc.c:1646 */
1351 #line 115 "fmd_parser.y" /* yacc.c:1646 */
1352 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1353 #line 1354 "y.tab.c" /* yacc.c:1646 */
1357 #line 117 "fmd_parser.y" /* yacc.c:1646 */
1358 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1359 #line 1360 "y.tab.c" /* yacc.c:1646 */
1363 #line 119 "fmd_parser.y" /* yacc.c:1646 */
1365 (yyval.region_listhdr) = (struct descriptor_list)
1366 {.len = 0, .head = NULL, .tail = NULL};
1368 #line 1369 "y.tab.c" /* yacc.c:1646 */
1372 #line 124 "fmd_parser.y" /* yacc.c:1646 */
1373 { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
1374 #line 1375 "y.tab.c" /* yacc.c:1646 */
1378 #line 126 "fmd_parser.y" /* yacc.c:1646 */
1380 struct descriptor_node *node = malloc(sizeof(*node));
1382 perror("E: While allocating linked list node");
1385 node->val = (yyvsp[0].region_ptr);
1387 (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
1389 #line 1390 "y.tab.c" /* yacc.c:1646 */
1393 #line 137 "fmd_parser.y" /* yacc.c:1646 */
1395 struct descriptor_node *node = malloc(sizeof(*node));
1397 perror("E: While allocating linked list node");
1400 node->val = (yyvsp[0].region_ptr);
1403 (yyvsp[-1].region_listhdr).tail->next = node;
1404 (yyval.region_listhdr) = (struct descriptor_list)
1405 {.len = (yyvsp[-1].region_listhdr).len + 1, .head = (yyvsp[-1].region_listhdr).head, .tail = node};
1407 #line 1408 "y.tab.c" /* yacc.c:1646 */
1411 #line 1412 "y.tab.c" /* yacc.c:1646 */
1414 /* User semantic actions sometimes alter yychar, and that requires
1415 that yytoken be updated with the new translation. We take the
1416 approach of translating immediately before every use of yytoken.
1417 One alternative is translating here after every semantic action,
1418 but that translation would be missed if the semantic action invokes
1419 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1420 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1421 incorrect destructor might then be invoked immediately. In the
1422 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1423 to an incorrect destructor call or verbose syntax error message
1424 before the lookahead is translated. */
1425 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1429 YY_STACK_PRINT (yyss, yyssp);
1433 /* Now 'shift' the result of the reduction. Determine what state
1434 that goes to, based on the state we popped back to and the rule
1435 number reduced by. */
1439 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1440 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1441 yystate = yytable[yystate];
1443 yystate = yydefgoto[yyn - YYNTOKENS];
1448 /*--------------------------------------.
1449 | yyerrlab -- here on detecting error. |
1450 `--------------------------------------*/
1452 /* Make sure we have latest lookahead translation. See comments at
1453 user semantic actions for why this is necessary. */
1454 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1456 /* If not already recovering from an error, report this error. */
1460 #if ! YYERROR_VERBOSE
1461 yyerror (YY_("syntax error"));
1463 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1466 char const *yymsgp = YY_("syntax error");
1467 int yysyntax_error_status;
1468 yysyntax_error_status = YYSYNTAX_ERROR;
1469 if (yysyntax_error_status == 0)
1471 else if (yysyntax_error_status == 1)
1473 if (yymsg != yymsgbuf)
1474 YYSTACK_FREE (yymsg);
1475 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1479 yymsg_alloc = sizeof yymsgbuf;
1480 yysyntax_error_status = 2;
1484 yysyntax_error_status = YYSYNTAX_ERROR;
1489 if (yysyntax_error_status == 2)
1490 goto yyexhaustedlab;
1492 # undef YYSYNTAX_ERROR
1498 if (yyerrstatus == 3)
1500 /* If just tried and failed to reuse lookahead token after an
1501 error, discard it. */
1503 if (yychar <= YYEOF)
1505 /* Return failure if at end of input. */
1506 if (yychar == YYEOF)
1511 yydestruct ("Error: discarding",
1517 /* Else will try to reuse lookahead token after shifting the error
1522 /*---------------------------------------------------.
1523 | yyerrorlab -- error raised explicitly by YYERROR. |
1524 `---------------------------------------------------*/
1527 /* Pacify compilers like GCC when the user code never invokes
1528 YYERROR and the label yyerrorlab therefore never appears in user
1530 if (/*CONSTCOND*/ 0)
1533 /* Do not reclaim the symbols of the rule whose action triggered
1537 YY_STACK_PRINT (yyss, yyssp);
1542 /*-------------------------------------------------------------.
1543 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1544 `-------------------------------------------------------------*/
1546 yyerrstatus = 3; /* Each real token shifted decrements this. */
1550 yyn = yypact[yystate];
1551 if (!yypact_value_is_default (yyn))
1554 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1562 /* Pop the current state because it cannot handle the error token. */
1567 yydestruct ("Error: popping",
1568 yystos[yystate], yyvsp);
1571 YY_STACK_PRINT (yyss, yyssp);
1574 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1576 YY_IGNORE_MAYBE_UNINITIALIZED_END
1579 /* Shift the error token. */
1580 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1586 /*-------------------------------------.
1587 | yyacceptlab -- YYACCEPT comes here. |
1588 `-------------------------------------*/
1593 /*-----------------------------------.
1594 | yyabortlab -- YYABORT comes here. |
1595 `-----------------------------------*/
1600 #if !defined yyoverflow || YYERROR_VERBOSE
1601 /*-------------------------------------------------.
1602 | yyexhaustedlab -- memory exhaustion comes here. |
1603 `-------------------------------------------------*/
1605 yyerror (YY_("memory exhausted"));
1611 if (yychar != YYEMPTY)
1613 /* Make sure we have latest lookahead translation. See comments at
1614 user semantic actions for why this is necessary. */
1615 yytoken = YYTRANSLATE (yychar);
1616 yydestruct ("Cleanup: discarding lookahead",
1619 /* Do not reclaim the symbols of the rule whose action triggered
1620 this YYABORT or YYACCEPT. */
1622 YY_STACK_PRINT (yyss, yyssp);
1623 while (yyssp != yyss)
1625 yydestruct ("Cleanup: popping",
1626 yystos[*yyssp], yyvsp);
1631 YYSTACK_FREE (yyss);
1634 if (yymsg != yymsgbuf)
1635 YYSTACK_FREE (yymsg);
1639 #line 151 "fmd_parser.y" /* yacc.c:1906 */
1642 struct flashmap_descriptor *parse_descriptor(
1643 char *name, union flashmap_flags flags, struct unsigned_option offset,
1644 struct unsigned_option size, struct descriptor_list children)
1646 struct flashmap_descriptor *region = malloc(sizeof(*region));
1648 perror("E: While allocating descriptor section");
1651 region->name = name;
1652 region->flags = flags;
1653 region->offset_known = offset.val_known;
1654 region->offset = offset.val;
1655 region->size_known = size.val_known;
1656 region->size = size.val;
1657 region->list_len = children.len;
1658 if (region->list_len) {
1659 region->list = malloc(region->list_len * sizeof(*region->list));
1660 if (!region->list) {
1661 perror("E: While allocating node children array");
1664 struct descriptor_node *cur_node = children.head;
1665 for (unsigned idx = 0; idx < region->list_len; ++idx) {
1666 region->list[idx] = cur_node->val;
1668 struct descriptor_node *next_node = cur_node->next;
1670 cur_node = next_node;
1673 region->list = NULL;
1678 void yyerror(const char *s)
1680 fprintf(stderr, "%s\n", s);