blob: 2597fc663748f8559956e4309b0dde579b69c188 [file] [log] [blame]
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001/* A Bison parser, made by GNU Bison 3.0.4. */
Sol Boucher69b88bf2015-02-26 11:47:19 -08002
3/* Bison implementation for Yacc-like parsers in C
4
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08005 Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
Sol Boucher69b88bf2015-02-26 11:47:19 -08006
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. */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +080047#define YYBISON_VERSION "3.0.4"
Sol Boucher69b88bf2015-02-26 11:47:19 -080048
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. */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +080065#line 16 "fmd_parser.y" /* yacc.c:339 */
Sol Boucher69b88bf2015-02-26 11:47:19 -080066
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. */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800104#line 34 "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
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800124struct flashmap_descriptor *parse_descriptor(
125 char *name, union flashmap_flags flags, struct unsigned_option offset,
126 struct unsigned_option size, struct descriptor_list children);
Sol Boucher69b88bf2015-02-26 11:47:19 -0800127void 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,
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800138 STRING = 260,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800139 FLAG_CBFS = 261,
140 FLAG_PRESERVE = 262
Sol Boucher69b88bf2015-02-26 11:47:19 -0800141 };
142#endif
143/* Tokens. */
144#define INTEGER 258
145#define OCTAL 259
146#define STRING 260
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800147#define FLAG_CBFS 261
Hung-Te Lin49a44502019-03-04 15:41:09 +0800148#define FLAG_PRESERVE 262
Sol Boucher69b88bf2015-02-26 11:47:19 -0800149
150/* Value type. */
151#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800152
Sol Boucher69b88bf2015-02-26 11:47:19 -0800153union YYSTYPE
154{
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800155#line 25 "fmd_parser.y" /* yacc.c:355 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800156
157 unsigned intval;
158 char *strval;
159 struct unsigned_option maybe_intval;
160 struct flashmap_descriptor *region_ptr;
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800161 union flashmap_flags flags;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800162 struct descriptor_list region_listhdr;
163
Hung-Te Lin49a44502019-03-04 15:41:09 +0800164#line 165 "y.tab.c" /* yacc.c:355 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800165};
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800166
167typedef union YYSTYPE YYSTYPE;
Sol Boucher69b88bf2015-02-26 11:47:19 -0800168# define YYSTYPE_IS_TRIVIAL 1
169# define YYSTYPE_IS_DECLARED 1
170#endif
171
172
173extern YYSTYPE yylval;
174
175int yyparse (void);
176
177#endif /* !YY_YY_Y_TAB_H_INCLUDED */
178
179/* Copy the second part of user declarations. */
180
Hung-Te Lin49a44502019-03-04 15:41:09 +0800181#line 182 "y.tab.c" /* yacc.c:358 */
Sol Boucher69b88bf2015-02-26 11:47:19 -0800182
183#ifdef short
184# undef short
185#endif
186
187#ifdef YYTYPE_UINT8
188typedef YYTYPE_UINT8 yytype_uint8;
189#else
190typedef unsigned char yytype_uint8;
191#endif
192
193#ifdef YYTYPE_INT8
194typedef YYTYPE_INT8 yytype_int8;
195#else
196typedef signed char yytype_int8;
197#endif
198
199#ifdef YYTYPE_UINT16
200typedef YYTYPE_UINT16 yytype_uint16;
201#else
202typedef unsigned short int yytype_uint16;
203#endif
204
205#ifdef YYTYPE_INT16
206typedef YYTYPE_INT16 yytype_int16;
207#else
208typedef short int yytype_int16;
209#endif
210
211#ifndef YYSIZE_T
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
219# else
220# define YYSIZE_T unsigned int
221# endif
222#endif
223
224#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
225
226#ifndef YY_
227# if defined YYENABLE_NLS && YYENABLE_NLS
228# if ENABLE_NLS
229# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
230# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
231# endif
232# endif
233# ifndef YY_
234# define YY_(Msgid) Msgid
235# endif
236#endif
237
238#ifndef YY_ATTRIBUTE
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)
243# else
244# define YY_ATTRIBUTE(Spec) /* empty */
245# endif
246#endif
247
248#ifndef YY_ATTRIBUTE_PURE
249# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
250#endif
251
252#ifndef YY_ATTRIBUTE_UNUSED
253# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
254#endif
255
256#if !defined _Noreturn \
257 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
258# if defined _MSC_VER && 1200 <= _MSC_VER
259# define _Noreturn __declspec (noreturn)
260# else
261# define _Noreturn YY_ATTRIBUTE ((__noreturn__))
262# endif
263#endif
264
265/* Suppress unused-variable warnings by "using" E. */
266#if ! defined lint || defined __GNUC__
267# define YYUSE(E) ((void) (E))
268#else
269# define YYUSE(E) /* empty */
270#endif
271
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")
280#else
281# define YY_INITIAL_VALUE(Value) Value
282#endif
283#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
284# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
285# define YY_IGNORE_MAYBE_UNINITIALIZED_END
286#endif
287#ifndef YY_INITIAL_VALUE
288# define YY_INITIAL_VALUE(Value) /* Nothing. */
289#endif
290
291
292#if ! defined yyoverflow || YYERROR_VERBOSE
293
294/* The parser invokes alloca or malloc; define the necessary symbols. */
295
296# ifdef YYSTACK_USE_ALLOCA
297# if YYSTACK_USE_ALLOCA
298# ifdef __GNUC__
299# define YYSTACK_ALLOC __builtin_alloca
300# elif defined __BUILTIN_VA_ARG_INCR
301# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
302# elif defined _AIX
303# define YYSTACK_ALLOC __alloca
304# elif defined _MSC_VER
305# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
306# define alloca _alloca
307# else
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
314# endif
315# endif
316# endif
317# endif
318# endif
319
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 */
329# endif
330# else
331# define YYSTACK_ALLOC YYMALLOC
332# define YYSTACK_FREE YYFREE
333# ifndef YYSTACK_ALLOC_MAXIMUM
334# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
335# endif
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
342# endif
343# endif
344# ifndef YYMALLOC
345# define YYMALLOC malloc
346# if ! defined malloc && ! defined EXIT_SUCCESS
347void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
348# endif
349# endif
350# ifndef YYFREE
351# define YYFREE free
352# if ! defined free && ! defined EXIT_SUCCESS
353void free (void *); /* INFRINGES ON USER NAME SPACE */
354# endif
355# endif
356# endif
357#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
358
359
360#if (! defined yyoverflow \
361 && (! defined __cplusplus \
362 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
363
364/* A type that is properly aligned for any stack member. */
365union yyalloc
366{
367 yytype_int16 yyss_alloc;
368 YYSTYPE yyvs_alloc;
369};
370
371/* The size of the maximum gap between one aligned stack and the next. */
372# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
373
374/* The size of an array large to enough to hold all stacks, each with
375 N elements. */
376# define YYSTACK_BYTES(N) \
377 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
378 + YYSTACK_GAP_MAXIMUM)
379
380# define YYCOPY_NEEDED 1
381
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
386 stack. */
387# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
388 do \
389 { \
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); \
395 } \
396 while (0)
397
398#endif
399
400#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
401/* Copy COUNT objects from SRC to DST. The source and destination do
402 not overlap. */
403# ifndef YYCOPY
404# if defined __GNUC__ && 1 < __GNUC__
405# define YYCOPY(Dst, Src, Count) \
406 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
407# else
408# define YYCOPY(Dst, Src, Count) \
409 do \
410 { \
411 YYSIZE_T yyi; \
412 for (yyi = 0; yyi < (Count); yyi++) \
413 (Dst)[yyi] = (Src)[yyi]; \
414 } \
415 while (0)
416# endif
417# endif
418#endif /* !YYCOPY_NEEDED */
419
420/* YYFINAL -- State number of the termination state. */
421#define YYFINAL 4
422/* YYLAST -- Last index in YYTABLE. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800423#define YYLAST 23
Sol Boucher69b88bf2015-02-26 11:47:19 -0800424
425/* YYNTOKENS -- Number of terminals. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800426#define YYNTOKENS 13
Sol Boucher69b88bf2015-02-26 11:47:19 -0800427/* YYNNTS -- Number of nonterminals. */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800428#define YYNNTS 14
Sol Boucher69b88bf2015-02-26 11:47:19 -0800429/* YYNRULES -- Number of rules. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800430#define YYNRULES 21
Sol Boucher69b88bf2015-02-26 11:47:19 -0800431/* YYNSTATES -- Number of states. */
Hung-Te Lin49a44502019-03-04 15:41:09 +0800432#define YYNSTATES 31
Sol Boucher69b88bf2015-02-26 11:47:19 -0800433
434/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
435 by yylex, with out-of-bounds checking. */
436#define YYUNDEFTOK 2
Hung-Te Lin49a44502019-03-04 15:41:09 +0800437#define YYMAXUTOK 262
Sol Boucher69b88bf2015-02-26 11:47:19 -0800438
439#define YYTRANSLATE(YYX) \
440 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
441
442/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
443 as returned by yylex, without out-of-bounds checking. */
444static const yytype_uint8 yytranslate[] =
445{
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,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800450 8, 9, 2, 2, 2, 2, 2, 2, 2, 2,
Sol Boucher69b88bf2015-02-26 11:47:19 -0800451 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800452 2, 2, 2, 2, 10, 2, 2, 2, 2, 2,
Sol Boucher69b88bf2015-02-26 11:47:19 -0800453 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,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800458 2, 2, 2, 11, 2, 12, 2, 2, 2, 2,
Sol Boucher69b88bf2015-02-26 11:47:19 -0800459 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,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800472 5, 6, 7
Sol Boucher69b88bf2015-02-26 11:47:19 -0800473};
474
475#if YYDEBUG
476 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
477static const yytype_uint8 yyrline[] =
478{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800479 0, 80, 80, 86, 100, 107, 108, 109, 109, 110,
480 111, 112, 113, 114, 115, 116, 117, 119, 123, 124,
481 125, 136
Sol Boucher69b88bf2015-02-26 11:47:19 -0800482};
483#endif
484
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. */
488static const char *const yytname[] =
489{
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800490 "$end", "error", "$undefined", "INTEGER", "OCTAL", "STRING",
Hung-Te Lin49a44502019-03-04 15:41:09 +0800491 "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
Sol Boucher69b88bf2015-02-26 11:47:19 -0800496};
497#endif
498
499# ifdef YYPRINT
500/* YYTOKNUM[NUM] -- (External) token number corresponding to the
501 (internal) symbol number NUM (which must be that of a token). */
502static const yytype_uint16 yytoknum[] =
503{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800504 0, 256, 257, 258, 259, 260, 261, 262, 40, 41,
505 64, 123, 125
Sol Boucher69b88bf2015-02-26 11:47:19 -0800506};
507# endif
508
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800509#define YYPACT_NINF -12
Sol Boucher69b88bf2015-02-26 11:47:19 -0800510
511#define yypact_value_is_default(Yystate) \
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800512 (!!((Yystate) == (-12)))
Sol Boucher69b88bf2015-02-26 11:47:19 -0800513
514#define YYTABLE_NINF -1
515
516#define yytable_value_is_error(Yytable_value) \
517 0
518
519 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
520 STATE-NUM. */
521static const yytype_int8 yypact[] =
522{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800523 -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,
526 -12
Sol Boucher69b88bf2015-02-26 11:47:19 -0800527};
528
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. */
532static const yytype_uint8 yydefact[] =
533{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800534 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,
537 18
Sol Boucher69b88bf2015-02-26 11:47:19 -0800538};
539
540 /* YYPGOTO[NTERM-NUM]. */
541static const yytype_int8 yypgoto[] =
542{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800543 -12, -12, -6, 10, -12, -10, -12, 6, -12, -12,
544 -9, -12, -11, -12
Sol Boucher69b88bf2015-02-26 11:47:19 -0800545};
546
547 /* YYDEFGOTO[NTERM-NUM]. */
548static const yytype_int8 yydefgoto[] =
549{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800550 -1, 2, 13, 14, 17, 22, 23, 6, 7, 27,
551 10, 29, 12, 15
Sol Boucher69b88bf2015-02-26 11:47:19 -0800552};
553
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. */
557static const yytype_uint8 yytable[] =
558{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800559 1, 4, 20, 21, 1, 8, 9, 18, 5, 19,
560 3, 11, 16, 26, 25, 28, 30, 0, 0, 0,
561 0, 0, 0, 24
Sol Boucher69b88bf2015-02-26 11:47:19 -0800562};
563
564static const yytype_int8 yycheck[] =
565{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800566 5, 0, 6, 7, 5, 3, 3, 12, 10, 15,
567 0, 11, 8, 23, 9, 24, 27, -1, -1, -1,
568 -1, -1, -1, 17
Sol Boucher69b88bf2015-02-26 11:47:19 -0800569};
570
571 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
572 symbol of state STATE-NUM. */
573static const yytype_uint8 yystos[] =
574{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800575 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,
578 25
Sol Boucher69b88bf2015-02-26 11:47:19 -0800579};
580
581 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
582static const yytype_uint8 yyr1[] =
583{
Hung-Te Lin49a44502019-03-04 15:41:09 +0800584 0, 13, 14, 15, 16, 17, 17, 18, 18, 19,
585 19, 20, 20, 21, 22, 22, 23, 24, 24, 25,
586 26, 26
Sol Boucher69b88bf2015-02-26 11:47:19 -0800587};
588
589 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
590static const yytype_uint8 yyr2[] =
591{
Hung-Te Lin9497fcb2019-03-04 14:28:37 +0800592 0, 2, 4, 5, 1, 0, 3, 1, 2, 1,
Hung-Te Lin49a44502019-03-04 15:41:09 +0800593 1, 0, 1, 2, 0, 1, 1, 0, 1, 3,
594 1, 2
Sol Boucher69b88bf2015-02-26 11:47:19 -0800595};
596
597
598#define yyerrok (yyerrstatus = 0)
599#define yyclearin (yychar = YYEMPTY)
600#define YYEMPTY (-2)
601#define YYEOF 0
602
603#define YYACCEPT goto yyacceptlab
604#define YYABORT goto yyabortlab
605#define YYERROR goto yyerrorlab
606
607
608#define YYRECOVERING() (!!yyerrstatus)
609
610#define YYBACKUP(Token, Value) \
611do \
612 if (yychar == YYEMPTY) \
613 { \
614 yychar = (Token); \
615 yylval = (Value); \
616 YYPOPSTACK (yylen); \
617 yystate = *yyssp; \
618 goto yybackup; \
619 } \
620 else \
621 { \
622 yyerror (YY_("syntax error: cannot back up")); \
623 YYERROR; \
624 } \
625while (0)
626
627/* Error token number */
628#define YYTERROR 1
629#define YYERRCODE 256
630
631
632
633/* Enable debugging if requested. */
634#if YYDEBUG
635
636# ifndef YYFPRINTF
637# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
638# define YYFPRINTF fprintf
639# endif
640
641# define YYDPRINTF(Args) \
642do { \
643 if (yydebug) \
644 YYFPRINTF Args; \
645} while (0)
646
647/* This macro is provided for backward compatibility. */
648#ifndef YY_LOCATION_PRINT
649# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
650#endif
651
652
653# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
654do { \
655 if (yydebug) \
656 { \
657 YYFPRINTF (stderr, "%s ", Title); \
658 yy_symbol_print (stderr, \
659 Type, Value); \
660 YYFPRINTF (stderr, "\n"); \
661 } \
662} while (0)
663
664
665/*----------------------------------------.
666| Print this symbol's value on YYOUTPUT. |
667`----------------------------------------*/
668
669static void
670yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
671{
672 FILE *yyo = yyoutput;
673 YYUSE (yyo);
674 if (!yyvaluep)
675 return;
676# ifdef YYPRINT
677 if (yytype < YYNTOKENS)
678 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
679# endif
680 YYUSE (yytype);
681}
682
683
684/*--------------------------------.
685| Print this symbol on YYOUTPUT. |
686`--------------------------------*/
687
688static void
689yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
690{
691 YYFPRINTF (yyoutput, "%s %s (",
692 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
693
694 yy_symbol_value_print (yyoutput, yytype, yyvaluep);
695 YYFPRINTF (yyoutput, ")");
696}
697
698/*------------------------------------------------------------------.
699| yy_stack_print -- Print the state stack from its BOTTOM up to its |
700| TOP (included). |
701`------------------------------------------------------------------*/
702
703static void
704yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
705{
706 YYFPRINTF (stderr, "Stack now");
707 for (; yybottom <= yytop; yybottom++)
708 {
709 int yybot = *yybottom;
710 YYFPRINTF (stderr, " %d", yybot);
711 }
712 YYFPRINTF (stderr, "\n");
713}
714
715# define YY_STACK_PRINT(Bottom, Top) \
716do { \
717 if (yydebug) \
718 yy_stack_print ((Bottom), (Top)); \
719} while (0)
720
721
722/*------------------------------------------------.
723| Report that the YYRULE is going to be reduced. |
724`------------------------------------------------*/
725
726static void
727yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule)
728{
729 unsigned long int yylno = yyrline[yyrule];
730 int yynrhs = yyr2[yyrule];
731 int yyi;
732 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
733 yyrule - 1, yylno);
734 /* The symbols being reduced. */
735 for (yyi = 0; yyi < yynrhs; yyi++)
736 {
737 YYFPRINTF (stderr, " $%d = ", yyi + 1);
738 yy_symbol_print (stderr,
739 yystos[yyssp[yyi + 1 - yynrhs]],
740 &(yyvsp[(yyi + 1) - (yynrhs)])
741 );
742 YYFPRINTF (stderr, "\n");
743 }
744}
745
746# define YY_REDUCE_PRINT(Rule) \
747do { \
748 if (yydebug) \
749 yy_reduce_print (yyssp, yyvsp, Rule); \
750} while (0)
751
752/* Nonzero means print parse trace. It is left uninitialized so that
753 multiple parsers can coexist. */
754int yydebug;
755#else /* !YYDEBUG */
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 */
761
762
763/* YYINITDEPTH -- initial size of the parser's stacks. */
764#ifndef YYINITDEPTH
765# define YYINITDEPTH 200
766#endif
767
768/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
769 if the built-in stack extension method is used).
770
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. */
774
775#ifndef YYMAXDEPTH
776# define YYMAXDEPTH 10000
777#endif
778
779
780#if YYERROR_VERBOSE
781
782# ifndef yystrlen
783# if defined __GLIBC__ && defined _STRING_H
784# define yystrlen strlen
785# else
786/* Return the length of YYSTR. */
787static YYSIZE_T
788yystrlen (const char *yystr)
789{
790 YYSIZE_T yylen;
791 for (yylen = 0; yystr[yylen]; yylen++)
792 continue;
793 return yylen;
794}
795# endif
796# endif
797
798# ifndef yystpcpy
799# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
800# define yystpcpy stpcpy
801# else
802/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
803 YYDEST. */
804static char *
805yystpcpy (char *yydest, const char *yysrc)
806{
807 char *yyd = yydest;
808 const char *yys = yysrc;
809
810 while ((*yyd++ = *yys++) != '\0')
811 continue;
812
813 return yyd - 1;
814}
815# endif
816# endif
817
818# ifndef yytnamerr
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
825 would have been. */
826static YYSIZE_T
827yytnamerr (char *yyres, const char *yystr)
828{
829 if (*yystr == '"')
830 {
831 YYSIZE_T yyn = 0;
832 char const *yyp = yystr;
833
834 for (;;)
835 switch (*++yyp)
836 {
837 case '\'':
838 case ',':
839 goto do_not_strip_quotes;
840
841 case '\\':
842 if (*++yyp != '\\')
843 goto do_not_strip_quotes;
844 /* Fall through. */
845 default:
846 if (yyres)
847 yyres[yyn] = *yyp;
848 yyn++;
849 break;
850
851 case '"':
852 if (yyres)
853 yyres[yyn] = '\0';
854 return yyn;
855 }
856 do_not_strip_quotes: ;
857 }
858
859 if (! yyres)
860 return yystrlen (yystr);
861
862 return yystpcpy (yyres, yystr) - yyres;
863}
864# endif
865
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
868 YYSSP.
869
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. */
874static int
875yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
876 yytype_int16 *yyssp, int yytoken)
877{
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
886 "expected"). */
887 int yycount = 0;
888
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.
911 */
912 if (yytoken != YYEMPTY)
913 {
914 int yyn = yypact[*yyssp];
915 yyarg[yycount++] = yytname[yytoken];
916 if (!yypact_value_is_default (yyn))
917 {
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;
925 int yyx;
926
927 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
928 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
929 && !yytable_value_is_error (yytable[yyx + yyn]))
930 {
931 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
932 {
933 yycount = 1;
934 yysize = yysize0;
935 break;
936 }
937 yyarg[yycount++] = yytname[yyx];
938 {
939 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
940 if (! (yysize <= yysize1
941 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
942 return 2;
943 yysize = yysize1;
944 }
945 }
946 }
947 }
948
949 switch (yycount)
950 {
951# define YYCASE_(N, S) \
952 case N: \
953 yyformat = S; \
954 break
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"));
961# undef YYCASE_
962 }
963
964 {
965 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
966 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
967 return 2;
968 yysize = yysize1;
969 }
970
971 if (*yymsg_alloc < yysize)
972 {
973 *yymsg_alloc = 2 * yysize;
974 if (! (yysize <= *yymsg_alloc
975 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
976 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
977 return 1;
978 }
979
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. */
983 {
984 char *yyp = *yymsg;
985 int yyi = 0;
986 while ((*yyp = *yyformat) != '\0')
987 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
988 {
989 yyp += yytnamerr (yyp, yyarg[yyi++]);
990 yyformat += 2;
991 }
992 else
993 {
994 yyp++;
995 yyformat++;
996 }
997 }
998 return 0;
999}
1000#endif /* YYERROR_VERBOSE */
1001
1002/*-----------------------------------------------.
1003| Release the memory associated to this symbol. |
1004`-----------------------------------------------*/
1005
1006static void
1007yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1008{
1009 YYUSE (yyvaluep);
1010 if (!yymsg)
1011 yymsg = "Deleting";
1012 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1013
1014 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1015 YYUSE (yytype);
1016 YY_IGNORE_MAYBE_UNINITIALIZED_END
1017}
1018
1019
1020
1021
1022/* The lookahead symbol. */
1023int yychar;
1024
1025/* The semantic value of the lookahead symbol. */
1026YYSTYPE yylval;
1027/* Number of syntax errors so far. */
1028int yynerrs;
1029
1030
1031/*----------.
1032| yyparse. |
1033`----------*/
1034
1035int
1036yyparse (void)
1037{
1038 int yystate;
1039 /* Number of tokens to shift before error messages enabled. */
1040 int yyerrstatus;
1041
1042 /* The stacks and their tools:
1043 'yyss': related to states.
1044 'yyvs': related to semantic values.
1045
1046 Refer to the stacks through separate pointers, to allow yyoverflow
1047 to reallocate them elsewhere. */
1048
1049 /* The state stack. */
1050 yytype_int16 yyssa[YYINITDEPTH];
1051 yytype_int16 *yyss;
1052 yytype_int16 *yyssp;
1053
1054 /* The semantic value stack. */
1055 YYSTYPE yyvsa[YYINITDEPTH];
1056 YYSTYPE *yyvs;
1057 YYSTYPE *yyvsp;
1058
1059 YYSIZE_T yystacksize;
1060
1061 int yyn;
1062 int yyresult;
1063 /* Lookahead token as an internal (translated) token number. */
1064 int yytoken = 0;
1065 /* The variables used to return semantic value and location from the
1066 action routines. */
1067 YYSTYPE yyval;
1068
1069#if YYERROR_VERBOSE
1070 /* Buffer for error messages, and its allocated size. */
1071 char yymsgbuf[128];
1072 char *yymsg = yymsgbuf;
1073 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1074#endif
1075
1076#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1077
1078 /* The number of symbols on the RHS of the reduced rule.
1079 Keep to zero when no symbol should be popped. */
1080 int yylen = 0;
1081
1082 yyssp = yyss = yyssa;
1083 yyvsp = yyvs = yyvsa;
1084 yystacksize = YYINITDEPTH;
1085
1086 YYDPRINTF ((stderr, "Starting parse\n"));
1087
1088 yystate = 0;
1089 yyerrstatus = 0;
1090 yynerrs = 0;
1091 yychar = YYEMPTY; /* Cause a token to be read. */
1092 goto yysetstate;
1093
1094/*------------------------------------------------------------.
1095| yynewstate -- Push a new state, which is found in yystate. |
1096`------------------------------------------------------------*/
1097 yynewstate:
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. */
1100 yyssp++;
1101
1102 yysetstate:
1103 *yyssp = yystate;
1104
1105 if (yyss + yystacksize - 1 <= yyssp)
1106 {
1107 /* Get the current used size of the three stacks, in elements. */
1108 YYSIZE_T yysize = yyssp - yyss + 1;
1109
1110#ifdef yyoverflow
1111 {
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
1114 memory. */
1115 YYSTYPE *yyvs1 = yyvs;
1116 yytype_int16 *yyss1 = yyss;
1117
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),
1125 &yystacksize);
1126
1127 yyss = yyss1;
1128 yyvs = yyvs1;
1129 }
1130#else /* no yyoverflow */
1131# ifndef YYSTACK_RELOCATE
1132 goto yyexhaustedlab;
1133# else
1134 /* Extend the stack our own way. */
1135 if (YYMAXDEPTH <= yystacksize)
1136 goto yyexhaustedlab;
1137 yystacksize *= 2;
1138 if (YYMAXDEPTH < yystacksize)
1139 yystacksize = YYMAXDEPTH;
1140
1141 {
1142 yytype_int16 *yyss1 = yyss;
1143 union yyalloc *yyptr =
1144 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1145 if (! yyptr)
1146 goto yyexhaustedlab;
1147 YYSTACK_RELOCATE (yyss_alloc, yyss);
1148 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1149# undef YYSTACK_RELOCATE
1150 if (yyss1 != yyssa)
1151 YYSTACK_FREE (yyss1);
1152 }
1153# endif
1154#endif /* no yyoverflow */
1155
1156 yyssp = yyss + yysize - 1;
1157 yyvsp = yyvs + yysize - 1;
1158
1159 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1160 (unsigned long int) yystacksize));
1161
1162 if (yyss + yystacksize - 1 <= yyssp)
1163 YYABORT;
1164 }
1165
1166 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1167
1168 if (yystate == YYFINAL)
1169 YYACCEPT;
1170
1171 goto yybackup;
1172
1173/*-----------.
1174| yybackup. |
1175`-----------*/
1176yybackup:
1177
1178 /* Do appropriate processing given the current state. Read a
1179 lookahead token if we need one and don't already have one. */
1180
1181 /* First try to decide what to do without reference to lookahead token. */
1182 yyn = yypact[yystate];
1183 if (yypact_value_is_default (yyn))
1184 goto yydefault;
1185
1186 /* Not known => get a lookahead token if don't already have one. */
1187
1188 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1189 if (yychar == YYEMPTY)
1190 {
1191 YYDPRINTF ((stderr, "Reading a token: "));
1192 yychar = yylex ();
1193 }
1194
1195 if (yychar <= YYEOF)
1196 {
1197 yychar = yytoken = YYEOF;
1198 YYDPRINTF ((stderr, "Now at end of input.\n"));
1199 }
1200 else
1201 {
1202 yytoken = YYTRANSLATE (yychar);
1203 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1204 }
1205
1206 /* If the proper action on seeing token YYTOKEN is to reduce or to
1207 detect an error, take that action. */
1208 yyn += yytoken;
1209 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1210 goto yydefault;
1211 yyn = yytable[yyn];
1212 if (yyn <= 0)
1213 {
1214 if (yytable_value_is_error (yyn))
1215 goto yyerrlab;
1216 yyn = -yyn;
1217 goto yyreduce;
1218 }
1219
1220 /* Count tokens shifted since error; after three, turn off error
1221 status. */
1222 if (yyerrstatus)
1223 yyerrstatus--;
1224
1225 /* Shift the lookahead token. */
1226 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1227
1228 /* Discard the shifted token. */
1229 yychar = YYEMPTY;
1230
1231 yystate = yyn;
1232 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1233 *++yyvsp = yylval;
1234 YY_IGNORE_MAYBE_UNINITIALIZED_END
1235
1236 goto yynewstate;
1237
1238
1239/*-----------------------------------------------------------.
1240| yydefault -- do the default action for the current state. |
1241`-----------------------------------------------------------*/
1242yydefault:
1243 yyn = yydefact[yystate];
1244 if (yyn == 0)
1245 goto yyerrlab;
1246 goto yyreduce;
1247
1248
1249/*-----------------------------.
1250| yyreduce -- Do a reduction. |
1251`-----------------------------*/
1252yyreduce:
1253 /* yyn is the number of a rule to reduce with. */
1254 yylen = yyr2[yyn];
1255
1256 /* If YYLEN is nonzero, implement the default value of the action:
1257 '$$ = $1'.
1258
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];
1265
1266
1267 YY_REDUCE_PRINT (yyn);
1268 switch (yyn)
1269 {
1270 case 2:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001271#line 81 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001272 {
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001273 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))))
Sol Boucher69b88bf2015-02-26 11:47:19 -08001275 YYABORT;
1276}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001277#line 1278 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001278 break;
1279
1280 case 3:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001281#line 88 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001282 {
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001283 struct flashmap_descriptor *node = parse_descriptor((yyvsp[-4].strval), (yyvsp[-3].flags), (yyvsp[-2].maybe_intval), (yyvsp[-1].maybe_intval), (yyvsp[0].region_listhdr));
Sol Boucher69b88bf2015-02-26 11:47:19 -08001284 if (!node)
1285 YYABORT;
1286
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001287 if (node->flags.f.cbfs && !fmd_process_flag_cbfs(node)) {
1288 ERROR("Section '%s' cannot have flag 'CBFS''\n", node->name);
Sol Boucher69b88bf2015-02-26 11:47:19 -08001289 YYABORT;
1290 }
Sol Boucher69b88bf2015-02-26 11:47:19 -08001291
1292 (yyval.region_ptr) = node;
1293}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001294#line 1295 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001295 break;
1296
1297 case 4:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001298#line 101 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001299 {
1300 if (!(yyvsp[0].strval)) {
Sol Boucherb9740812015-03-18 10:13:48 -07001301 perror("E: While allocating section name");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001302 YYABORT;
1303 }
1304}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001305#line 1306 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001306 break;
1307
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001308 case 5:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001309#line 107 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001310 { (yyval.flags) = (union flashmap_flags){ .v=0 }; }
Hung-Te Lin49a44502019-03-04 15:41:09 +08001311#line 1312 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001312 break;
1313
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001314 case 6:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001315#line 108 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001316 { (yyval.flags) = (yyvsp[-1].flags); }
Hung-Te Lin49a44502019-03-04 15:41:09 +08001317#line 1318 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001318 break;
1319
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001320 case 8:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001321#line 109 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001322 { (yyval.flags).v = (yyvsp[-1].flags).v | (yyvsp[0].flags).v; }
Hung-Te Lin49a44502019-03-04 15:41:09 +08001323#line 1324 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001324 break;
1325
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001326 case 9:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001327#line 110 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001328 { (yyval.flags).v = 0; (yyval.flags).f.cbfs = 1; }
Hung-Te Lin49a44502019-03-04 15:41:09 +08001329#line 1330 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001330 break;
1331
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001332 case 10:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001333#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 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001336 break;
1337
Hung-Te Lin49a44502019-03-04 15:41:09 +08001338 case 11:
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001339#line 112 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin49a44502019-03-04 15:41:09 +08001340 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1341#line 1342 "y.tab.c" /* yacc.c:1646 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001342 break;
1343
1344 case 13:
Hung-Te Lin49a44502019-03-04 15:41:09 +08001345#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 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001348 break;
1349
Hung-Te Lin49a44502019-03-04 15:41:09 +08001350 case 14:
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001351#line 115 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin49a44502019-03-04 15:41:09 +08001352 { (yyval.maybe_intval) = (struct unsigned_option){false, 0}; }
1353#line 1354 "y.tab.c" /* yacc.c:1646 */
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001354 break;
1355
1356 case 16:
1357#line 117 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin49a44502019-03-04 15:41:09 +08001358 { (yyval.maybe_intval) = (struct unsigned_option){true, (yyvsp[0].intval)}; }
1359#line 1360 "y.tab.c" /* yacc.c:1646 */
1360 break;
1361
1362 case 17:
1363#line 119 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001364 {
1365 (yyval.region_listhdr) = (struct descriptor_list)
1366 {.len = 0, .head = NULL, .tail = NULL};
1367}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001368#line 1369 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001369 break;
1370
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001371 case 19:
1372#line 124 "fmd_parser.y" /* yacc.c:1646 */
Hung-Te Lin49a44502019-03-04 15:41:09 +08001373 { (yyval.region_listhdr) = (yyvsp[-1].region_listhdr); }
1374#line 1375 "y.tab.c" /* yacc.c:1646 */
1375 break;
1376
1377 case 20:
1378#line 126 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001379 {
1380 struct descriptor_node *node = malloc(sizeof(*node));
1381 if (!node) {
Sol Boucherb9740812015-03-18 10:13:48 -07001382 perror("E: While allocating linked list node");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001383 YYABORT;
1384 }
1385 node->val = (yyvsp[0].region_ptr);
1386 node->next = NULL;
1387 (yyval.region_listhdr) = (struct descriptor_list){.len = 1, .head = node, .tail = node};
1388}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001389#line 1390 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001390 break;
1391
Hung-Te Lin49a44502019-03-04 15:41:09 +08001392 case 21:
1393#line 137 "fmd_parser.y" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001394 {
1395 struct descriptor_node *node = malloc(sizeof(*node));
1396 if (!node) {
Sol Boucherb9740812015-03-18 10:13:48 -07001397 perror("E: While allocating linked list node");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001398 YYABORT;
1399 }
1400 node->val = (yyvsp[0].region_ptr);
1401 node->next = NULL;
1402
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};
1406}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001407#line 1408 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001408 break;
1409
1410
Hung-Te Lin49a44502019-03-04 15:41:09 +08001411#line 1412 "y.tab.c" /* yacc.c:1646 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001412 default: break;
1413 }
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);
1426
1427 YYPOPSTACK (yylen);
1428 yylen = 0;
1429 YY_STACK_PRINT (yyss, yyssp);
1430
1431 *++yyvsp = yyval;
1432
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. */
1436
1437 yyn = yyr1[yyn];
1438
1439 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
1440 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1441 yystate = yytable[yystate];
1442 else
1443 yystate = yydefgoto[yyn - YYNTOKENS];
1444
1445 goto yynewstate;
1446
1447
1448/*--------------------------------------.
1449| yyerrlab -- here on detecting error. |
1450`--------------------------------------*/
1451yyerrlab:
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);
1455
1456 /* If not already recovering from an error, report this error. */
1457 if (!yyerrstatus)
1458 {
1459 ++yynerrs;
1460#if ! YYERROR_VERBOSE
1461 yyerror (YY_("syntax error"));
1462#else
1463# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
1464 yyssp, yytoken)
1465 {
1466 char const *yymsgp = YY_("syntax error");
1467 int yysyntax_error_status;
1468 yysyntax_error_status = YYSYNTAX_ERROR;
1469 if (yysyntax_error_status == 0)
1470 yymsgp = yymsg;
1471 else if (yysyntax_error_status == 1)
1472 {
1473 if (yymsg != yymsgbuf)
1474 YYSTACK_FREE (yymsg);
1475 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
1476 if (!yymsg)
1477 {
1478 yymsg = yymsgbuf;
1479 yymsg_alloc = sizeof yymsgbuf;
1480 yysyntax_error_status = 2;
1481 }
1482 else
1483 {
1484 yysyntax_error_status = YYSYNTAX_ERROR;
1485 yymsgp = yymsg;
1486 }
1487 }
1488 yyerror (yymsgp);
1489 if (yysyntax_error_status == 2)
1490 goto yyexhaustedlab;
1491 }
1492# undef YYSYNTAX_ERROR
1493#endif
1494 }
1495
1496
1497
1498 if (yyerrstatus == 3)
1499 {
1500 /* If just tried and failed to reuse lookahead token after an
1501 error, discard it. */
1502
1503 if (yychar <= YYEOF)
1504 {
1505 /* Return failure if at end of input. */
1506 if (yychar == YYEOF)
1507 YYABORT;
1508 }
1509 else
1510 {
1511 yydestruct ("Error: discarding",
1512 yytoken, &yylval);
1513 yychar = YYEMPTY;
1514 }
1515 }
1516
1517 /* Else will try to reuse lookahead token after shifting the error
1518 token. */
1519 goto yyerrlab1;
1520
1521
1522/*---------------------------------------------------.
1523| yyerrorlab -- error raised explicitly by YYERROR. |
1524`---------------------------------------------------*/
1525yyerrorlab:
1526
1527 /* Pacify compilers like GCC when the user code never invokes
1528 YYERROR and the label yyerrorlab therefore never appears in user
1529 code. */
1530 if (/*CONSTCOND*/ 0)
1531 goto yyerrorlab;
1532
1533 /* Do not reclaim the symbols of the rule whose action triggered
1534 this YYERROR. */
1535 YYPOPSTACK (yylen);
1536 yylen = 0;
1537 YY_STACK_PRINT (yyss, yyssp);
1538 yystate = *yyssp;
1539 goto yyerrlab1;
1540
1541
1542/*-------------------------------------------------------------.
1543| yyerrlab1 -- common code for both syntax error and YYERROR. |
1544`-------------------------------------------------------------*/
1545yyerrlab1:
1546 yyerrstatus = 3; /* Each real token shifted decrements this. */
1547
1548 for (;;)
1549 {
1550 yyn = yypact[yystate];
1551 if (!yypact_value_is_default (yyn))
1552 {
1553 yyn += YYTERROR;
1554 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
1555 {
1556 yyn = yytable[yyn];
1557 if (0 < yyn)
1558 break;
1559 }
1560 }
1561
1562 /* Pop the current state because it cannot handle the error token. */
1563 if (yyssp == yyss)
1564 YYABORT;
1565
1566
1567 yydestruct ("Error: popping",
1568 yystos[yystate], yyvsp);
1569 YYPOPSTACK (1);
1570 yystate = *yyssp;
1571 YY_STACK_PRINT (yyss, yyssp);
1572 }
1573
1574 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1575 *++yyvsp = yylval;
1576 YY_IGNORE_MAYBE_UNINITIALIZED_END
1577
1578
1579 /* Shift the error token. */
1580 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
1581
1582 yystate = yyn;
1583 goto yynewstate;
1584
1585
1586/*-------------------------------------.
1587| yyacceptlab -- YYACCEPT comes here. |
1588`-------------------------------------*/
1589yyacceptlab:
1590 yyresult = 0;
1591 goto yyreturn;
1592
1593/*-----------------------------------.
1594| yyabortlab -- YYABORT comes here. |
1595`-----------------------------------*/
1596yyabortlab:
1597 yyresult = 1;
1598 goto yyreturn;
1599
1600#if !defined yyoverflow || YYERROR_VERBOSE
1601/*-------------------------------------------------.
1602| yyexhaustedlab -- memory exhaustion comes here. |
1603`-------------------------------------------------*/
1604yyexhaustedlab:
1605 yyerror (YY_("memory exhausted"));
1606 yyresult = 2;
1607 /* Fall through. */
1608#endif
1609
1610yyreturn:
1611 if (yychar != YYEMPTY)
1612 {
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",
1617 yytoken, &yylval);
1618 }
1619 /* Do not reclaim the symbols of the rule whose action triggered
1620 this YYABORT or YYACCEPT. */
1621 YYPOPSTACK (yylen);
1622 YY_STACK_PRINT (yyss, yyssp);
1623 while (yyssp != yyss)
1624 {
1625 yydestruct ("Cleanup: popping",
1626 yystos[*yyssp], yyvsp);
1627 YYPOPSTACK (1);
1628 }
1629#ifndef yyoverflow
1630 if (yyss != yyssa)
1631 YYSTACK_FREE (yyss);
1632#endif
1633#if YYERROR_VERBOSE
1634 if (yymsg != yymsgbuf)
1635 YYSTACK_FREE (yymsg);
1636#endif
1637 return yyresult;
1638}
Hung-Te Lin49a44502019-03-04 15:41:09 +08001639#line 151 "fmd_parser.y" /* yacc.c:1906 */
Sol Boucher69b88bf2015-02-26 11:47:19 -08001640
1641
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001642struct flashmap_descriptor *parse_descriptor(
1643 char *name, union flashmap_flags flags, struct unsigned_option offset,
1644 struct unsigned_option size, struct descriptor_list children)
Sol Boucher69b88bf2015-02-26 11:47:19 -08001645{
1646 struct flashmap_descriptor *region = malloc(sizeof(*region));
1647 if (!region) {
Sol Boucherb9740812015-03-18 10:13:48 -07001648 perror("E: While allocating descriptor section");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001649 return NULL;
1650 }
1651 region->name = name;
Hung-Te Lin9497fcb2019-03-04 14:28:37 +08001652 region->flags = flags;
Sol Boucher69b88bf2015-02-26 11:47:19 -08001653 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) {
Sol Boucherb9740812015-03-18 10:13:48 -07001661 perror("E: While allocating node children array");
Sol Boucher69b88bf2015-02-26 11:47:19 -08001662 return NULL;
1663 }
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;
1667
1668 struct descriptor_node *next_node = cur_node->next;
1669 free(cur_node);
1670 cur_node = next_node;
1671 }
1672 } else {
1673 region->list = NULL;
1674 }
1675 return region;
1676}
1677
1678void yyerror(const char *s)
1679{
1680 fprintf(stderr, "%s\n", s);
1681}