blob: d46339325621a0b4c3c91883ed01f3d019ef525c [file] [log] [blame]
Sol Boucher69b88bf2015-02-26 11:47:19 -08001/* A Bison parser, made by GNU Bison 3.0.2. */
2
3/* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6
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.
11
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.
16
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/>. */
19
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.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33/* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
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. */
42
43/* Identify Bison output. */
44#define YYBISON 1
45
46/* Bison version. */
47#define YYBISON_VERSION "3.0.2"
48
49/* Skeleton name. */
50#define YYSKELETON_NAME "yacc.c"
51
52/* Pure parsers. */
53#define YYPURE 0
54
55/* Push parsers. */
56#define YYPUSH 0
57
58/* Pull parsers. */
59#define YYPULL 1
60
61
62
63
64/* Copy the first part of user declarations. */
65#line 20 "fmd_parser.y" /* yacc.c:339 */
66
67#include "fmd_scanner.h"
Sol Boucherb9740812015-03-18 10:13:48 -070068#include "common.h"
Sol Boucher69b88bf2015-02-26 11:47:19 -080069
70#include <stdlib.h>
71
72struct flashmap_descriptor *res = NULL;
73
Sol Boucherb9740812015-03-18 10:13:48 -070074#line 75 "y.tab.c" /* yacc.c:339 */
Sol Boucher69b88bf2015-02-26 11:47:19 -080075
76# ifndef YY_NULLPTR
77# if defined __cplusplus && 201103L <= __cplusplus
78# define YY_NULLPTR nullptr
79# else
80# define YY_NULLPTR 0
81# endif
82# endif
83
84/* Enabling verbose error messages. */
85#ifdef YYERROR_VERBOSE
86# undef YYERROR_VERBOSE
87# define YYERROR_VERBOSE 1
88#else
89# define YYERROR_VERBOSE 0
90#endif
91
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
96/* Debug traces. */
97#ifndef YYDEBUG
98# define YYDEBUG 0
99#endif
100#if YYDEBUG
101extern int yydebug;
102#endif
103/* "%code requires" blocks. */
Sol Boucherb9740812015-03-18 10:13:48 -0700104#line 37 "fmd_parser.y" /* yacc.c:355 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800105
106#include "fmd.h"
107#include "option.h"
108
109#include <stdbool.h>
110
111struct descriptor_node {
112 struct flashmap_descriptor *val;
113 struct descriptor_node *next;
114};
115
116struct descriptor_list {
117 size_t len;
118 struct descriptor_node *head;
119 struct descriptor_node *tail;
120};
121
122extern struct flashmap_descriptor *res;
123
124struct flashmap_descriptor *parse_descriptor(char *name,
125 struct unsigned_option offset, struct unsigned_option size,
126 struct descriptor_list children);
127void yyerror(const char *s);
128
Sol Boucherb9740812015-03-18 10:13:48 -0700129#line 130 "y.tab.c" /* yacc.c:355 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800130
131/* Token type. */
132#ifndef YYTOKENTYPE
133# define YYTOKENTYPE
134 enum yytokentype
135 {
136 INTEGER = 258,
137 OCTAL = 259,
138 STRING = 260
139 };
140#endif
141/* Tokens. */
142#define INTEGER 258
143#define OCTAL 259
144#define STRING 260
145
146/* Value type. */
147#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
148typedef union YYSTYPE YYSTYPE;
149union YYSTYPE
150{
Sol Boucherb9740812015-03-18 10:13:48 -0700151#line 29 "fmd_parser.y" /* yacc.c:355 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800152
153 unsigned intval;
154 char *strval;
155 struct unsigned_option maybe_intval;
156 struct flashmap_descriptor *region_ptr;
157 struct descriptor_list region_listhdr;
158
Sol Boucherb9740812015-03-18 10:13:48 -0700159#line 160 "y.tab.c" /* yacc.c:355 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800160};
161# define YYSTYPE_IS_TRIVIAL 1
162# define YYSTYPE_IS_DECLARED 1
163#endif
164
165
166extern YYSTYPE yylval;
167
168int yyparse (void);
169
170#endif /* !YY_YY_Y_TAB_H_INCLUDED */
171
172/* Copy the second part of user declarations. */
173
Sol Boucherb9740812015-03-18 10:13:48 -0700174#line 175 "y.tab.c" /* yacc.c:358 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800175
176#ifdef short
177# undef short
178#endif
179
180#ifdef YYTYPE_UINT8
181typedef YYTYPE_UINT8 yytype_uint8;
182#else
183typedef unsigned char yytype_uint8;
184#endif
185
186#ifdef YYTYPE_INT8
187typedef YYTYPE_INT8 yytype_int8;
188#else
189typedef signed char yytype_int8;
190#endif
191
192#ifdef YYTYPE_UINT16
193typedef YYTYPE_UINT16 yytype_uint16;
194#else
195typedef unsigned short int yytype_uint16;
196#endif
197
198#ifdef YYTYPE_INT16
199typedef YYTYPE_INT16 yytype_int16;
200#else
201typedef short int yytype_int16;
202#endif
203
204#ifndef YYSIZE_T
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
212# else
213# define YYSIZE_T unsigned int
214# endif
215#endif
216
217#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
218
219#ifndef YY_
220# if defined YYENABLE_NLS && YYENABLE_NLS
221# if ENABLE_NLS
222# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
223# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
224# endif
225# endif
226# ifndef YY_
227# define YY_(Msgid) Msgid
228# endif
229#endif
230
231#ifndef YY_ATTRIBUTE
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)
236# else
237# define YY_ATTRIBUTE(Spec) /* empty */
238# endif
239#endif
240
241#ifndef YY_ATTRIBUTE_PURE
242# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
243#endif
244
245#ifndef YY_ATTRIBUTE_UNUSED
246# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
247#endif
248
249#if !defined _Noreturn \
250 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
251# if defined _MSC_VER && 1200 <= _MSC_VER
252# define _Noreturn __declspec (noreturn)
253# else
254# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
255# endif
256#endif
257
258/* Suppress unused-variable warnings by "using" E. */
259#if ! defined lint || defined __GNUC__
260# define YYUSE(E) ((void) (E))
261#else
262# define YYUSE(E) /* empty */
263#endif
264
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")
273#else
274# define YY_INITIAL_VALUE(Value) Value
275#endif
276#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
277# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
278# define YY_IGNORE_MAYBE_UNINITIALIZED_END
279#endif
280#ifndef YY_INITIAL_VALUE
281# define YY_INITIAL_VALUE(Value) /* Nothing. */
282#endif
283
284
285#if ! defined yyoverflow || YYERROR_VERBOSE
286
287/* The parser invokes alloca or malloc; define the necessary symbols. */
288
289# ifdef YYSTACK_USE_ALLOCA
290# if YYSTACK_USE_ALLOCA
291# ifdef __GNUC__
292# define YYSTACK_ALLOC __builtin_alloca
293# elif defined __BUILTIN_VA_ARG_INCR
294# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
295# elif defined _AIX
296# define YYSTACK_ALLOC __alloca
297# elif defined _MSC_VER
298# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
299# define alloca _alloca
300# else
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
307# endif
308# endif
309# endif
310# endif
311# endif
312
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 */
322# endif
323# else
324# define YYSTACK_ALLOC YYMALLOC
325# define YYSTACK_FREE YYFREE
326# ifndef YYSTACK_ALLOC_MAXIMUM
327# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
328# endif
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
335# endif
336# endif
337# ifndef YYMALLOC
338# define YYMALLOC malloc
339# if ! defined malloc && ! defined EXIT_SUCCESS
340void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
341# endif
342# endif
343# ifndef YYFREE
344# define YYFREE free
345# if ! defined free && ! defined EXIT_SUCCESS
346void free (void *); /* INFRINGES ON USER NAME SPACE */
347# endif
348# endif
349# endif
350#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
351
352
353#if (! defined yyoverflow \
354 && (! defined __cplusplus \
355 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
356
357/* A type that is properly aligned for any stack member. */
358union yyalloc
359{
360 yytype_int16 yyss_alloc;
361 YYSTYPE yyvs_alloc;
362};
363
364/* The size of the maximum gap between one aligned stack and the next. */
365# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
366
367/* The size of an array large to enough to hold all stacks, each with
368 N elements. */
369# define YYSTACK_BYTES(N) \
370 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
371 + YYSTACK_GAP_MAXIMUM)
372
373# define YYCOPY_NEEDED 1
374
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
379 stack. */
380# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
381 do \
382 { \
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); \
388 } \
389 while (0)
390
391#endif
392
393#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
394/* Copy COUNT objects from SRC to DST. The source and destination do
395 not overlap. */
396# ifndef YYCOPY
397# if defined __GNUC__ && 1 < __GNUC__
398# define YYCOPY(Dst, Src, Count) \
399 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
400# else
401# define YYCOPY(Dst, Src, Count) \
402 do \
403 { \
404 YYSIZE_T yyi; \
405 for (yyi = 0; yyi < (Count); yyi++) \
406 (Dst)[yyi] = (Src)[yyi]; \
407 } \
408 while (0)
409# endif
410# endif
411#endif /* !YYCOPY_NEEDED */
412
413/* YYFINAL -- State number of the termination state. */
414#define YYFINAL 4
415/* YYLAST -- Last index in YYTABLE. */
416#define YYLAST 17
417
418/* YYNTOKENS -- Number of terminals. */
419#define YYNTOKENS 11
420/* YYNNTS -- Number of nonterminals. */
421#define YYNNTS 13
422/* YYNRULES -- Number of rules. */
423#define YYNRULES 18
424/* YYNSTATES -- Number of states. */
425#define YYNSTATES 28
426
427/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
428 by yylex, with out-of-bounds checking. */
429#define YYUNDEFTOK 2
430#define YYMAXUTOK 260
431
432#define YYTRANSLATE(YYX) \
433 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
434
435/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
436 as returned by yylex, without out-of-bounds checking. */
437static const yytype_uint8 yytranslate[] =
438{
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,
465 5
466};
467
468#if YYDEBUG
469 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
470static const yytype_uint8 yyrline[] =
471{
Sol Boucherb9740812015-03-18 10:13:48 -0700472 0, 80, 80, 85, 102, 109, 110, 111, 112, 113,
473 114, 115, 116, 117, 119, 123, 124, 125, 136
Sol Boucher69b88bf2015-02-26 11:47:19 -0800474};
475#endif
476
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. */
480static const char *const yytname[] =
481{
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
487};
488#endif
489
490# ifdef YYPRINT
491/* YYTOKNUM[NUM] -- (External) token number corresponding to the
492 (internal) symbol number NUM (which must be that of a token). */
493static const yytype_uint16 yytoknum[] =
494{
495 0, 256, 257, 258, 259, 260, 40, 41, 64, 123,
496 125
497};
498# endif
499
500#define YYPACT_NINF -10
501
502#define yypact_value_is_default(Yystate) \
503 (!!((Yystate) == (-10)))
504
505#define YYTABLE_NINF -1
506
507#define yytable_value_is_error(Yytable_value) \
508 0
509
510 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
511 STATE-NUM. */
512static const yytype_int8 yypact[] =
513{
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
517};
518
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. */
522static const yytype_uint8 yydefact[] =
523{
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
527};
528
529 /* YYPGOTO[NTERM-NUM]. */
530static const yytype_int8 yypgoto[] =
531{
532 -10, -10, -8, 12, -10, -10, -3, -10, -10, -9,
533 -10, -7, -10
534};
535
536 /* YYDEFGOTO[NTERM-NUM]. */
537static const yytype_int8 yydefgoto[] =
538{
539 -1, 2, 13, 14, 17, 18, 6, 7, 24, 10,
540 26, 12, 15
541};
542
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. */
546static const yytype_uint8 yytable[] =
547{
548 1, 1, 4, 8, 9, 19, 5, 20, 11, 16,
549 21, 23, 3, 25, 22, 0, 0, 27
550};
551
552static const yytype_int8 yycheck[] =
553{
554 5, 5, 0, 3, 3, 10, 8, 15, 9, 6,
555 5, 7, 0, 22, 17, -1, -1, 24
556};
557
558 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
559 symbol of state STATE-NUM. */
560static const yytype_uint8 yystos[] =
561{
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
565};
566
567 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
568static const yytype_uint8 yyr1[] =
569{
570 0, 11, 12, 13, 14, 15, 15, 16, 17, 17,
571 18, 19, 19, 20, 21, 21, 22, 23, 23
572};
573
574 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
575static const yytype_uint8 yyr2[] =
576{
577 0, 2, 4, 5, 1, 0, 1, 3, 0, 1,
578 2, 0, 1, 1, 0, 1, 3, 1, 2
579};
580
581
582#define yyerrok (yyerrstatus = 0)
583#define yyclearin (yychar = YYEMPTY)
584#define YYEMPTY (-2)
585#define YYEOF 0
586
587#define YYACCEPT goto yyacceptlab
588#define YYABORT goto yyabortlab
589#define YYERROR goto yyerrorlab
590
591
592#define YYRECOVERING() (!!yyerrstatus)
593
594#define YYBACKUP(Token, Value) \
595do \
596 if (yychar == YYEMPTY) \
597 { \
598 yychar = (Token); \
599 yylval = (Value); \
600 YYPOPSTACK (yylen); \
601 yystate = *yyssp; \
602 goto yybackup; \
603 } \
604 else \
605 { \
606 yyerror (YY_("syntax error: cannot back up")); \
607 YYERROR; \
608 } \
609while (0)
610
611/* Error token number */
612#define YYTERROR 1
613#define YYERRCODE 256
614
615
616
617/* Enable debugging if requested. */
618#if YYDEBUG
619
620# ifndef YYFPRINTF
621# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
622# define YYFPRINTF fprintf
623# endif
624
625# define YYDPRINTF(Args) \
626do { \
627 if (yydebug) \
628 YYFPRINTF Args; \
629} while (0)
630
631/* This macro is provided for backward compatibility. */
632#ifndef YY_LOCATION_PRINT
633# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
634#endif
635
636
637# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
638do { \
639 if (yydebug) \
640 { \
641 YYFPRINTF (stderr, "%s ", Title); \
642 yy_symbol_print (stderr, \
643 Type, Value); \
644 YYFPRINTF (stderr, "\n"); \
645 } \
646} while (0)
647
648
649/*----------------------------------------.
650| Print this symbol's value on YYOUTPUT. |
651`----------------------------------------*/
652
653static void
654yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
655{
656 FILE *yyo = yyoutput;
657 YYUSE (yyo);
658 if (!yyvaluep)
659 return;
660# ifdef YYPRINT
661 if (yytype < YYNTOKENS)
662 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
663# endif
664 YYUSE (yytype);
665}
666
667
668/*--------------------------------.
669| Print this symbol on YYOUTPUT. |
670`--------------------------------*/
671
672static void
673yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
674{
675 YYFPRINTF (yyoutput, "%s %s (",
676 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
677
678 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
679 YYFPRINTF (yyoutput, ")");
680}
681
682/*------------------------------------------------------------------.
683| yy_stack_print -- Print the state stack from its BOTTOM up to its |
684| TOP (included). |
685`------------------------------------------------------------------*/
686
687static void
688yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
689{
690 YYFPRINTF (stderr, "Stack now");
691 for (; yybottom <= yytop; yybottom++)
692 {
693 int yybot = *yybottom;
694 YYFPRINTF (stderr, " %d", yybot);
695 }
696 YYFPRINTF (stderr, "\n");
697}
698
699# define YY_STACK_PRINT(Bottom, Top) \
700do { \
701 if (yydebug) \
702 yy_stack_print ((Bottom), (Top)); \
703} while (0)
704
705
706/*------------------------------------------------.
707| Report that the YYRULE is going to be reduced. |
708`------------------------------------------------*/
709
710static void
711yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
712{
713 unsigned long int yylno = yyrline[yyrule];
714 int yynrhs = yyr2[yyrule];
715 int yyi;
716 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
717 yyrule - 1, yylno);
718 /* The symbols being reduced. */
719 for (yyi = 0; yyi < yynrhs; yyi++)
720 {
721 YYFPRINTF (stderr, " $%d = ", yyi + 1);
722 yy_symbol_print (stderr,
723 yystos[yyssp[yyi + 1 - yynrhs]],
724 &(yyvsp[(yyi + 1) - (yynrhs)])
725 );
726 YYFPRINTF (stderr, "\n");
727 }
728}
729
730# define YY_REDUCE_PRINT(Rule) \
731do { \
732 if (yydebug) \
733 yy_reduce_print (yyssp, yyvsp, Rule); \
734} while (0)
735
736/* Nonzero means print parse trace. It is left uninitialized so that
737 multiple parsers can coexist. */
738int yydebug;
739#else /* !YYDEBUG */
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 */
745
746
747/* YYINITDEPTH -- initial size of the parser's stacks. */
748#ifndef YYINITDEPTH
749# define YYINITDEPTH 200
750#endif
751
752/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
753 if the built-in stack extension method is used).
754
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. */
758
759#ifndef YYMAXDEPTH
760# define YYMAXDEPTH 10000
761#endif
762
763
764#if YYERROR_VERBOSE
765
766# ifndef yystrlen
767# if defined __GLIBC__ && defined _STRING_H
768# define yystrlen strlen
769# else
770/* Return the length of YYSTR. */
771static YYSIZE_T
772yystrlen (const char *yystr)
773{
774 YYSIZE_T yylen;
775 for (yylen = 0; yystr[yylen]; yylen++)
776 continue;
777 return yylen;
778}
779# endif
780# endif
781
782# ifndef yystpcpy
783# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
784# define yystpcpy stpcpy
785# else
786/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
787 YYDEST. */
788static char *
789yystpcpy (char *yydest, const char *yysrc)
790{
791 char *yyd = yydest;
792 const char *yys = yysrc;
793
794 while ((*yyd++ = *yys++) != '\0')
795 continue;
796
797 return yyd - 1;
798}
799# endif
800# endif
801
802# ifndef yytnamerr
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
809 would have been. */
810static YYSIZE_T
811yytnamerr (char *yyres, const char *yystr)
812{
813 if (*yystr == '"')
814 {
815 YYSIZE_T yyn = 0;
816 char const *yyp = yystr;
817
818 for (;;)
819 switch (*++yyp)
820 {
821 case '\'':
822 case ',':
823 goto do_not_strip_quotes;
824
825 case '\\':
826 if (*++yyp != '\\')
827 goto do_not_strip_quotes;
828 /* Fall through. */
829 default:
830 if (yyres)
831 yyres[yyn] = *yyp;
832 yyn++;
833 break;
834
835 case '"':
836 if (yyres)
837 yyres[yyn] = '\0';
838 return yyn;
839 }
840 do_not_strip_quotes: ;
841 }
842
843 if (! yyres)
844 return yystrlen (yystr);
845
846 return yystpcpy (yyres, yystr) - yyres;
847}
848# endif
849
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
852 YYSSP.
853
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. */
858static int
859yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
860 yytype_int16 *yyssp, int yytoken)
861{
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
870 "expected"). */
871 int yycount = 0;
872
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.
895 */
896 if (yytoken != YYEMPTY)
897 {
898 int yyn = yypact[*yyssp];
899 yyarg[yycount++] = yytname[yytoken];
900 if (!yypact_value_is_default (yyn))
901 {
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;
909 int yyx;
910
911 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
912 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
913 && !yytable_value_is_error (yytable[yyx + yyn]))
914 {
915 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
916 {
917 yycount = 1;
918 yysize = yysize0;
919 break;
920 }
921 yyarg[yycount++] = yytname[yyx];
922 {
923 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
924 if (! (yysize <= yysize1
925 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
926 return 2;
927 yysize = yysize1;
928 }
929 }
930 }
931 }
932
933 switch (yycount)
934 {
935# define YYCASE_(N, S) \
936 case N: \
937 yyformat = S; \
938 break
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"));
945# undef YYCASE_
946 }
947
948 {
949 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
950 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
951 return 2;
952 yysize = yysize1;
953 }
954
955 if (*yymsg_alloc < yysize)
956 {
957 *yymsg_alloc = 2 * yysize;
958 if (! (yysize <= *yymsg_alloc
959 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
960 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
961 return 1;
962 }
963
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. */
967 {
968 char *yyp = *yymsg;
969 int yyi = 0;
970 while ((*yyp = *yyformat) != '\0')
971 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
972 {
973 yyp += yytnamerr (yyp, yyarg[yyi++]);
974 yyformat += 2;
975 }
976 else
977 {
978 yyp++;
979 yyformat++;
980 }
981 }
982 return 0;
983}
984#endif /* YYERROR_VERBOSE */
985
986/*-----------------------------------------------.
987| Release the memory associated to this symbol. |
988`-----------------------------------------------*/
989
990static void
991yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
992{
993 YYUSE (yyvaluep);
994 if (!yymsg)
995 yymsg = "Deleting";
996 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
997
998 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
999 YYUSE (yytype);
1000 YY_IGNORE_MAYBE_UNINITIALIZED_END
1001}
1002
1003
1004
1005
1006/* The lookahead symbol. */
1007int yychar;
1008
1009/* The semantic value of the lookahead symbol. */
1010YYSTYPE yylval;
1011/* Number of syntax errors so far. */
1012int yynerrs;
1013
1014
1015/*----------.
1016| yyparse. |
1017`----------*/
1018
1019int
1020yyparse (void)
1021{
1022 int yystate;
1023 /* Number of tokens to shift before error messages enabled. */
1024 int yyerrstatus;
1025
1026 /* The stacks and their tools:
1027 'yyss': related to states.
1028 'yyvs': related to semantic values.
1029
1030 Refer to the stacks through separate pointers, to allow yyoverflow
1031 to reallocate them elsewhere. */
1032
1033 /* The state stack. */
1034 yytype_int16 yyssa[YYINITDEPTH];
1035 yytype_int16 *yyss;
1036 yytype_int16 *yyssp;
1037
1038 /* The semantic value stack. */
1039 YYSTYPE yyvsa[YYINITDEPTH];
1040 YYSTYPE *yyvs;
1041 YYSTYPE *yyvsp;
1042
1043 YYSIZE_T yystacksize;
1044
1045 int yyn;
1046 int yyresult;
1047 /* Lookahead token as an internal (translated) token number. */
1048 int yytoken = 0;
1049 /* The variables used to return semantic value and location from the
1050 action routines. */
1051 YYSTYPE yyval;
1052
1053#if YYERROR_VERBOSE
1054 /* Buffer for error messages, and its allocated size. */
1055 char yymsgbuf[128];
1056 char *yymsg = yymsgbuf;
1057 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1058#endif
1059
1060#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1061
1062 /* The number of symbols on the RHS of the reduced rule.
1063 Keep to zero when no symbol should be popped. */
1064 int yylen = 0;
1065
1066 yyssp = yyss = yyssa;
1067 yyvsp = yyvs = yyvsa;
1068 yystacksize = YYINITDEPTH;
1069
1070 YYDPRINTF ((stderr, "Starting parse\n"));
1071
1072 yystate = 0;
1073 yyerrstatus = 0;
1074 yynerrs = 0;
1075 yychar = YYEMPTY; /* Cause a token to be read. */
1076 goto yysetstate;
1077
1078/*------------------------------------------------------------.
1079| yynewstate -- Push a new state, which is found in yystate. |
1080`------------------------------------------------------------*/
1081 yynewstate:
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. */
1084 yyssp++;
1085
1086 yysetstate:
1087 *yyssp = yystate;
1088
1089 if (yyss + yystacksize - 1 <= yyssp)
1090 {
1091 /* Get the current used size of the three stacks, in elements. */
1092 YYSIZE_T yysize = yyssp - yyss + 1;
1093
1094#ifdef yyoverflow
1095 {
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
1098 memory. */
1099 YYSTYPE *yyvs1 = yyvs;
1100 yytype_int16 *yyss1 = yyss;
1101
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),
1109 &yystacksize);
1110
1111 yyss = yyss1;
1112 yyvs = yyvs1;
1113 }
1114#else /* no yyoverflow */
1115# ifndef YYSTACK_RELOCATE
1116 goto yyexhaustedlab;
1117# else
1118 /* Extend the stack our own way. */
1119 if (YYMAXDEPTH <= yystacksize)
1120 goto yyexhaustedlab;
1121 yystacksize *= 2;
1122 if (YYMAXDEPTH < yystacksize)
1123 yystacksize = YYMAXDEPTH;
1124
1125 {
1126 yytype_int16 *yyss1 = yyss;
1127 union yyalloc *yyptr =
1128 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1129 if (! yyptr)
1130 goto yyexhaustedlab;
1131 YYSTACK_RELOCATE (yyss_alloc, yyss);
1132 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1133# undef YYSTACK_RELOCATE
1134 if (yyss1 != yyssa)
1135 YYSTACK_FREE (yyss1);
1136 }
1137# endif
1138#endif /* no yyoverflow */
1139
1140 yyssp = yyss + yysize - 1;
1141 yyvsp = yyvs + yysize - 1;
1142
1143 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1144 (unsigned long int) yystacksize));
1145
1146 if (yyss + yystacksize - 1 <= yyssp)
1147 YYABORT;
1148 }
1149
1150 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1151
1152 if (yystate == YYFINAL)
1153 YYACCEPT;
1154
1155 goto yybackup;
1156
1157/*-----------.
1158| yybackup. |
1159`-----------*/
1160yybackup:
1161
1162 /* Do appropriate processing given the current state. Read a
1163 lookahead token if we need one and don't already have one. */
1164
1165 /* First try to decide what to do without reference to lookahead token. */
1166 yyn = yypact[yystate];
1167 if (yypact_value_is_default (yyn))
1168 goto yydefault;
1169
1170 /* Not known => get a lookahead token if don't already have one. */
1171
1172 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1173 if (yychar == YYEMPTY)
1174 {
1175 YYDPRINTF ((stderr, "Reading a token: "));
1176 yychar = yylex ();
1177 }
1178
1179 if (yychar <= YYEOF)
1180 {
1181 yychar = yytoken = YYEOF;
1182 YYDPRINTF ((stderr, "Now at end of input.\n"));
1183 }
1184 else
1185 {
1186 yytoken = YYTRANSLATE (yychar);
1187 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1188 }
1189
1190 /* If the proper action on seeing token YYTOKEN is to reduce or to
1191 detect an error, take that action. */
1192 yyn += yytoken;
1193 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1194 goto yydefault;
1195 yyn = yytable[yyn];
1196 if (yyn <= 0)
1197 {
1198 if (yytable_value_is_error (yyn))
1199 goto yyerrlab;
1200 yyn = -yyn;
1201 goto yyreduce;
1202 }
1203
1204 /* Count tokens shifted since error; after three, turn off error
1205 status. */
1206 if (yyerrstatus)
1207 yyerrstatus--;
1208
1209 /* Shift the lookahead token. */
1210 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1211
1212 /* Discard the shifted token. */
1213 yychar = YYEMPTY;
1214
1215 yystate = yyn;
1216 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1217 *++yyvsp = yylval;
1218 YY_IGNORE_MAYBE_UNINITIALIZED_END
1219
1220 goto yynewstate;
1221
1222
1223/*-----------------------------------------------------------.
1224| yydefault -- do the default action for the current state. |
1225`-----------------------------------------------------------*/
1226yydefault:
1227 yyn = yydefact[yystate];
1228 if (yyn == 0)
1229 goto yyerrlab;
1230 goto yyreduce;
1231
1232
1233/*-----------------------------.
1234| yyreduce -- Do a reduction. |
1235`-----------------------------*/
1236yyreduce:
1237 /* yyn is the number of a rule to reduce with. */
1238 yylen = yyr2[yyn];
1239
1240 /* If YYLEN is nonzero, implement the default value of the action:
1241 '$$ = $1'.
1242
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];
1249
1250
1251 YY_REDUCE_PRINT (yyn);
1252 switch (yyn)
1253 {
1254 case 2:
Sol Boucherb9740812015-03-18 10:13:48 -07001255#line 81 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001256 {
1257 if (!(res = parse_descriptor((yyvsp[-3].strval), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr))))
1258 YYABORT;
1259}
Sol Boucherb9740812015-03-18 10:13:48 -07001260#line 1261 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001261 break;
1262
1263 case 3:
Sol Boucherb9740812015-03-18 10:13:48 -07001264#line 87 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001265 {
1266 struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
1267 if (!node)
1268 YYABORT;
1269
1270 char *annotation = (yyvsp[-3].strval);
1271 if (annotation && !fmd_process_annotation_impl(node, annotation)) {
Sol Boucherb9740812015-03-18 10:13:48 -07001272 ERROR("Section '%s' has unexpected annotation '(%s)'\n",
Sol Boucher69b88bf2015-02-26 11:47:19 -08001273 node->name, annotation);
1274 YYABORT;
1275 }
1276 free(annotation);
1277
1278 (yyval.region_ptr) = node;
1279}
Sol Boucherb9740812015-03-18 10:13:48 -07001280#line 1281 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001281 break;
1282
1283 case 4:
Sol Boucherb9740812015-03-18 10:13:48 -07001284#line 103 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001285 {
1286 if (!(yyvsp[0].strval)) {
Sol Boucherb9740812015-03-18 10:13:48 -07001287 perror("E: While allocating section name");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001288 YYABORT;
1289 }
1290}
Sol Boucherb9740812015-03-18 10:13:48 -07001291#line 1292 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001292 break;
1293
1294 case 5:
Sol Boucherb9740812015-03-18 10:13:48 -07001295#line 109 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001296 { (yyval.strval) = NULL; }
Sol Boucherb9740812015-03-18 10:13:48 -07001297#line 1298 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001298 break;
1299
1300 case 7:
Sol Boucherb9740812015-03-18 10:13:48 -07001301#line 111 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001302 { (yyval.strval) = (yyvsp[-1].strval); }
Sol Boucherb9740812015-03-18 10:13:48 -07001303#line 1304 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001304 break;
1305
1306 case 8:
Sol Boucherb9740812015-03-18 10:13:48 -07001307#line 112 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001308 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
Sol Boucherb9740812015-03-18 10:13:48 -07001309#line 1310 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001310 break;
1311
1312 case 10:
Sol Boucherb9740812015-03-18 10:13:48 -07001313#line 114 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001314 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
Sol Boucherb9740812015-03-18 10:13:48 -07001315#line 1316 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001316 break;
1317
1318 case 11:
Sol Boucherb9740812015-03-18 10:13:48 -07001319#line 115 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001320 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
Sol Boucherb9740812015-03-18 10:13:48 -07001321#line 1322 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001322 break;
1323
1324 case 13:
Sol Boucherb9740812015-03-18 10:13:48 -07001325#line 117 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001326 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
Sol Boucherb9740812015-03-18 10:13:48 -07001327#line 1328 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001328 break;
1329
1330 case 14:
Sol Boucherb9740812015-03-18 10:13:48 -07001331#line 119 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001332 {
1333 (yyval.region_listhdr) = (struct descriptor_list)
1334 {.len = 0, .head = NULL, .tail = NULL};
1335}
Sol Boucherb9740812015-03-18 10:13:48 -07001336#line 1337 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001337 break;
1338
1339 case 16:
Sol Boucherb9740812015-03-18 10:13:48 -07001340#line 124 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001341 { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
Sol Boucherb9740812015-03-18 10:13:48 -07001342#line 1343 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001343 break;
1344
1345 case 17:
Sol Boucherb9740812015-03-18 10:13:48 -07001346#line 126 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001347 {
1348 struct descriptor_node *node = malloc(sizeof(*node));
1349 if (!node) {
Sol Boucherb9740812015-03-18 10:13:48 -07001350 perror("E: While allocating linked list node");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001351 YYABORT;
1352 }
1353 node->val = (yyvsp[0].region_ptr);
1354 node->next = NULL;
1355 (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
1356}
Sol Boucherb9740812015-03-18 10:13:48 -07001357#line 1358 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001358 break;
1359
1360 case 18:
Sol Boucherb9740812015-03-18 10:13:48 -07001361#line 137 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001362 {
1363 struct descriptor_node *node = malloc(sizeof(*node));
1364 if (!node) {
Sol Boucherb9740812015-03-18 10:13:48 -07001365 perror("E: While allocating linked list node");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001366 YYABORT;
1367 }
1368 node->val = (yyvsp[0].region_ptr);
1369 node->next = NULL;
1370
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};
1374}
Sol Boucherb9740812015-03-18 10:13:48 -07001375#line 1376 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001376 break;
1377
1378
Sol Boucherb9740812015-03-18 10:13:48 -07001379#line 1380 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001380 default: break;
1381 }
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);
1394
1395 YYPOPSTACK (yylen);
1396 yylen = 0;
1397 YY_STACK_PRINT (yyss, yyssp);
1398
1399 *++yyvsp = yyval;
1400
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. */
1404
1405 yyn = yyr1[yyn];
1406
1407 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1408 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1409 yystate = yytable[yystate];
1410 else
1411 yystate = yydefgoto[yyn - YYNTOKENS];
1412
1413 goto yynewstate;
1414
1415
1416/*--------------------------------------.
1417| yyerrlab -- here on detecting error. |
1418`--------------------------------------*/
1419yyerrlab:
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);
1423
1424 /* If not already recovering from an error, report this error. */
1425 if (!yyerrstatus)
1426 {
1427 ++yynerrs;
1428#if ! YYERROR_VERBOSE
1429 yyerror (YY_("syntax error"));
1430#else
1431# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1432 yyssp, yytoken)
1433 {
1434 char const *yymsgp = YY_("syntax error");
1435 int yysyntax_error_status;
1436 yysyntax_error_status = YYSYNTAX_ERROR;
1437 if (yysyntax_error_status == 0)
1438 yymsgp = yymsg;
1439 else if (yysyntax_error_status == 1)
1440 {
1441 if (yymsg != yymsgbuf)
1442 YYSTACK_FREE (yymsg);
1443 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1444 if (!yymsg)
1445 {
1446 yymsg = yymsgbuf;
1447 yymsg_alloc = sizeof yymsgbuf;
1448 yysyntax_error_status = 2;
1449 }
1450 else
1451 {
1452 yysyntax_error_status = YYSYNTAX_ERROR;
1453 yymsgp = yymsg;
1454 }
1455 }
1456 yyerror (yymsgp);
1457 if (yysyntax_error_status == 2)
1458 goto yyexhaustedlab;
1459 }
1460# undef YYSYNTAX_ERROR
1461#endif
1462 }
1463
1464
1465
1466 if (yyerrstatus == 3)
1467 {
1468 /* If just tried and failed to reuse lookahead token after an
1469 error, discard it. */
1470
1471 if (yychar <= YYEOF)
1472 {
1473 /* Return failure if at end of input. */
1474 if (yychar == YYEOF)
1475 YYABORT;
1476 }
1477 else
1478 {
1479 yydestruct ("Error: discarding",
1480 yytoken, &yylval);
1481 yychar = YYEMPTY;
1482 }
1483 }
1484
1485 /* Else will try to reuse lookahead token after shifting the error
1486 token. */
1487 goto yyerrlab1;
1488
1489
1490/*---------------------------------------------------.
1491| yyerrorlab -- error raised explicitly by YYERROR. |
1492`---------------------------------------------------*/
1493yyerrorlab:
1494
1495 /* Pacify compilers like GCC when the user code never invokes
1496 YYERROR and the label yyerrorlab therefore never appears in user
1497 code. */
1498 if (/*CONSTCOND*/ 0)
1499 goto yyerrorlab;
1500
1501 /* Do not reclaim the symbols of the rule whose action triggered
1502 this YYERROR. */
1503 YYPOPSTACK (yylen);
1504 yylen = 0;
1505 YY_STACK_PRINT (yyss, yyssp);
1506 yystate = *yyssp;
1507 goto yyerrlab1;
1508
1509
1510/*-------------------------------------------------------------.
1511| yyerrlab1 -- common code for both syntax error and YYERROR. |
1512`-------------------------------------------------------------*/
1513yyerrlab1:
1514 yyerrstatus = 3; /* Each real token shifted decrements this. */
1515
1516 for (;;)
1517 {
1518 yyn = yypact[yystate];
1519 if (!yypact_value_is_default (yyn))
1520 {
1521 yyn += YYTERROR;
1522 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1523 {
1524 yyn = yytable[yyn];
1525 if (0 < yyn)
1526 break;
1527 }
1528 }
1529
1530 /* Pop the current state because it cannot handle the error token. */
1531 if (yyssp == yyss)
1532 YYABORT;
1533
1534
1535 yydestruct ("Error: popping",
1536 yystos[yystate], yyvsp);
1537 YYPOPSTACK (1);
1538 yystate = *yyssp;
1539 YY_STACK_PRINT (yyss, yyssp);
1540 }
1541
1542 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1543 *++yyvsp = yylval;
1544 YY_IGNORE_MAYBE_UNINITIALIZED_END
1545
1546
1547 /* Shift the error token. */
1548 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1549
1550 yystate = yyn;
1551 goto yynewstate;
1552
1553
1554/*-------------------------------------.
1555| yyacceptlab -- YYACCEPT comes here. |
1556`-------------------------------------*/
1557yyacceptlab:
1558 yyresult = 0;
1559 goto yyreturn;
1560
1561/*-----------------------------------.
1562| yyabortlab -- YYABORT comes here. |
1563`-----------------------------------*/
1564yyabortlab:
1565 yyresult = 1;
1566 goto yyreturn;
1567
1568#if !defined yyoverflow || YYERROR_VERBOSE
1569/*-------------------------------------------------.
1570| yyexhaustedlab -- memory exhaustion comes here. |
1571`-------------------------------------------------*/
1572yyexhaustedlab:
1573 yyerror (YY_("memory exhausted"));
1574 yyresult = 2;
1575 /* Fall through. */
1576#endif
1577
1578yyreturn:
1579 if (yychar != YYEMPTY)
1580 {
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",
1585 yytoken, &yylval);
1586 }
1587 /* Do not reclaim the symbols of the rule whose action triggered
1588 this YYABORT or YYACCEPT. */
1589 YYPOPSTACK (yylen);
1590 YY_STACK_PRINT (yyss, yyssp);
1591 while (yyssp != yyss)
1592 {
1593 yydestruct ("Cleanup: popping",
1594 yystos[*yyssp], yyvsp);
1595 YYPOPSTACK (1);
1596 }
1597#ifndef yyoverflow
1598 if (yyss != yyssa)
1599 YYSTACK_FREE (yyss);
1600#endif
1601#if YYERROR_VERBOSE
1602 if (yymsg != yymsgbuf)
1603 YYSTACK_FREE (yymsg);
1604#endif
1605 return yyresult;
1606}
Sol Boucherb9740812015-03-18 10:13:48 -07001607#line 151 "fmd_parser.y" /* yacc.c:1906 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001608
1609
1610struct flashmap_descriptor *parse_descriptor(char *name,
1611 struct unsigned_option offset, struct unsigned_option size,
1612 struct descriptor_list children)
1613{
1614 struct flashmap_descriptor *region = malloc(sizeof(*region));
1615 if (!region) {
Sol Boucherb9740812015-03-18 10:13:48 -07001616 perror("E: While allocating descriptor section");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001617 return NULL;
1618 }
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) {
Sol Boucherb9740812015-03-18 10:13:48 -07001628 perror("E: While allocating node children array");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001629 return NULL;
1630 }
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;
1634
1635 struct descriptor_node *next_node = cur_node->next;
1636 free(cur_node);
1637 cur_node = next_node;
1638 }
1639 } else {
1640 region->list = NULL;
1641 }
1642 return region;
1643}
1644
1645void yyerror(const char *s)
1646{
1647 fprintf(stderr, "%s\n", s);
1648}