1 /* A Bison parser, made by GNU Bison 3.0.2. */
3 /* Bison implementation for Yacc-like parsers in C
5 Copyright (C) 1984, 1989-1990, 2000-2013 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.2"
50 #define YYSKELETON_NAME "yacc.c"
64 /* Copy the first part of user declarations. */
65 #line 20 "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 37 "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(char *name,
125 struct unsigned_option offset, struct unsigned_option size,
126 struct descriptor_list children);
127 void yyerror(const char *s);
129 #line 130 "y.tab.c" /* yacc.c:355 */
147 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
148 typedef union YYSTYPE YYSTYPE;
151 #line 29 "fmd_parser.y" /* yacc.c:355 */
155 struct unsigned_option maybe_intval;
156 struct flashmap_descriptor *region_ptr;
157 struct descriptor_list region_listhdr;
159 #line 160 "y.tab.c" /* yacc.c:355 */
161 # define YYSTYPE_IS_TRIVIAL 1
162 # define YYSTYPE_IS_DECLARED 1
166 extern YYSTYPE yylval;
170 #endif /* !YY_YY_Y_TAB_H_INCLUDED */
172 /* Copy the second part of user declarations. */
174 #line 175 "y.tab.c" /* yacc.c:358 */
181 typedef YYTYPE_UINT8 yytype_uint8;
183 typedef unsigned char yytype_uint8;
187 typedef YYTYPE_INT8 yytype_int8;
189 typedef signed char yytype_int8;
193 typedef YYTYPE_UINT16 yytype_uint16;
195 typedef unsigned short int yytype_uint16;
199 typedef YYTYPE_INT16 yytype_int16;
201 typedef short int yytype_int16;
205 # ifdef __SIZE_TYPE__
206 # define YYSIZE_T __SIZE_TYPE__
207 # elif defined size_t
208 # define YYSIZE_T size_t
209 # elif ! defined YYSIZE_T
210 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
211 # define YYSIZE_T size_t
213 # define YYSIZE_T unsigned int
217 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
220 # if defined YYENABLE_NLS && YYENABLE_NLS
222 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
223 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
227 # define YY_(Msgid) Msgid
232 # if (defined __GNUC__ \
233 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
234 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
235 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
237 # define YY_ATTRIBUTE(Spec) /* empty */
241 #ifndef YY_ATTRIBUTE_PURE
242 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
245 #ifndef YY_ATTRIBUTE_UNUSED
246 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
249 #if !defined _Noreturn \
250 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
251 # if defined _MSC_VER && 1200 <= _MSC_VER
252 # define _Noreturn __declspec (noreturn)
254 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
258 /* Suppress unused-variable warnings by "using" E. */
259 #if ! defined lint || defined __GNUC__
260 # define YYUSE(E) ((void) (E))
262 # define YYUSE(E) /* empty */
265 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
266 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
267 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
268 _Pragma ("GCC diagnostic push") \
269 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
270 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
271 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
272 _Pragma ("GCC diagnostic pop")
274 # define YY_INITIAL_VALUE(Value) Value
276 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
277 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
278 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
280 #ifndef YY_INITIAL_VALUE
281 # define YY_INITIAL_VALUE(Value) /* Nothing. */
285 #if ! defined yyoverflow || YYERROR_VERBOSE
287 /* The parser invokes alloca or malloc; define the necessary symbols. */
289 # ifdef YYSTACK_USE_ALLOCA
290 # if YYSTACK_USE_ALLOCA
292 # define YYSTACK_ALLOC __builtin_alloca
293 # elif defined __BUILTIN_VA_ARG_INCR
294 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
296 # define YYSTACK_ALLOC __alloca
297 # elif defined _MSC_VER
298 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
299 # define alloca _alloca
301 # define YYSTACK_ALLOC alloca
302 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
303 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
304 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
305 # ifndef EXIT_SUCCESS
306 # define EXIT_SUCCESS 0
313 # ifdef YYSTACK_ALLOC
314 /* Pacify GCC's 'empty if-body' warning. */
315 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
316 # ifndef YYSTACK_ALLOC_MAXIMUM
317 /* The OS might guarantee only one guard page at the bottom of the stack,
318 and a page size can be as small as 4096 bytes. So we cannot safely
319 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
320 to allow for a few compiler-allocated temporary stack slots. */
321 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
324 # define YYSTACK_ALLOC YYMALLOC
325 # define YYSTACK_FREE YYFREE
326 # ifndef YYSTACK_ALLOC_MAXIMUM
327 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
329 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
330 && ! ((defined YYMALLOC || defined malloc) \
331 && (defined YYFREE || defined free)))
332 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
333 # ifndef EXIT_SUCCESS
334 # define EXIT_SUCCESS 0
338 # define YYMALLOC malloc
339 # if ! defined malloc && ! defined EXIT_SUCCESS
340 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
345 # if ! defined free && ! defined EXIT_SUCCESS
346 void free (void *); /* INFRINGES ON USER NAME SPACE */
350 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
353 #if (! defined yyoverflow \
354 && (! defined __cplusplus \
355 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
357 /* A type that is properly aligned for any stack member. */
360 yytype_int16 yyss_alloc;
364 /* The size of the maximum gap between one aligned stack and the next. */
365 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
367 /* The size of an array large to enough to hold all stacks, each with
369 # define YYSTACK_BYTES(N) \
370 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
371 + YYSTACK_GAP_MAXIMUM)
373 # define YYCOPY_NEEDED 1
375 /* Relocate STACK from its old location to the new one. The
376 local variables YYSIZE and YYSTACKSIZE give the old and new number of
377 elements in the stack, and YYPTR gives the new location of the
378 stack. Advance YYPTR to a properly aligned location for the next
380 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
383 YYSIZE_T yynewbytes; \
384 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
385 Stack = &yyptr->Stack_alloc; \
386 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
387 yyptr += yynewbytes / sizeof (*yyptr); \
393 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
394 /* Copy COUNT objects from SRC to DST. The source and destination do
397 # if defined __GNUC__ && 1 < __GNUC__
398 # define YYCOPY(Dst, Src, Count) \
399 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
401 # define YYCOPY(Dst, Src, Count) \
405 for (yyi = 0; yyi < (Count); yyi++) \
406 (Dst)[yyi] = (Src)[yyi]; \
411 #endif /* !YYCOPY_NEEDED */
413 /* YYFINAL -- State number of the termination state. */
415 /* YYLAST -- Last index in YYTABLE. */
418 /* YYNTOKENS -- Number of terminals. */
420 /* YYNNTS -- Number of nonterminals. */
422 /* YYNRULES -- Number of rules. */
424 /* YYNSTATES -- Number of states. */
427 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
428 by yylex, with out-of-bounds checking. */
430 #define YYMAXUTOK 260
432 #define YYTRANSLATE(YYX) \
433 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
435 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
436 as returned by yylex, without out-of-bounds checking. */
437 static const yytype_uint8 yytranslate[] =
439 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
440 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
441 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
442 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
443 6, 7, 2, 2, 2, 2, 2, 2, 2, 2,
444 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
445 2, 2, 2, 2, 8, 2, 2, 2, 2, 2,
446 2, 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 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
451 2, 2, 2, 9, 2, 10, 2, 2, 2, 2,
452 2, 2, 2, 2, 2, 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, 2, 2, 2, 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, 1, 2, 3, 4,
469 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
470 static const yytype_uint8 yyrline[] =
472 0, 80, 80, 85, 102, 109, 110, 111, 112, 113,
473 114, 115, 116, 117, 119, 123, 124, 125, 136
477 #if YYDEBUG || YYERROR_VERBOSE || 0
478 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
479 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
480 static const char *const yytname[] =
482 "$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING", "'('",
483 "')'", "'@'", "'{'", "'}'", "$accept", "flash_chip", "flash_region",
484 "region_name", "region_annotation_opt", "region_annotation",
485 "region_offset_opt", "region_offset", "region_size_opt", "region_size",
486 "region_list_opt", "region_list", "region_list_entries", YY_NULLPTR
491 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
492 (internal) symbol number NUM (which must be that of a token). */
493 static const yytype_uint16 yytoknum[] =
495 0, 256, 257, 258, 259, 260, 40, 41, 64, 123,
500 #define YYPACT_NINF -10
502 #define yypact_value_is_default(Yystate) \
503 (!!((Yystate) == (-10)))
505 #define YYTABLE_NINF -1
507 #define yytable_value_is_error(Yytable_value) \
510 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
512 static const yytype_int8 yypact[] =
514 -4, -10, 2, -2, -10, 0, 1, -10, -10, -10,
515 -1, -4, -10, -10, 3, -5, 5, -2, -10, -10,
516 -10, 4, 1, -10, -1, -10, -10, -10
519 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
520 Performed when YYTABLE does not specify something else to do. Zero
521 means the default is an error. */
522 static const yytype_uint8 yydefact[] =
524 0, 4, 0, 8, 1, 0, 0, 9, 10, 13,
525 0, 0, 2, 17, 5, 0, 0, 8, 6, 16,
526 18, 0, 11, 7, 14, 12, 3, 15
529 /* YYPGOTO[NTERM-NUM]. */
530 static const yytype_int8 yypgoto[] =
532 -10, -10, -8, 12, -10, -10, -3, -10, -10, -9,
536 /* YYDEFGOTO[NTERM-NUM]. */
537 static const yytype_int8 yydefgoto[] =
539 -1, 2, 13, 14, 17, 18, 6, 7, 24, 10,
543 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
544 positive, shift that token. If negative, reduce the rule whose
545 number is the opposite. If YYTABLE_NINF, syntax error. */
546 static const yytype_uint8 yytable[] =
548 1, 1, 4, 8, 9, 19, 5, 20, 11, 16,
549 21, 23, 3, 25, 22, 0, 0, 27
552 static const yytype_int8 yycheck[] =
554 5, 5, 0, 3, 3, 10, 8, 15, 9, 6,
555 5, 7, 0, 22, 17, -1, -1, 24
558 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
559 symbol of state STATE-NUM. */
560 static const yytype_uint8 yystos[] =
562 0, 5, 12, 14, 0, 8, 17, 18, 3, 3,
563 20, 9, 22, 13, 14, 23, 6, 15, 16, 10,
564 13, 5, 17, 7, 19, 20, 21, 22
567 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
568 static const yytype_uint8 yyr1[] =
570 0, 11, 12, 13, 14, 15, 15, 16, 17, 17,
571 18, 19, 19, 20, 21, 21, 22, 23, 23
574 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
575 static const yytype_uint8 yyr2[] =
577 0, 2, 4, 5, 1, 0, 1, 3, 0, 1,
578 2, 0, 1, 1, 0, 1, 3, 1, 2
582 #define yyerrok (yyerrstatus = 0)
583 #define yyclearin (yychar = YYEMPTY)
587 #define YYACCEPT goto yyacceptlab
588 #define YYABORT goto yyabortlab
589 #define YYERROR goto yyerrorlab
592 #define YYRECOVERING() (!!yyerrstatus)
594 #define YYBACKUP(Token, Value) \
596 if (yychar == YYEMPTY) \
600 YYPOPSTACK (yylen); \
606 yyerror (YY_("syntax error: cannot back up")); \
611 /* Error token number */
613 #define YYERRCODE 256
617 /* Enable debugging if requested. */
621 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
622 # define YYFPRINTF fprintf
625 # define YYDPRINTF(Args) \
631 /* This macro is provided for backward compatibility. */
632 #ifndef YY_LOCATION_PRINT
633 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
637 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
641 YYFPRINTF (stderr, "%s ", Title); \
642 yy_symbol_print (stderr, \
644 YYFPRINTF (stderr, "\n"); \
649 /*----------------------------------------.
650 | Print this symbol's value on YYOUTPUT. |
651 `----------------------------------------*/
654 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
656 FILE *yyo = yyoutput;
661 if (yytype < YYNTOKENS)
662 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
668 /*--------------------------------.
669 | Print this symbol on YYOUTPUT. |
670 `--------------------------------*/
673 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
675 YYFPRINTF (yyoutput, "%s %s (",
676 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
678 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
679 YYFPRINTF (yyoutput, ")");
682 /*------------------------------------------------------------------.
683 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
685 `------------------------------------------------------------------*/
688 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
690 YYFPRINTF (stderr, "Stack now");
691 for (; yybottom <= yytop; yybottom++)
693 int yybot = *yybottom;
694 YYFPRINTF (stderr, " %d", yybot);
696 YYFPRINTF (stderr, "\n");
699 # define YY_STACK_PRINT(Bottom, Top) \
702 yy_stack_print ((Bottom), (Top)); \
706 /*------------------------------------------------.
707 | Report that the YYRULE is going to be reduced. |
708 `------------------------------------------------*/
711 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
713 unsigned long int yylno = yyrline[yyrule];
714 int yynrhs = yyr2[yyrule];
716 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
718 /* The symbols being reduced. */
719 for (yyi = 0; yyi < yynrhs; yyi++)
721 YYFPRINTF (stderr, " $%d = ", yyi + 1);
722 yy_symbol_print (stderr,
723 yystos[yyssp[yyi + 1 - yynrhs]],
724 &(yyvsp[(yyi + 1) - (yynrhs)])
726 YYFPRINTF (stderr, "\n");
730 # define YY_REDUCE_PRINT(Rule) \
733 yy_reduce_print (yyssp, yyvsp, Rule); \
736 /* Nonzero means print parse trace. It is left uninitialized so that
737 multiple parsers can coexist. */
740 # define YYDPRINTF(Args)
741 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
742 # define YY_STACK_PRINT(Bottom, Top)
743 # define YY_REDUCE_PRINT(Rule)
744 #endif /* !YYDEBUG */
747 /* YYINITDEPTH -- initial size of the parser's stacks. */
749 # define YYINITDEPTH 200
752 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
753 if the built-in stack extension method is used).
755 Do not make this value too large; the results are undefined if
756 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
757 evaluated with infinite-precision integer arithmetic. */
760 # define YYMAXDEPTH 10000
767 # if defined __GLIBC__ && defined _STRING_H
768 # define yystrlen strlen
770 /* Return the length of YYSTR. */
772 yystrlen (const char *yystr)
775 for (yylen = 0; yystr[yylen]; yylen++)
783 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
784 # define yystpcpy stpcpy
786 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
789 yystpcpy (char *yydest, const char *yysrc)
792 const char *yys = yysrc;
794 while ((*yyd++ = *yys++) != '\0')
803 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
804 quotes and backslashes, so that it's suitable for yyerror. The
805 heuristic is that double-quoting is unnecessary unless the string
806 contains an apostrophe, a comma, or backslash (other than
807 backslash-backslash). YYSTR is taken from yytname. If YYRES is
808 null, do not copy; instead, return the length of what the result
811 yytnamerr (char *yyres, const char *yystr)
816 char const *yyp = yystr;
823 goto do_not_strip_quotes;
827 goto do_not_strip_quotes;
840 do_not_strip_quotes: ;
844 return yystrlen (yystr);
846 return yystpcpy (yyres, yystr) - yyres;
850 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
851 about the unexpected token YYTOKEN for the state stack whose top is
854 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
855 not large enough to hold the message. In that case, also set
856 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
857 required number of bytes is too large to store. */
859 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
860 yytype_int16 *yyssp, int yytoken)
862 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
863 YYSIZE_T yysize = yysize0;
864 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
865 /* Internationalized format string. */
866 const char *yyformat = YY_NULLPTR;
867 /* Arguments of yyformat. */
868 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
869 /* Number of reported tokens (one for the "unexpected", one per
873 /* There are many possibilities here to consider:
874 - If this state is a consistent state with a default action, then
875 the only way this function was invoked is if the default action
876 is an error action. In that case, don't check for expected
877 tokens because there are none.
878 - The only way there can be no lookahead present (in yychar) is if
879 this state is a consistent state with a default action. Thus,
880 detecting the absence of a lookahead is sufficient to determine
881 that there is no unexpected or expected token to report. In that
882 case, just report a simple "syntax error".
883 - Don't assume there isn't a lookahead just because this state is a
884 consistent state with a default action. There might have been a
885 previous inconsistent state, consistent state with a non-default
886 action, or user semantic action that manipulated yychar.
887 - Of course, the expected token list depends on states to have
888 correct lookahead information, and it depends on the parser not
889 to perform extra reductions after fetching a lookahead from the
890 scanner and before detecting a syntax error. Thus, state merging
891 (from LALR or IELR) and default reductions corrupt the expected
892 token list. However, the list is correct for canonical LR with
893 one exception: it will still contain any token that will not be
894 accepted due to an error action in a later state.
896 if (yytoken != YYEMPTY)
898 int yyn = yypact[*yyssp];
899 yyarg[yycount++] = yytname[yytoken];
900 if (!yypact_value_is_default (yyn))
902 /* Start YYX at -YYN if negative to avoid negative indexes in
903 YYCHECK. In other words, skip the first -YYN actions for
904 this state because they are default actions. */
905 int yyxbegin = yyn < 0 ? -yyn : 0;
906 /* Stay within bounds of both yycheck and yytname. */
907 int yychecklim = YYLAST - yyn + 1;
908 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
911 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
912 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
913 && !yytable_value_is_error (yytable[yyx + yyn]))
915 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
921 yyarg[yycount++] = yytname[yyx];
923 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
924 if (! (yysize <= yysize1
925 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
935 # define YYCASE_(N, S) \
939 YYCASE_(0, YY_("syntax error"));
940 YYCASE_(1, YY_("syntax error, unexpected %s"));
941 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
942 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
943 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
944 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
949 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
950 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
955 if (*yymsg_alloc < yysize)
957 *yymsg_alloc = 2 * yysize;
958 if (! (yysize <= *yymsg_alloc
959 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
960 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
964 /* Avoid sprintf, as that infringes on the user's name space.
965 Don't have undefined behavior even if the translation
966 produced a string with the wrong number of "%s"s. */
970 while ((*yyp = *yyformat) != '\0')
971 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
973 yyp += yytnamerr (yyp, yyarg[yyi++]);
984 #endif /* YYERROR_VERBOSE */
986 /*-----------------------------------------------.
987 | Release the memory associated to this symbol. |
988 `-----------------------------------------------*/
991 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
996 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
998 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1000 YY_IGNORE_MAYBE_UNINITIALIZED_END
1006 /* The lookahead symbol. */
1009 /* The semantic value of the lookahead symbol. */
1011 /* Number of syntax errors so far. */
1023 /* Number of tokens to shift before error messages enabled. */
1026 /* The stacks and their tools:
1027 'yyss': related to states.
1028 'yyvs': related to semantic values.
1030 Refer to the stacks through separate pointers, to allow yyoverflow
1031 to reallocate them elsewhere. */
1033 /* The state stack. */
1034 yytype_int16 yyssa[YYINITDEPTH];
1036 yytype_int16 *yyssp;
1038 /* The semantic value stack. */
1039 YYSTYPE yyvsa[YYINITDEPTH];
1043 YYSIZE_T yystacksize;
1047 /* Lookahead token as an internal (translated) token number. */
1049 /* The variables used to return semantic value and location from the
1054 /* Buffer for error messages, and its allocated size. */
1056 char *yymsg = yymsgbuf;
1057 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1060 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1062 /* The number of symbols on the RHS of the reduced rule.
1063 Keep to zero when no symbol should be popped. */
1066 yyssp = yyss = yyssa;
1067 yyvsp = yyvs = yyvsa;
1068 yystacksize = YYINITDEPTH;
1070 YYDPRINTF ((stderr, "Starting parse\n"));
1075 yychar = YYEMPTY; /* Cause a token to be read. */
1078 /*------------------------------------------------------------.
1079 | yynewstate -- Push a new state, which is found in yystate. |
1080 `------------------------------------------------------------*/
1082 /* In all cases, when you get here, the value and location stacks
1083 have just been pushed. So pushing a state here evens the stacks. */
1089 if (yyss + yystacksize - 1 <= yyssp)
1091 /* Get the current used size of the three stacks, in elements. */
1092 YYSIZE_T yysize = yyssp - yyss + 1;
1096 /* Give user a chance to reallocate the stack. Use copies of
1097 these so that the &'s don't force the real ones into
1099 YYSTYPE *yyvs1 = yyvs;
1100 yytype_int16 *yyss1 = yyss;
1102 /* Each stack pointer address is followed by the size of the
1103 data in use in that stack, in bytes. This used to be a
1104 conditional around just the two extra args, but that might
1105 be undefined if yyoverflow is a macro. */
1106 yyoverflow (YY_("memory exhausted"),
1107 &yyss1, yysize * sizeof (*yyssp),
1108 &yyvs1, yysize * sizeof (*yyvsp),
1114 #else /* no yyoverflow */
1115 # ifndef YYSTACK_RELOCATE
1116 goto yyexhaustedlab;
1118 /* Extend the stack our own way. */
1119 if (YYMAXDEPTH <= yystacksize)
1120 goto yyexhaustedlab;
1122 if (YYMAXDEPTH < yystacksize)
1123 yystacksize = YYMAXDEPTH;
1126 yytype_int16 *yyss1 = yyss;
1127 union yyalloc *yyptr =
1128 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1130 goto yyexhaustedlab;
1131 YYSTACK_RELOCATE (yyss_alloc, yyss);
1132 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1133 # undef YYSTACK_RELOCATE
1135 YYSTACK_FREE (yyss1);
1138 #endif /* no yyoverflow */
1140 yyssp = yyss + yysize - 1;
1141 yyvsp = yyvs + yysize - 1;
1143 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1144 (unsigned long int) yystacksize));
1146 if (yyss + yystacksize - 1 <= yyssp)
1150 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1152 if (yystate == YYFINAL)
1162 /* Do appropriate processing given the current state. Read a
1163 lookahead token if we need one and don't already have one. */
1165 /* First try to decide what to do without reference to lookahead token. */
1166 yyn = yypact[yystate];
1167 if (yypact_value_is_default (yyn))
1170 /* Not known => get a lookahead token if don't already have one. */
1172 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1173 if (yychar == YYEMPTY)
1175 YYDPRINTF ((stderr, "Reading a token: "));
1179 if (yychar <= YYEOF)
1181 yychar = yytoken = YYEOF;
1182 YYDPRINTF ((stderr, "Now at end of input.\n"));
1186 yytoken = YYTRANSLATE (yychar);
1187 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1190 /* If the proper action on seeing token YYTOKEN is to reduce or to
1191 detect an error, take that action. */
1193 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1198 if (yytable_value_is_error (yyn))
1204 /* Count tokens shifted since error; after three, turn off error
1209 /* Shift the lookahead token. */
1210 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1212 /* Discard the shifted token. */
1216 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1218 YY_IGNORE_MAYBE_UNINITIALIZED_END
1223 /*-----------------------------------------------------------.
1224 | yydefault -- do the default action for the current state. |
1225 `-----------------------------------------------------------*/
1227 yyn = yydefact[yystate];
1233 /*-----------------------------.
1234 | yyreduce -- Do a reduction. |
1235 `-----------------------------*/
1237 /* yyn is the number of a rule to reduce with. */
1240 /* If YYLEN is nonzero, implement the default value of the action:
1243 Otherwise, the following line sets YYVAL to garbage.
1244 This behavior is undocumented and Bison
1245 users should not rely upon it. Assigning to YYVAL
1246 unconditionally makes the parser a bit smaller, and it avoids a
1247 GCC warning that YYVAL may be used uninitialized. */
1248 yyval = yyvsp[1-yylen];
1251 YY_REDUCE_PRINT (yyn);
1255 #line 81 "fmd_parser.y" /* yacc.c:1646 */
1257 if (!(res = parse_descriptor((yyvsp[-3].strval), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr))))
1260 #line 1261 "y.tab.c" /* yacc.c:1646 */
1264 #line 87 "fmd_parser.y" /* yacc.c:1646 */
1266 struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
1270 char *annotation = (yyvsp[-3].strval);
1271 if (annotation && !fmd_process_annotation_impl(node, annotation)) {
1272 ERROR("Section '%s' has unexpected annotation '(%s)'\n",
1273 node->name, annotation);
1278 (yyval.region_ptr) = node;
1280 #line 1281 "y.tab.c" /* yacc.c:1646 */
1284 #line 103 "fmd_parser.y" /* yacc.c:1646 */
1286 if (!(yyvsp[0].strval)) {
1287 perror("E: While allocating section name");
1291 #line 1292 "y.tab.c" /* yacc.c:1646 */
1295 #line 109 "fmd_parser.y" /* yacc.c:1646 */
1296 { (yyval.strval) = NULL; }
1297 #line 1298 "y.tab.c" /* yacc.c:1646 */
1301 #line 111 "fmd_parser.y" /* yacc.c:1646 */
1302 { (yyval.strval) = (yyvsp[-1].strval); }
1303 #line 1304 "y.tab.c" /* yacc.c:1646 */
1307 #line 112 "fmd_parser.y" /* yacc.c:1646 */
1308 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1309 #line 1310 "y.tab.c" /* yacc.c:1646 */
1313 #line 114 "fmd_parser.y" /* yacc.c:1646 */
1314 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1315 #line 1316 "y.tab.c" /* yacc.c:1646 */
1319 #line 115 "fmd_parser.y" /* yacc.c:1646 */
1320 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1321 #line 1322 "y.tab.c" /* yacc.c:1646 */
1325 #line 117 "fmd_parser.y" /* yacc.c:1646 */
1326 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1327 #line 1328 "y.tab.c" /* yacc.c:1646 */
1331 #line 119 "fmd_parser.y" /* yacc.c:1646 */
1333 (yyval.region_listhdr) = (struct descriptor_list)
1334 {.len = 0, .head = NULL, .tail = NULL};
1336 #line 1337 "y.tab.c" /* yacc.c:1646 */
1340 #line 124 "fmd_parser.y" /* yacc.c:1646 */
1341 { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
1342 #line 1343 "y.tab.c" /* yacc.c:1646 */
1346 #line 126 "fmd_parser.y" /* yacc.c:1646 */
1348 struct descriptor_node *node = malloc(sizeof(*node));
1350 perror("E: While allocating linked list node");
1353 node->val = (yyvsp[0].region_ptr);
1355 (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
1357 #line 1358 "y.tab.c" /* yacc.c:1646 */
1361 #line 137 "fmd_parser.y" /* yacc.c:1646 */
1363 struct descriptor_node *node = malloc(sizeof(*node));
1365 perror("E: While allocating linked list node");
1368 node->val = (yyvsp[0].region_ptr);
1371 (yyvsp[-1].region_listhdr).tail->next = node;
1372 (yyval.region_listhdr) = (struct descriptor_list)
1373 {.len = (yyvsp[-1].region_listhdr).len + 1, .head = (yyvsp[-1].region_listhdr).head, .tail = node};
1375 #line 1376 "y.tab.c" /* yacc.c:1646 */
1379 #line 1380 "y.tab.c" /* yacc.c:1646 */
1382 /* User semantic actions sometimes alter yychar, and that requires
1383 that yytoken be updated with the new translation. We take the
1384 approach of translating immediately before every use of yytoken.
1385 One alternative is translating here after every semantic action,
1386 but that translation would be missed if the semantic action invokes
1387 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1388 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1389 incorrect destructor might then be invoked immediately. In the
1390 case of YYERROR or YYBACKUP, subsequent parser actions might lead
1391 to an incorrect destructor call or verbose syntax error message
1392 before the lookahead is translated. */
1393 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
1397 YY_STACK_PRINT (yyss, yyssp);
1401 /* Now 'shift' the result of the reduction. Determine what state
1402 that goes to, based on the state we popped back to and the rule
1403 number reduced by. */
1407 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1408 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1409 yystate = yytable[yystate];
1411 yystate = yydefgoto[yyn - YYNTOKENS];
1416 /*--------------------------------------.
1417 | yyerrlab -- here on detecting error. |
1418 `--------------------------------------*/
1420 /* Make sure we have latest lookahead translation. See comments at
1421 user semantic actions for why this is necessary. */
1422 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
1424 /* If not already recovering from an error, report this error. */
1428 #if ! YYERROR_VERBOSE
1429 yyerror (YY_("syntax error"));
1431 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1434 char const *yymsgp = YY_("syntax error");
1435 int yysyntax_error_status;
1436 yysyntax_error_status = YYSYNTAX_ERROR;
1437 if (yysyntax_error_status == 0)
1439 else if (yysyntax_error_status == 1)
1441 if (yymsg != yymsgbuf)
1442 YYSTACK_FREE (yymsg);
1443 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1447 yymsg_alloc = sizeof yymsgbuf;
1448 yysyntax_error_status = 2;
1452 yysyntax_error_status = YYSYNTAX_ERROR;
1457 if (yysyntax_error_status == 2)
1458 goto yyexhaustedlab;
1460 # undef YYSYNTAX_ERROR
1466 if (yyerrstatus == 3)
1468 /* If just tried and failed to reuse lookahead token after an
1469 error, discard it. */
1471 if (yychar <= YYEOF)
1473 /* Return failure if at end of input. */
1474 if (yychar == YYEOF)
1479 yydestruct ("Error: discarding",
1485 /* Else will try to reuse lookahead token after shifting the error
1490 /*---------------------------------------------------.
1491 | yyerrorlab -- error raised explicitly by YYERROR. |
1492 `---------------------------------------------------*/
1495 /* Pacify compilers like GCC when the user code never invokes
1496 YYERROR and the label yyerrorlab therefore never appears in user
1498 if (/*CONSTCOND*/ 0)
1501 /* Do not reclaim the symbols of the rule whose action triggered
1505 YY_STACK_PRINT (yyss, yyssp);
1510 /*-------------------------------------------------------------.
1511 | yyerrlab1 -- common code for both syntax error and YYERROR. |
1512 `-------------------------------------------------------------*/
1514 yyerrstatus = 3; /* Each real token shifted decrements this. */
1518 yyn = yypact[yystate];
1519 if (!yypact_value_is_default (yyn))
1522 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1530 /* Pop the current state because it cannot handle the error token. */
1535 yydestruct ("Error: popping",
1536 yystos[yystate], yyvsp);
1539 YY_STACK_PRINT (yyss, yyssp);
1542 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1544 YY_IGNORE_MAYBE_UNINITIALIZED_END
1547 /* Shift the error token. */
1548 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1554 /*-------------------------------------.
1555 | yyacceptlab -- YYACCEPT comes here. |
1556 `-------------------------------------*/
1561 /*-----------------------------------.
1562 | yyabortlab -- YYABORT comes here. |
1563 `-----------------------------------*/
1568 #if !defined yyoverflow || YYERROR_VERBOSE
1569 /*-------------------------------------------------.
1570 | yyexhaustedlab -- memory exhaustion comes here. |
1571 `-------------------------------------------------*/
1573 yyerror (YY_("memory exhausted"));
1579 if (yychar != YYEMPTY)
1581 /* Make sure we have latest lookahead translation. See comments at
1582 user semantic actions for why this is necessary. */
1583 yytoken = YYTRANSLATE (yychar);
1584 yydestruct ("Cleanup: discarding lookahead",
1587 /* Do not reclaim the symbols of the rule whose action triggered
1588 this YYABORT or YYACCEPT. */
1590 YY_STACK_PRINT (yyss, yyssp);
1591 while (yyssp != yyss)
1593 yydestruct ("Cleanup: popping",
1594 yystos[*yyssp], yyvsp);
1599 YYSTACK_FREE (yyss);
1602 if (yymsg != yymsgbuf)
1603 YYSTACK_FREE (yymsg);
1607 #line 151 "fmd_parser.y" /* yacc.c:1906 */
1610 struct flashmap_descriptor *parse_descriptor(char *name,
1611 struct unsigned_option offset, struct unsigned_option size,
1612 struct descriptor_list children)
1614 struct flashmap_descriptor *region = malloc(sizeof(*region));
1616 perror("E: While allocating descriptor section");
1619 region->name = name;
1620 region->offset_known = offset.val_known;
1621 region->offset = offset.val;
1622 region->size_known = size.val_known;
1623 region->size = size.val;
1624 region->list_len = children.len;
1625 if (region->list_len) {
1626 region->list = malloc(region->list_len * sizeof(*region->list));
1627 if (!region->list) {
1628 perror("E: While allocating node children array");
1631 struct descriptor_node *cur_node = children.head;
1632 for (unsigned idx = 0; idx < region->list_len; ++idx) {
1633 region->list[idx] = cur_node->val;
1635 struct descriptor_node *next_node = cur_node->next;
1637 cur_node = next_node;
1640 region->list = NULL;
1645 void yyerror(const char *s)
1647 fprintf(stderr, "%s\n", s);