xref: /netbsd-src/external/gpl3/binutils.old/dist/binutils/sysinfo.c (revision e992f068c547fd6e84b3f104dc2340adcc955732)
1 /* A Bison parser, made by GNU Bison 3.8.2.  */
2 
3 /* Bison implementation for Yacc-like parsers in C
4 
5    Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6    Inc.
7 
8    This program is free software: you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation, either version 3 of the License, or
11    (at your option) any later version.
12 
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17 
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
20 
21 /* As a special exception, you may create a larger work that contains
22    part or all of the Bison parser skeleton and distribute that work
23    under terms of your choice, so long as that work isn't itself a
24    parser generator using the skeleton or a modified version thereof
25    as a parser skeleton.  Alternatively, if you modify or redistribute
26    the parser skeleton itself, you may (at your option) remove this
27    special exception, which will cause the skeleton and the resulting
28    Bison output files to be licensed under the GNU General Public
29    License without this special exception.
30 
31    This special exception was added by the Free Software Foundation in
32    version 2.2 of Bison.  */
33 
34 /* C LALR(1) parser skeleton written by Richard Stallman, by
35    simplifying the original so-called "semantic" parser.  */
36 
37 /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38    especially those whose name start with YY_ or yy_.  They are
39    private implementation details that can be changed or removed.  */
40 
41 /* All symbols defined below should begin with yy or YY, to avoid
42    infringing on user name space.  This should be done even for local
43    variables, as they might otherwise be expanded by user macros.
44    There are some unavoidable exceptions within include files to
45    define necessary library symbols; they are noted "INFRINGES ON
46    USER NAME SPACE" below.  */
47 
48 /* Identify Bison output, and Bison version.  */
49 #define YYBISON 30802
50 
51 /* Bison version string.  */
52 #define YYBISON_VERSION "3.8.2"
53 
54 /* Skeleton name.  */
55 #define YYSKELETON_NAME "yacc.c"
56 
57 /* Pure parsers.  */
58 #define YYPURE 0
59 
60 /* Push parsers.  */
61 #define YYPUSH 0
62 
63 /* Pull parsers.  */
64 #define YYPULL 1
65 
66 
67 
68 
69 /* First part of user prologue.  */
70 #line 21 "sysinfo.y"
71 
72 #include <stdio.h>
73 #include <stdlib.h>
74 #include <string.h>
75 
76 static char writecode;
77 static char *it;
78 static int code;
79 static char * repeat;
80 static char *oldrepeat;
81 static char *name;
82 static int rdepth;
83 static char *names[] = {" ","[n]","[n][m]"};
84 static char *pnames[]= {"","*","**"};
85 
86 static void yyerror (const char *s);
87 extern int yylex (void);
88 
89 #line 90 "sysinfo.c"
90 
91 # ifndef YY_CAST
92 #  ifdef __cplusplus
93 #   define YY_CAST(Type, Val) static_cast<Type> (Val)
94 #   define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
95 #  else
96 #   define YY_CAST(Type, Val) ((Type) (Val))
97 #   define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
98 #  endif
99 # endif
100 # ifndef YY_NULLPTR
101 #  if defined __cplusplus
102 #   if 201103L <= __cplusplus
103 #    define YY_NULLPTR nullptr
104 #   else
105 #    define YY_NULLPTR 0
106 #   endif
107 #  else
108 #   define YY_NULLPTR ((void*)0)
109 #  endif
110 # endif
111 
112 /* Use api.header.include to #include this header
113    instead of duplicating it here.  */
114 #ifndef YY_YY_SYSINFO_H_INCLUDED
115 # define YY_YY_SYSINFO_H_INCLUDED
116 /* Debug traces.  */
117 #ifndef YYDEBUG
118 # define YYDEBUG 0
119 #endif
120 #if YYDEBUG
121 extern int yydebug;
122 #endif
123 
124 /* Token kinds.  */
125 #ifndef YYTOKENTYPE
126 # define YYTOKENTYPE
127   enum yytokentype
128   {
129     YYEMPTY = -2,
130     YYEOF = 0,                     /* "end of file"  */
131     YYerror = 256,                 /* error  */
132     YYUNDEF = 257,                 /* "invalid token"  */
133     COND = 258,                    /* COND  */
134     REPEAT = 259,                  /* REPEAT  */
135     TYPE = 260,                    /* TYPE  */
136     NAME = 261,                    /* NAME  */
137     NUMBER = 262,                  /* NUMBER  */
138     UNIT = 263                     /* UNIT  */
139   };
140   typedef enum yytokentype yytoken_kind_t;
141 #endif
142 /* Token kinds.  */
143 #define YYEMPTY -2
144 #define YYEOF 0
145 #define YYerror 256
146 #define YYUNDEF 257
147 #define COND 258
148 #define REPEAT 259
149 #define TYPE 260
150 #define NAME 261
151 #define NUMBER 262
152 #define UNIT 263
153 
154 /* Value type.  */
155 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
156 union YYSTYPE
157 {
158 #line 41 "sysinfo.y"
159 
160  int i;
161  char *s;
162 
163 #line 164 "sysinfo.c"
164 
165 };
166 typedef union YYSTYPE YYSTYPE;
167 # define YYSTYPE_IS_TRIVIAL 1
168 # define YYSTYPE_IS_DECLARED 1
169 #endif
170 
171 
172 extern YYSTYPE yylval;
173 
174 
175 int yyparse (void);
176 
177 
178 #endif /* !YY_YY_SYSINFO_H_INCLUDED  */
179 /* Symbol kind.  */
180 enum yysymbol_kind_t
181 {
182   YYSYMBOL_YYEMPTY = -2,
183   YYSYMBOL_YYEOF = 0,                      /* "end of file"  */
184   YYSYMBOL_YYerror = 1,                    /* error  */
185   YYSYMBOL_YYUNDEF = 2,                    /* "invalid token"  */
186   YYSYMBOL_COND = 3,                       /* COND  */
187   YYSYMBOL_REPEAT = 4,                     /* REPEAT  */
188   YYSYMBOL_5_ = 5,                         /* '('  */
189   YYSYMBOL_6_ = 6,                         /* ')'  */
190   YYSYMBOL_TYPE = 7,                       /* TYPE  */
191   YYSYMBOL_NAME = 8,                       /* NAME  */
192   YYSYMBOL_NUMBER = 9,                     /* NUMBER  */
193   YYSYMBOL_UNIT = 10,                      /* UNIT  */
194   YYSYMBOL_YYACCEPT = 11,                  /* $accept  */
195   YYSYMBOL_top = 12,                       /* top  */
196   YYSYMBOL_13_1 = 13,                      /* $@1  */
197   YYSYMBOL_it_list = 14,                   /* it_list  */
198   YYSYMBOL_it = 15,                        /* it  */
199   YYSYMBOL_16_2 = 16,                      /* $@2  */
200   YYSYMBOL_it_field_list = 17,             /* it_field_list  */
201   YYSYMBOL_repeat_it_field = 18,           /* repeat_it_field  */
202   YYSYMBOL_19_3 = 19,                      /* $@3  */
203   YYSYMBOL_cond_it_field = 20,             /* cond_it_field  */
204   YYSYMBOL_21_4 = 21,                      /* $@4  */
205   YYSYMBOL_it_field = 22,                  /* it_field  */
206   YYSYMBOL_23_5 = 23,                      /* $@5  */
207   YYSYMBOL_attr_type = 24,                 /* attr_type  */
208   YYSYMBOL_attr_desc = 25,                 /* attr_desc  */
209   YYSYMBOL_attr_size = 26,                 /* attr_size  */
210   YYSYMBOL_attr_id = 27,                   /* attr_id  */
211   YYSYMBOL_enums = 28,                     /* enums  */
212   YYSYMBOL_enum_list = 29                  /* enum_list  */
213 };
214 typedef enum yysymbol_kind_t yysymbol_kind_t;
215 
216 
217 
218 
219 #ifdef short
220 # undef short
221 #endif
222 
223 /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
224    <limits.h> and (if available) <stdint.h> are included
225    so that the code can choose integer types of a good width.  */
226 
227 #ifndef __PTRDIFF_MAX__
228 # include <limits.h> /* INFRINGES ON USER NAME SPACE */
229 # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
230 #  include <stdint.h> /* INFRINGES ON USER NAME SPACE */
231 #  define YY_STDINT_H
232 # endif
233 #endif
234 
235 /* Narrow types that promote to a signed type and that can represent a
236    signed or unsigned integer of at least N bits.  In tables they can
237    save space and decrease cache pressure.  Promoting to a signed type
238    helps avoid bugs in integer arithmetic.  */
239 
240 #ifdef __INT_LEAST8_MAX__
241 typedef __INT_LEAST8_TYPE__ yytype_int8;
242 #elif defined YY_STDINT_H
243 typedef int_least8_t yytype_int8;
244 #else
245 typedef signed char yytype_int8;
246 #endif
247 
248 #ifdef __INT_LEAST16_MAX__
249 typedef __INT_LEAST16_TYPE__ yytype_int16;
250 #elif defined YY_STDINT_H
251 typedef int_least16_t yytype_int16;
252 #else
253 typedef short yytype_int16;
254 #endif
255 
256 /* Work around bug in HP-UX 11.23, which defines these macros
257    incorrectly for preprocessor constants.  This workaround can likely
258    be removed in 2023, as HPE has promised support for HP-UX 11.23
259    (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
260    <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>.  */
261 #ifdef __hpux
262 # undef UINT_LEAST8_MAX
263 # undef UINT_LEAST16_MAX
264 # define UINT_LEAST8_MAX 255
265 # define UINT_LEAST16_MAX 65535
266 #endif
267 
268 #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
269 typedef __UINT_LEAST8_TYPE__ yytype_uint8;
270 #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
271        && UINT_LEAST8_MAX <= INT_MAX)
272 typedef uint_least8_t yytype_uint8;
273 #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
274 typedef unsigned char yytype_uint8;
275 #else
276 typedef short yytype_uint8;
277 #endif
278 
279 #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
280 typedef __UINT_LEAST16_TYPE__ yytype_uint16;
281 #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
282        && UINT_LEAST16_MAX <= INT_MAX)
283 typedef uint_least16_t yytype_uint16;
284 #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
285 typedef unsigned short yytype_uint16;
286 #else
287 typedef int yytype_uint16;
288 #endif
289 
290 #ifndef YYPTRDIFF_T
291 # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
292 #  define YYPTRDIFF_T __PTRDIFF_TYPE__
293 #  define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
294 # elif defined PTRDIFF_MAX
295 #  ifndef ptrdiff_t
296 #   include <stddef.h> /* INFRINGES ON USER NAME SPACE */
297 #  endif
298 #  define YYPTRDIFF_T ptrdiff_t
299 #  define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
300 # else
301 #  define YYPTRDIFF_T long
302 #  define YYPTRDIFF_MAXIMUM LONG_MAX
303 # endif
304 #endif
305 
306 #ifndef YYSIZE_T
307 # ifdef __SIZE_TYPE__
308 #  define YYSIZE_T __SIZE_TYPE__
309 # elif defined size_t
310 #  define YYSIZE_T size_t
311 # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
312 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
313 #  define YYSIZE_T size_t
314 # else
315 #  define YYSIZE_T unsigned
316 # endif
317 #endif
318 
319 #define YYSIZE_MAXIMUM                                  \
320   YY_CAST (YYPTRDIFF_T,                                 \
321            (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1)  \
322             ? YYPTRDIFF_MAXIMUM                         \
323             : YY_CAST (YYSIZE_T, -1)))
324 
325 #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
326 
327 
328 /* Stored state numbers (used for stacks). */
329 typedef yytype_int8 yy_state_t;
330 
331 /* State numbers in computations.  */
332 typedef int yy_state_fast_t;
333 
334 #ifndef YY_
335 # if defined YYENABLE_NLS && YYENABLE_NLS
336 #  if ENABLE_NLS
337 #   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
338 #   define YY_(Msgid) dgettext ("bison-runtime", Msgid)
339 #  endif
340 # endif
341 # ifndef YY_
342 #  define YY_(Msgid) Msgid
343 # endif
344 #endif
345 
346 
347 #ifndef YY_ATTRIBUTE_PURE
348 # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
349 #  define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
350 # else
351 #  define YY_ATTRIBUTE_PURE
352 # endif
353 #endif
354 
355 #ifndef YY_ATTRIBUTE_UNUSED
356 # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
357 #  define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
358 # else
359 #  define YY_ATTRIBUTE_UNUSED
360 # endif
361 #endif
362 
363 /* Suppress unused-variable warnings by "using" E.  */
364 #if ! defined lint || defined __GNUC__
365 # define YY_USE(E) ((void) (E))
366 #else
367 # define YY_USE(E) /* empty */
368 #endif
369 
370 /* Suppress an incorrect diagnostic about yylval being uninitialized.  */
371 #if defined __GNUC__ && ! defined __ICC && 406 <= __GNUC__ * 100 + __GNUC_MINOR__
372 # if __GNUC__ * 100 + __GNUC_MINOR__ < 407
373 #  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
374     _Pragma ("GCC diagnostic push")                                     \
375     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")
376 # else
377 #  define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN                           \
378     _Pragma ("GCC diagnostic push")                                     \
379     _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")              \
380     _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
381 # endif
382 # define YY_IGNORE_MAYBE_UNINITIALIZED_END      \
383     _Pragma ("GCC diagnostic pop")
384 #else
385 # define YY_INITIAL_VALUE(Value) Value
386 #endif
387 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
388 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
389 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
390 #endif
391 #ifndef YY_INITIAL_VALUE
392 # define YY_INITIAL_VALUE(Value) /* Nothing. */
393 #endif
394 
395 #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
396 # define YY_IGNORE_USELESS_CAST_BEGIN                          \
397     _Pragma ("GCC diagnostic push")                            \
398     _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
399 # define YY_IGNORE_USELESS_CAST_END            \
400     _Pragma ("GCC diagnostic pop")
401 #endif
402 #ifndef YY_IGNORE_USELESS_CAST_BEGIN
403 # define YY_IGNORE_USELESS_CAST_BEGIN
404 # define YY_IGNORE_USELESS_CAST_END
405 #endif
406 
407 
408 #define YY_ASSERT(E) ((void) (0 && (E)))
409 
410 #if !defined yyoverflow
411 
412 /* The parser invokes alloca or malloc; define the necessary symbols.  */
413 
414 # ifdef YYSTACK_USE_ALLOCA
415 #  if YYSTACK_USE_ALLOCA
416 #   ifdef __GNUC__
417 #    define YYSTACK_ALLOC __builtin_alloca
418 #   elif defined __BUILTIN_VA_ARG_INCR
419 #    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
420 #   elif defined _AIX
421 #    define YYSTACK_ALLOC __alloca
422 #   elif defined _MSC_VER
423 #    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
424 #    define alloca _alloca
425 #   else
426 #    define YYSTACK_ALLOC alloca
427 #    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
428 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
429       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
430 #     ifndef EXIT_SUCCESS
431 #      define EXIT_SUCCESS 0
432 #     endif
433 #    endif
434 #   endif
435 #  endif
436 # endif
437 
438 # ifdef YYSTACK_ALLOC
439    /* Pacify GCC's 'empty if-body' warning.  */
440 #  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
441 #  ifndef YYSTACK_ALLOC_MAXIMUM
442     /* The OS might guarantee only one guard page at the bottom of the stack,
443        and a page size can be as small as 4096 bytes.  So we cannot safely
444        invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
445        to allow for a few compiler-allocated temporary stack slots.  */
446 #   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
447 #  endif
448 # else
449 #  define YYSTACK_ALLOC YYMALLOC
450 #  define YYSTACK_FREE YYFREE
451 #  ifndef YYSTACK_ALLOC_MAXIMUM
452 #   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
453 #  endif
454 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
455        && ! ((defined YYMALLOC || defined malloc) \
456              && (defined YYFREE || defined free)))
457 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
458 #   ifndef EXIT_SUCCESS
459 #    define EXIT_SUCCESS 0
460 #   endif
461 #  endif
462 #  ifndef YYMALLOC
463 #   define YYMALLOC malloc
464 #   if ! defined malloc && ! defined EXIT_SUCCESS
465 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
466 #   endif
467 #  endif
468 #  ifndef YYFREE
469 #   define YYFREE free
470 #   if ! defined free && ! defined EXIT_SUCCESS
471 void free (void *); /* INFRINGES ON USER NAME SPACE */
472 #   endif
473 #  endif
474 # endif
475 #endif /* !defined yyoverflow */
476 
477 #if (! defined yyoverflow \
478      && (! defined __cplusplus \
479          || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
480 
481 /* A type that is properly aligned for any stack member.  */
482 union yyalloc
483 {
484   yy_state_t yyss_alloc;
485   YYSTYPE yyvs_alloc;
486 };
487 
488 /* The size of the maximum gap between one aligned stack and the next.  */
489 # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
490 
491 /* The size of an array large to enough to hold all stacks, each with
492    N elements.  */
493 # define YYSTACK_BYTES(N) \
494      ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
495       + YYSTACK_GAP_MAXIMUM)
496 
497 # define YYCOPY_NEEDED 1
498 
499 /* Relocate STACK from its old location to the new one.  The
500    local variables YYSIZE and YYSTACKSIZE give the old and new number of
501    elements in the stack, and YYPTR gives the new location of the
502    stack.  Advance YYPTR to a properly aligned location for the next
503    stack.  */
504 # define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
505     do                                                                  \
506       {                                                                 \
507         YYPTRDIFF_T yynewbytes;                                         \
508         YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
509         Stack = &yyptr->Stack_alloc;                                    \
510         yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
511         yyptr += yynewbytes / YYSIZEOF (*yyptr);                        \
512       }                                                                 \
513     while (0)
514 
515 #endif
516 
517 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
518 /* Copy COUNT objects from SRC to DST.  The source and destination do
519    not overlap.  */
520 # ifndef YYCOPY
521 #  if defined __GNUC__ && 1 < __GNUC__
522 #   define YYCOPY(Dst, Src, Count) \
523       __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
524 #  else
525 #   define YYCOPY(Dst, Src, Count)              \
526       do                                        \
527         {                                       \
528           YYPTRDIFF_T yyi;                      \
529           for (yyi = 0; yyi < (Count); yyi++)   \
530             (Dst)[yyi] = (Src)[yyi];            \
531         }                                       \
532       while (0)
533 #  endif
534 # endif
535 #endif /* !YYCOPY_NEEDED */
536 
537 /* YYFINAL -- State number of the termination state.  */
538 #define YYFINAL  3
539 /* YYLAST -- Last index in YYTABLE.  */
540 #define YYLAST   38
541 
542 /* YYNTOKENS -- Number of terminals.  */
543 #define YYNTOKENS  11
544 /* YYNNTS -- Number of nonterminals.  */
545 #define YYNNTS  19
546 /* YYNRULES -- Number of rules.  */
547 #define YYNRULES  27
548 /* YYNSTATES -- Number of states.  */
549 #define YYNSTATES  55
550 
551 /* YYMAXUTOK -- Last valid token kind.  */
552 #define YYMAXUTOK   263
553 
554 
555 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
556    as returned by yylex, with out-of-bounds checking.  */
557 #define YYTRANSLATE(YYX)                                \
558   (0 <= (YYX) && (YYX) <= YYMAXUTOK                     \
559    ? YY_CAST (yysymbol_kind_t, yytranslate[YYX])        \
560    : YYSYMBOL_YYUNDEF)
561 
562 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
563    as returned by yylex.  */
564 static const yytype_int8 yytranslate[] =
565 {
566        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
567        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
568        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
569        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
570        5,     6,     2,     2,     2,     2,     2,     2,     2,     2,
571        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
572        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
573        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
574        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
575        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
576        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
577        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
578        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
579        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
580        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
581        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
582        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
583        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
584        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
585        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
586        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
587        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
588        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
589        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
590        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
591        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
592        7,     8,     9,    10
593 };
594 
595 #if YYDEBUG
596 /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
597 static const yytype_int16 yyrline[] =
598 {
599        0,    55,    55,    55,    93,    94,    99,    98,   171,   172,
600      173,   174,   178,   177,   228,   227,   257,   256,   367,   368,
601      372,   377,   383,   384,   387,   388,   390,   392
602 };
603 #endif
604 
605 /** Accessing symbol of state STATE.  */
606 #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
607 
608 #if YYDEBUG || 0
609 /* The user-facing name of the symbol whose (internal) number is
610    YYSYMBOL.  No bounds checking.  */
611 static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
612 
613 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
614    First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
615 static const char *const yytname[] =
616 {
617   "\"end of file\"", "error", "\"invalid token\"", "COND", "REPEAT",
618   "'('", "')'", "TYPE", "NAME", "NUMBER", "UNIT", "$accept", "top", "$@1",
619   "it_list", "it", "$@2", "it_field_list", "repeat_it_field", "$@3",
620   "cond_it_field", "$@4", "it_field", "$@5", "attr_type", "attr_desc",
621   "attr_size", "attr_id", "enums", "enum_list", YY_NULLPTR
622 };
623 
624 static const char *
yysymbol_name(yysymbol_kind_t yysymbol)625 yysymbol_name (yysymbol_kind_t yysymbol)
626 {
627   return yytname[yysymbol];
628 }
629 #endif
630 
631 #define YYPACT_NINF (-14)
632 
633 #define yypact_value_is_default(Yyn) \
634   ((Yyn) == YYPACT_NINF)
635 
636 #define YYTABLE_NINF (-1)
637 
638 #define yytable_value_is_error(Yyn) \
639   0
640 
641 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
642    STATE-NUM.  */
643 static const yytype_int8 yypact[] =
644 {
645      -14,     8,     4,   -14,     2,   -14,     4,     3,   -14,   -14,
646        6,     0,     7,     6,     6,     6,     9,    10,    11,    15,
647      -14,   -14,   -14,   -14,   -14,   -14,    16,    14,     6,     6,
648      -14,   -14,     5,    17,    18,    19,    20,   -14,   -14,   -14,
649       22,    23,   -14,    24,    27,   -14,   -14,    28,     1,   -14,
650       25,   -14,    29,    30,   -14
651 };
652 
653 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
654    Performed when YYTABLE does not specify something else to do.  Zero
655    means the default is an error.  */
656 static const yytype_int8 yydefact[] =
657 {
658        2,     0,     5,     1,     0,     3,     5,     0,     4,     6,
659       11,     0,     0,    11,    11,    11,     0,     0,     0,     0,
660        7,    10,     9,     8,    14,    12,     0,    19,    11,    11,
661       20,    18,     0,     0,     0,     0,     0,    15,    13,    21,
662       23,     0,    16,     0,    24,    22,    26,     0,     0,    17,
663        0,    25,     0,     0,    27
664 };
665 
666 /* YYPGOTO[NTERM-NUM].  */
667 static const yytype_int8 yypgoto[] =
668 {
669      -14,   -14,   -14,    32,   -14,   -14,   -13,   -14,   -14,   -14,
670      -14,   -14,   -14,   -14,   -14,   -14,   -14,   -14,   -14
671 };
672 
673 /* YYDEFGOTO[NTERM-NUM].  */
674 static const yytype_int8 yydefgoto[] =
675 {
676        0,     1,     2,     5,     6,    10,    12,    13,    29,    14,
677       28,    15,    44,    32,    19,    36,    42,    47,    48
678 };
679 
680 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
681    positive, shift that token.  If negative, reduce the rule whose
682    number is the opposite.  If YYTABLE_NINF, syntax error.  */
683 static const yytype_int8 yytable[] =
684 {
685       21,    22,    23,    16,    17,    18,    50,    51,     3,     4,
686        7,    11,     9,    20,    35,    33,    34,    24,    25,    26,
687       27,    31,    30,    37,    38,     0,    40,    41,     0,    39,
688       45,    43,    46,    52,    49,     0,    54,    53,     8
689 };
690 
691 static const yytype_int8 yycheck[] =
692 {
693       13,    14,    15,     3,     4,     5,     5,     6,     0,     5,
694        8,     5,     9,     6,     9,    28,    29,     8,     8,     8,
695        5,     7,     6,     6,     6,    -1,     6,     5,    -1,    10,
696        6,     8,     5,     8,     6,    -1,     6,     8,     6
697 };
698 
699 /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of
700    state STATE-NUM.  */
701 static const yytype_int8 yystos[] =
702 {
703        0,    12,    13,     0,     5,    14,    15,     8,    14,     9,
704       16,     5,    17,    18,    20,    22,     3,     4,     5,    25,
705        6,    17,    17,    17,     8,     8,     8,     5,    21,    19,
706        6,     7,    24,    17,    17,     9,    26,     6,     6,    10,
707        6,     5,    27,     8,    23,     6,     5,    28,    29,     6,
708        5,     6,     8,     8,     6
709 };
710 
711 /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM.  */
712 static const yytype_int8 yyr1[] =
713 {
714        0,    11,    13,    12,    14,    14,    16,    15,    17,    17,
715       17,    17,    19,    18,    21,    20,    23,    22,    24,    24,
716       25,    26,    27,    27,    28,    28,    29,    29
717 };
718 
719 /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM.  */
720 static const yytype_int8 yyr2[] =
721 {
722        0,     2,     0,     2,     2,     0,     0,     6,     2,     2,
723        2,     0,     0,     6,     0,     6,     0,    10,     1,     0,
724        3,     2,     3,     0,     0,     3,     0,     5
725 };
726 
727 
728 enum { YYENOMEM = -2 };
729 
730 #define yyerrok         (yyerrstatus = 0)
731 #define yyclearin       (yychar = YYEMPTY)
732 
733 #define YYACCEPT        goto yyacceptlab
734 #define YYABORT         goto yyabortlab
735 #define YYERROR         goto yyerrorlab
736 #define YYNOMEM         goto yyexhaustedlab
737 
738 
739 #define YYRECOVERING()  (!!yyerrstatus)
740 
741 #define YYBACKUP(Token, Value)                                    \
742   do                                                              \
743     if (yychar == YYEMPTY)                                        \
744       {                                                           \
745         yychar = (Token);                                         \
746         yylval = (Value);                                         \
747         YYPOPSTACK (yylen);                                       \
748         yystate = *yyssp;                                         \
749         goto yybackup;                                            \
750       }                                                           \
751     else                                                          \
752       {                                                           \
753         yyerror (YY_("syntax error: cannot back up")); \
754         YYERROR;                                                  \
755       }                                                           \
756   while (0)
757 
758 /* Backward compatibility with an undocumented macro.
759    Use YYerror or YYUNDEF. */
760 #define YYERRCODE YYUNDEF
761 
762 
763 /* Enable debugging if requested.  */
764 #if YYDEBUG
765 
766 # ifndef YYFPRINTF
767 #  include <stdio.h> /* INFRINGES ON USER NAME SPACE */
768 #  define YYFPRINTF fprintf
769 # endif
770 
771 # define YYDPRINTF(Args)                        \
772 do {                                            \
773   if (yydebug)                                  \
774     YYFPRINTF Args;                             \
775 } while (0)
776 
777 
778 
779 
780 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)                    \
781 do {                                                                      \
782   if (yydebug)                                                            \
783     {                                                                     \
784       YYFPRINTF (stderr, "%s ", Title);                                   \
785       yy_symbol_print (stderr,                                            \
786                   Kind, Value); \
787       YYFPRINTF (stderr, "\n");                                           \
788     }                                                                     \
789 } while (0)
790 
791 
792 /*-----------------------------------.
793 | Print this symbol's value on YYO.  |
794 `-----------------------------------*/
795 
796 static void
yy_symbol_value_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep)797 yy_symbol_value_print (FILE *yyo,
798                        yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
799 {
800   FILE *yyoutput = yyo;
801   YY_USE (yyoutput);
802   if (!yyvaluep)
803     return;
804   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
805   YY_USE (yykind);
806   YY_IGNORE_MAYBE_UNINITIALIZED_END
807 }
808 
809 
810 /*---------------------------.
811 | Print this symbol on YYO.  |
812 `---------------------------*/
813 
814 static void
yy_symbol_print(FILE * yyo,yysymbol_kind_t yykind,YYSTYPE const * const yyvaluep)815 yy_symbol_print (FILE *yyo,
816                  yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep)
817 {
818   YYFPRINTF (yyo, "%s %s (",
819              yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
820 
821   yy_symbol_value_print (yyo, yykind, yyvaluep);
822   YYFPRINTF (yyo, ")");
823 }
824 
825 /*------------------------------------------------------------------.
826 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
827 | TOP (included).                                                   |
828 `------------------------------------------------------------------*/
829 
830 static void
yy_stack_print(yy_state_t * yybottom,yy_state_t * yytop)831 yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
832 {
833   YYFPRINTF (stderr, "Stack now");
834   for (; yybottom <= yytop; yybottom++)
835     {
836       int yybot = *yybottom;
837       YYFPRINTF (stderr, " %d", yybot);
838     }
839   YYFPRINTF (stderr, "\n");
840 }
841 
842 # define YY_STACK_PRINT(Bottom, Top)                            \
843 do {                                                            \
844   if (yydebug)                                                  \
845     yy_stack_print ((Bottom), (Top));                           \
846 } while (0)
847 
848 
849 /*------------------------------------------------.
850 | Report that the YYRULE is going to be reduced.  |
851 `------------------------------------------------*/
852 
853 static void
yy_reduce_print(yy_state_t * yyssp,YYSTYPE * yyvsp,int yyrule)854 yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
855                  int yyrule)
856 {
857   int yylno = yyrline[yyrule];
858   int yynrhs = yyr2[yyrule];
859   int yyi;
860   YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
861              yyrule - 1, yylno);
862   /* The symbols being reduced.  */
863   for (yyi = 0; yyi < yynrhs; yyi++)
864     {
865       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
866       yy_symbol_print (stderr,
867                        YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
868                        &yyvsp[(yyi + 1) - (yynrhs)]);
869       YYFPRINTF (stderr, "\n");
870     }
871 }
872 
873 # define YY_REDUCE_PRINT(Rule)          \
874 do {                                    \
875   if (yydebug)                          \
876     yy_reduce_print (yyssp, yyvsp, Rule); \
877 } while (0)
878 
879 /* Nonzero means print parse trace.  It is left uninitialized so that
880    multiple parsers can coexist.  */
881 int yydebug;
882 #else /* !YYDEBUG */
883 # define YYDPRINTF(Args) ((void) 0)
884 # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
885 # define YY_STACK_PRINT(Bottom, Top)
886 # define YY_REDUCE_PRINT(Rule)
887 #endif /* !YYDEBUG */
888 
889 
890 /* YYINITDEPTH -- initial size of the parser's stacks.  */
891 #ifndef YYINITDEPTH
892 # define YYINITDEPTH 200
893 #endif
894 
895 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
896    if the built-in stack extension method is used).
897 
898    Do not make this value too large; the results are undefined if
899    YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
900    evaluated with infinite-precision integer arithmetic.  */
901 
902 #ifndef YYMAXDEPTH
903 # define YYMAXDEPTH 10000
904 #endif
905 
906 
907 
908 
909 
910 
911 /*-----------------------------------------------.
912 | Release the memory associated to this symbol.  |
913 `-----------------------------------------------*/
914 
915 static void
yydestruct(const char * yymsg,yysymbol_kind_t yykind,YYSTYPE * yyvaluep)916 yydestruct (const char *yymsg,
917             yysymbol_kind_t yykind, YYSTYPE *yyvaluep)
918 {
919   YY_USE (yyvaluep);
920   if (!yymsg)
921     yymsg = "Deleting";
922   YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
923 
924   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
925   YY_USE (yykind);
926   YY_IGNORE_MAYBE_UNINITIALIZED_END
927 }
928 
929 
930 /* Lookahead token kind.  */
931 int yychar;
932 
933 /* The semantic value of the lookahead symbol.  */
934 YYSTYPE yylval;
935 /* Number of syntax errors so far.  */
936 int yynerrs;
937 
938 
939 
940 
941 /*----------.
942 | yyparse.  |
943 `----------*/
944 
945 int
yyparse(void)946 yyparse (void)
947 {
948     yy_state_fast_t yystate = 0;
949     /* Number of tokens to shift before error messages enabled.  */
950     int yyerrstatus = 0;
951 
952     /* Refer to the stacks through separate pointers, to allow yyoverflow
953        to reallocate them elsewhere.  */
954 
955     /* Their size.  */
956     YYPTRDIFF_T yystacksize = YYINITDEPTH;
957 
958     /* The state stack: array, bottom, top.  */
959     yy_state_t yyssa[YYINITDEPTH];
960     yy_state_t *yyss = yyssa;
961     yy_state_t *yyssp = yyss;
962 
963     /* The semantic value stack: array, bottom, top.  */
964     YYSTYPE yyvsa[YYINITDEPTH];
965     YYSTYPE *yyvs = yyvsa;
966     YYSTYPE *yyvsp = yyvs;
967 
968   int yyn;
969   /* The return value of yyparse.  */
970   int yyresult;
971   /* Lookahead symbol kind.  */
972   yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
973   /* The variables used to return semantic value and location from the
974      action routines.  */
975   YYSTYPE yyval;
976 
977 
978 
979 #define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
980 
981   /* The number of symbols on the RHS of the reduced rule.
982      Keep to zero when no symbol should be popped.  */
983   int yylen = 0;
984 
985   YYDPRINTF ((stderr, "Starting parse\n"));
986 
987   yychar = YYEMPTY; /* Cause a token to be read.  */
988 
989   goto yysetstate;
990 
991 
992 /*------------------------------------------------------------.
993 | yynewstate -- push a new state, which is found in yystate.  |
994 `------------------------------------------------------------*/
995 yynewstate:
996   /* In all cases, when you get here, the value and location stacks
997      have just been pushed.  So pushing a state here evens the stacks.  */
998   yyssp++;
999 
1000 
1001 /*--------------------------------------------------------------------.
1002 | yysetstate -- set current state (the top of the stack) to yystate.  |
1003 `--------------------------------------------------------------------*/
1004 yysetstate:
1005   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1006   YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1007   YY_IGNORE_USELESS_CAST_BEGIN
1008   *yyssp = YY_CAST (yy_state_t, yystate);
1009   YY_IGNORE_USELESS_CAST_END
1010   YY_STACK_PRINT (yyss, yyssp);
1011 
1012   if (yyss + yystacksize - 1 <= yyssp)
1013 #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1014     YYNOMEM;
1015 #else
1016     {
1017       /* Get the current used size of the three stacks, in elements.  */
1018       YYPTRDIFF_T yysize = yyssp - yyss + 1;
1019 
1020 # if defined yyoverflow
1021       {
1022         /* Give user a chance to reallocate the stack.  Use copies of
1023            these so that the &'s don't force the real ones into
1024            memory.  */
1025         yy_state_t *yyss1 = yyss;
1026         YYSTYPE *yyvs1 = yyvs;
1027 
1028         /* Each stack pointer address is followed by the size of the
1029            data in use in that stack, in bytes.  This used to be a
1030            conditional around just the two extra args, but that might
1031            be undefined if yyoverflow is a macro.  */
1032         yyoverflow (YY_("memory exhausted"),
1033                     &yyss1, yysize * YYSIZEOF (*yyssp),
1034                     &yyvs1, yysize * YYSIZEOF (*yyvsp),
1035                     &yystacksize);
1036         yyss = yyss1;
1037         yyvs = yyvs1;
1038       }
1039 # else /* defined YYSTACK_RELOCATE */
1040       /* Extend the stack our own way.  */
1041       if (YYMAXDEPTH <= yystacksize)
1042         YYNOMEM;
1043       yystacksize *= 2;
1044       if (YYMAXDEPTH < yystacksize)
1045         yystacksize = YYMAXDEPTH;
1046 
1047       {
1048         yy_state_t *yyss1 = yyss;
1049         union yyalloc *yyptr =
1050           YY_CAST (union yyalloc *,
1051                    YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1052         if (! yyptr)
1053           YYNOMEM;
1054         YYSTACK_RELOCATE (yyss_alloc, yyss);
1055         YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1056 #  undef YYSTACK_RELOCATE
1057         if (yyss1 != yyssa)
1058           YYSTACK_FREE (yyss1);
1059       }
1060 # endif
1061 
1062       yyssp = yyss + yysize - 1;
1063       yyvsp = yyvs + yysize - 1;
1064 
1065       YY_IGNORE_USELESS_CAST_BEGIN
1066       YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1067                   YY_CAST (long, yystacksize)));
1068       YY_IGNORE_USELESS_CAST_END
1069 
1070       if (yyss + yystacksize - 1 <= yyssp)
1071         YYABORT;
1072     }
1073 #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1074 
1075 
1076   if (yystate == YYFINAL)
1077     YYACCEPT;
1078 
1079   goto yybackup;
1080 
1081 
1082 /*-----------.
1083 | yybackup.  |
1084 `-----------*/
1085 yybackup:
1086   /* Do appropriate processing given the current state.  Read a
1087      lookahead token if we need one and don't already have one.  */
1088 
1089   /* First try to decide what to do without reference to lookahead token.  */
1090   yyn = yypact[yystate];
1091   if (yypact_value_is_default (yyn))
1092     goto yydefault;
1093 
1094   /* Not known => get a lookahead token if don't already have one.  */
1095 
1096   /* YYCHAR is either empty, or end-of-input, or a valid lookahead.  */
1097   if (yychar == YYEMPTY)
1098     {
1099       YYDPRINTF ((stderr, "Reading a token\n"));
1100       yychar = yylex ();
1101     }
1102 
1103   if (yychar <= YYEOF)
1104     {
1105       yychar = YYEOF;
1106       yytoken = YYSYMBOL_YYEOF;
1107       YYDPRINTF ((stderr, "Now at end of input.\n"));
1108     }
1109   else if (yychar == YYerror)
1110     {
1111       /* The scanner already issued an error message, process directly
1112          to error recovery.  But do not keep the error token as
1113          lookahead, it is too special and may lead us to an endless
1114          loop in error recovery. */
1115       yychar = YYUNDEF;
1116       yytoken = YYSYMBOL_YYerror;
1117       goto yyerrlab1;
1118     }
1119   else
1120     {
1121       yytoken = YYTRANSLATE (yychar);
1122       YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1123     }
1124 
1125   /* If the proper action on seeing token YYTOKEN is to reduce or to
1126      detect an error, take that action.  */
1127   yyn += yytoken;
1128   if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1129     goto yydefault;
1130   yyn = yytable[yyn];
1131   if (yyn <= 0)
1132     {
1133       if (yytable_value_is_error (yyn))
1134         goto yyerrlab;
1135       yyn = -yyn;
1136       goto yyreduce;
1137     }
1138 
1139   /* Count tokens shifted since error; after three, turn off error
1140      status.  */
1141   if (yyerrstatus)
1142     yyerrstatus--;
1143 
1144   /* Shift the lookahead token.  */
1145   YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1146   yystate = yyn;
1147   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1148   *++yyvsp = yylval;
1149   YY_IGNORE_MAYBE_UNINITIALIZED_END
1150 
1151   /* Discard the shifted token.  */
1152   yychar = YYEMPTY;
1153   goto yynewstate;
1154 
1155 
1156 /*-----------------------------------------------------------.
1157 | yydefault -- do the default action for the current state.  |
1158 `-----------------------------------------------------------*/
1159 yydefault:
1160   yyn = yydefact[yystate];
1161   if (yyn == 0)
1162     goto yyerrlab;
1163   goto yyreduce;
1164 
1165 
1166 /*-----------------------------.
1167 | yyreduce -- do a reduction.  |
1168 `-----------------------------*/
1169 yyreduce:
1170   /* yyn is the number of a rule to reduce with.  */
1171   yylen = yyr2[yyn];
1172 
1173   /* If YYLEN is nonzero, implement the default value of the action:
1174      '$$ = $1'.
1175 
1176      Otherwise, the following line sets YYVAL to garbage.
1177      This behavior is undocumented and Bison
1178      users should not rely upon it.  Assigning to YYVAL
1179      unconditionally makes the parser a bit smaller, and it avoids a
1180      GCC warning that YYVAL may be used uninitialized.  */
1181   yyval = yyvsp[1-yylen];
1182 
1183 
1184   YY_REDUCE_PRINT (yyn);
1185   switch (yyn)
1186     {
1187   case 2: /* $@1: %empty  */
1188 #line 55 "sysinfo.y"
1189       {
1190   switch (writecode)
1191     {
1192     case 'i':
1193       printf("#ifdef SYSROFF_SWAP_IN\n");
1194       break;
1195     case 'p':
1196       printf("#ifdef SYSROFF_p\n");
1197       break;
1198     case 'd':
1199       break;
1200     case 'g':
1201       printf("#ifdef SYSROFF_SWAP_OUT\n");
1202       break;
1203     case 'c':
1204       printf("#ifdef SYSROFF_PRINT\n");
1205       printf("#include <stdio.h>\n");
1206       printf("#include <stdlib.h>\n");
1207       printf("#include <ansidecl.h>\n");
1208       break;
1209     }
1210  }
1211 #line 1212 "sysinfo.c"
1212     break;
1213 
1214   case 3: /* top: $@1 it_list  */
1215 #line 77 "sysinfo.y"
1216         {
1217   switch (writecode) {
1218   case 'i':
1219   case 'p':
1220   case 'g':
1221   case 'c':
1222     printf("#endif\n");
1223     break;
1224   case 'd':
1225     break;
1226   }
1227 }
1228 #line 1229 "sysinfo.c"
1229     break;
1230 
1231   case 6: /* $@2: %empty  */
1232 #line 99 "sysinfo.y"
1233       {
1234 	it = (yyvsp[-1].s); code = (yyvsp[0].i);
1235 	switch (writecode)
1236 	  {
1237 	  case 'd':
1238 	    printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code);
1239 	    printf("struct IT_%s;\n", it);
1240 	    printf("extern void sysroff_swap_%s_in (struct IT_%s *);\n",
1241 		   (yyvsp[-1].s), it);
1242 	    printf("extern void sysroff_swap_%s_out (FILE *, struct IT_%s *);\n",
1243 		   (yyvsp[-1].s), it);
1244 	    printf("extern void sysroff_print_%s_out (struct IT_%s *);\n",
1245 		   (yyvsp[-1].s), it);
1246 	    printf("struct IT_%s { \n", it);
1247 	    break;
1248 	  case 'i':
1249 	    printf("void sysroff_swap_%s_in (struct IT_%s * ptr)\n",(yyvsp[-1].s),it);
1250 	    printf("{\n");
1251 	    printf("\tunsigned char raw[255];\n");
1252 	    printf("\tint idx = 0;\n");
1253 	    printf("\tint size;\n");
1254 	    printf("\tmemset(raw,0,255);\n");
1255 	    printf("\tmemset(ptr,0,sizeof(*ptr));\n");
1256 	    printf("\tsize = fillup(raw);\n");
1257 	    break;
1258 	  case 'g':
1259 	    printf("void sysroff_swap_%s_out (FILE * ffile, struct IT_%s * ptr)\n",(yyvsp[-1].s),it);
1260 	    printf("{\n");
1261 	    printf("\tunsigned char raw[255];\n");
1262 	    printf("\tint idx = 16;\n");
1263 	    printf("\tmemset (raw, 0, 255);\n");
1264 	    printf("\tcode = IT_%s_CODE;\n", it);
1265 	    break;
1266 	  case 'o':
1267 	    printf("void sysroff_swap_%s_out (bfd * abfd, struct IT_%s * ptr)\n",(yyvsp[-1].s), it);
1268 	    printf("{\n");
1269 	    printf("\tint idx = 0;\n");
1270 	    break;
1271 	  case 'c':
1272 	    printf("void sysroff_print_%s_out (struct IT_%s *ptr)\n",(yyvsp[-1].s),it);
1273 	    printf("{\n");
1274 	    printf("itheader(\"%s\", IT_%s_CODE);\n",(yyvsp[-1].s),(yyvsp[-1].s));
1275 	    break;
1276 
1277 	  case 't':
1278 	    break;
1279 	  }
1280 
1281       }
1282 #line 1283 "sysinfo.c"
1283     break;
1284 
1285   case 7: /* it: '(' NAME NUMBER $@2 it_field_list ')'  */
1286 #line 150 "sysinfo.y"
1287 {
1288   switch (writecode) {
1289   case 'd':
1290     printf("};\n");
1291     break;
1292   case 'g':
1293     printf("\tchecksum(ffile,raw, idx, IT_%s_CODE);\n", it);
1294     /* Fall through.  */
1295   case 'i':
1296   case 'o':
1297   case 'c':
1298     printf("}\n");
1299   }
1300 
1301   free (it);
1302 }
1303 #line 1304 "sysinfo.c"
1304     break;
1305 
1306   case 12: /* $@3: %empty  */
1307 #line 178 "sysinfo.y"
1308         {
1309 	  rdepth++;
1310 	  switch (writecode)
1311 	    {
1312 	    case 'c':
1313 	      if (rdepth==1)
1314 	      printf("\tprintf(\"repeat %%d\\n\", %s);\n",(yyvsp[0].s));
1315 	      if (rdepth==2)
1316 	      printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",(yyvsp[0].s));
1317 	      /* Fall through.  */
1318 	    case 'i':
1319 	    case 'g':
1320 	    case 'o':
1321 
1322 	      if (rdepth==1)
1323 		{
1324 	      printf("\t{ int n; for (n = 0; n < %s; n++) {\n",    (yyvsp[0].s));
1325 	    }
1326 	      if (rdepth == 2) {
1327 	      printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n",    (yyvsp[0].s));
1328 	    }
1329 
1330 	      break;
1331 	    }
1332 
1333 	  oldrepeat = repeat;
1334          repeat = (yyvsp[0].s);
1335 	}
1336 #line 1337 "sysinfo.c"
1337     break;
1338 
1339   case 13: /* repeat_it_field: '(' REPEAT NAME $@3 it_field_list ')'  */
1340 #line 209 "sysinfo.y"
1341         {
1342 	  free (repeat);
1343 
1344 	  repeat = oldrepeat;
1345 	  oldrepeat =0;
1346 	  rdepth--;
1347 	  switch (writecode)
1348 	    {
1349 	    case 'i':
1350 	    case 'g':
1351 	    case 'o':
1352 	    case 'c':
1353 	  printf("\t}}\n");
1354 	}
1355 	}
1356 #line 1357 "sysinfo.c"
1357     break;
1358 
1359   case 14: /* $@4: %empty  */
1360 #line 228 "sysinfo.y"
1361         {
1362 	  switch (writecode)
1363 	    {
1364 	    case 'i':
1365 	    case 'g':
1366 	    case 'o':
1367 	    case 'c':
1368 	      printf("\tif (%s) {\n", (yyvsp[0].s));
1369 	      break;
1370 	    }
1371 
1372 	  free ((yyvsp[0].s));
1373 	}
1374 #line 1375 "sysinfo.c"
1375     break;
1376 
1377   case 15: /* cond_it_field: '(' COND NAME $@4 it_field_list ')'  */
1378 #line 243 "sysinfo.y"
1379         {
1380 	  switch (writecode)
1381 	    {
1382 	    case 'i':
1383 	    case 'g':
1384 	    case 'o':
1385 	    case 'c':
1386 	  printf("\t}\n");
1387 	}
1388 	}
1389 #line 1390 "sysinfo.c"
1390     break;
1391 
1392   case 16: /* $@5: %empty  */
1393 #line 257 "sysinfo.y"
1394         {name = (yyvsp[0].s); }
1395 #line 1396 "sysinfo.c"
1396     break;
1397 
1398   case 17: /* it_field: '(' attr_desc '(' attr_type attr_size ')' attr_id $@5 enums ')'  */
1399 #line 259 "sysinfo.y"
1400         {
1401 	  char *desc = (yyvsp[-8].s);
1402 	  char *type = (yyvsp[-6].s);
1403 	  int size = (yyvsp[-5].i);
1404 	  char *id = (yyvsp[-3].s);
1405 char *p = names[rdepth];
1406 char *ptr = pnames[rdepth];
1407 	  switch (writecode)
1408 	    {
1409 	    case 'g':
1410 	      if (size % 8)
1411 		{
1412 
1413 		  printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n",
1414 			 id,
1415 			 names[rdepth], size);
1416 
1417 		}
1418 	      else {
1419 		printf("\twrite%s(ptr->%s%s,raw,&idx,%d,ffile);\n",
1420 		       type,
1421 		       id,
1422 		       names[rdepth],size/8);
1423 		}
1424 	      break;
1425 	    case 'i':
1426 	      {
1427 
1428 		if (rdepth >= 1)
1429 
1430 		  {
1431 		    printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n",
1432 			   id,
1433 			   id,
1434 			   type,
1435 			   repeat,
1436 			   id);
1437 		  }
1438 
1439 		if (rdepth == 2)
1440 		  {
1441 		    printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)xcalloc(%s[n], sizeof(ptr->%s[n][0]));\n",
1442 			   id,
1443 			   id,
1444 			   type,
1445 			   repeat,
1446 			   id);
1447 		  }
1448 
1449 	      }
1450 
1451 	      if (size % 8)
1452 		{
1453 		  printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n",
1454 			 id,
1455 			 names[rdepth],
1456 			 size);
1457 		}
1458 	      else {
1459 		printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n",
1460 		       id,
1461 		       names[rdepth],
1462 		       type,
1463 		       size/8);
1464 		}
1465 	      break;
1466 	    case 'o':
1467 	      printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]);
1468 	      break;
1469 	    case 'd':
1470 	      if (repeat)
1471 		printf("\t/* repeat %s */\n", repeat);
1472 
1473 		  if (type[0] == 'I') {
1474 		  printf("\tint %s%s; \t/* %s */\n",ptr,id, desc);
1475 		}
1476 		  else if (type[0] =='C') {
1477 		  printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc);
1478 		}
1479 	      else {
1480 		printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc);
1481 	      }
1482 		  break;
1483 		case 'c':
1484 	      printf("tabout();\n");
1485 		  printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id);
1486 
1487 		  if (type[0] == 'I')
1488 		  printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p);
1489 		  else   if (type[0] == 'C')
1490 		  printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p);
1491 
1492 		  else   if (type[0] == 'B')
1493 		    {
1494 		  printf("\tpbarray(&ptr->%s%s);\n", id,p);
1495 		}
1496 	      else abort();
1497 		  break;
1498 		}
1499 
1500 	  free (desc);
1501 	  free (id);
1502 	}
1503 #line 1504 "sysinfo.c"
1504     break;
1505 
1506   case 18: /* attr_type: TYPE  */
1507 #line 367 "sysinfo.y"
1508               { (yyval.s) = (yyvsp[0].s); }
1509 #line 1510 "sysinfo.c"
1510     break;
1511 
1512   case 19: /* attr_type: %empty  */
1513 #line 368 "sysinfo.y"
1514            { (yyval.s) = "INT";}
1515 #line 1516 "sysinfo.c"
1516     break;
1517 
1518   case 20: /* attr_desc: '(' NAME ')'  */
1519 #line 373 "sysinfo.y"
1520         { (yyval.s) = (yyvsp[-1].s); }
1521 #line 1522 "sysinfo.c"
1522     break;
1523 
1524   case 21: /* attr_size: NUMBER UNIT  */
1525 #line 378 "sysinfo.y"
1526         { (yyval.i) = (yyvsp[-1].i) * (yyvsp[0].i); }
1527 #line 1528 "sysinfo.c"
1528     break;
1529 
1530   case 22: /* attr_id: '(' NAME ')'  */
1531 #line 383 "sysinfo.y"
1532                                 { (yyval.s) = (yyvsp[-1].s); }
1533 #line 1534 "sysinfo.c"
1534     break;
1535 
1536   case 23: /* attr_id: %empty  */
1537 #line 384 "sysinfo.y"
1538                 { (yyval.s) = strdup ("dummy");}
1539 #line 1540 "sysinfo.c"
1540     break;
1541 
1542   case 27: /* enum_list: enum_list '(' NAME NAME ')'  */
1543 #line 392 "sysinfo.y"
1544                                     {
1545 	  switch (writecode)
1546 	    {
1547 	    case 'd':
1548 	      printf("#define %s %s\n", (yyvsp[-2].s),(yyvsp[-1].s));
1549 	      break;
1550 	    case 'c':
1551 		printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],(yyvsp[-1].s),(yyvsp[-2].s));
1552 	    }
1553 
1554 	  free ((yyvsp[-2].s));
1555 	  free ((yyvsp[-1].s));
1556 	}
1557 #line 1558 "sysinfo.c"
1558     break;
1559 
1560 
1561 #line 1562 "sysinfo.c"
1562 
1563       default: break;
1564     }
1565   /* User semantic actions sometimes alter yychar, and that requires
1566      that yytoken be updated with the new translation.  We take the
1567      approach of translating immediately before every use of yytoken.
1568      One alternative is translating here after every semantic action,
1569      but that translation would be missed if the semantic action invokes
1570      YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1571      if it invokes YYBACKUP.  In the case of YYABORT or YYACCEPT, an
1572      incorrect destructor might then be invoked immediately.  In the
1573      case of YYERROR or YYBACKUP, subsequent parser actions might lead
1574      to an incorrect destructor call or verbose syntax error message
1575      before the lookahead is translated.  */
1576   YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1577 
1578   YYPOPSTACK (yylen);
1579   yylen = 0;
1580 
1581   *++yyvsp = yyval;
1582 
1583   /* Now 'shift' the result of the reduction.  Determine what state
1584      that goes to, based on the state we popped back to and the rule
1585      number reduced by.  */
1586   {
1587     const int yylhs = yyr1[yyn] - YYNTOKENS;
1588     const int yyi = yypgoto[yylhs] + *yyssp;
1589     yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1590                ? yytable[yyi]
1591                : yydefgoto[yylhs]);
1592   }
1593 
1594   goto yynewstate;
1595 
1596 
1597 /*--------------------------------------.
1598 | yyerrlab -- here on detecting error.  |
1599 `--------------------------------------*/
1600 yyerrlab:
1601   /* Make sure we have latest lookahead translation.  See comments at
1602      user semantic actions for why this is necessary.  */
1603   yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1604   /* If not already recovering from an error, report this error.  */
1605   if (!yyerrstatus)
1606     {
1607       ++yynerrs;
1608       yyerror (YY_("syntax error"));
1609     }
1610 
1611   if (yyerrstatus == 3)
1612     {
1613       /* If just tried and failed to reuse lookahead token after an
1614          error, discard it.  */
1615 
1616       if (yychar <= YYEOF)
1617         {
1618           /* Return failure if at end of input.  */
1619           if (yychar == YYEOF)
1620             YYABORT;
1621         }
1622       else
1623         {
1624           yydestruct ("Error: discarding",
1625                       yytoken, &yylval);
1626           yychar = YYEMPTY;
1627         }
1628     }
1629 
1630   /* Else will try to reuse lookahead token after shifting the error
1631      token.  */
1632   goto yyerrlab1;
1633 
1634 
1635 /*---------------------------------------------------.
1636 | yyerrorlab -- error raised explicitly by YYERROR.  |
1637 `---------------------------------------------------*/
1638 yyerrorlab:
1639   /* Pacify compilers when the user code never invokes YYERROR and the
1640      label yyerrorlab therefore never appears in user code.  */
1641   if (0)
1642     YYERROR;
1643   ++yynerrs;
1644 
1645   /* Do not reclaim the symbols of the rule whose action triggered
1646      this YYERROR.  */
1647   YYPOPSTACK (yylen);
1648   yylen = 0;
1649   YY_STACK_PRINT (yyss, yyssp);
1650   yystate = *yyssp;
1651   goto yyerrlab1;
1652 
1653 
1654 /*-------------------------------------------------------------.
1655 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
1656 `-------------------------------------------------------------*/
1657 yyerrlab1:
1658   yyerrstatus = 3;      /* Each real token shifted decrements this.  */
1659 
1660   /* Pop stack until we find a state that shifts the error token.  */
1661   for (;;)
1662     {
1663       yyn = yypact[yystate];
1664       if (!yypact_value_is_default (yyn))
1665         {
1666           yyn += YYSYMBOL_YYerror;
1667           if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1668             {
1669               yyn = yytable[yyn];
1670               if (0 < yyn)
1671                 break;
1672             }
1673         }
1674 
1675       /* Pop the current state because it cannot handle the error token.  */
1676       if (yyssp == yyss)
1677         YYABORT;
1678 
1679 
1680       yydestruct ("Error: popping",
1681                   YY_ACCESSING_SYMBOL (yystate), yyvsp);
1682       YYPOPSTACK (1);
1683       yystate = *yyssp;
1684       YY_STACK_PRINT (yyss, yyssp);
1685     }
1686 
1687   YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1688   *++yyvsp = yylval;
1689   YY_IGNORE_MAYBE_UNINITIALIZED_END
1690 
1691 
1692   /* Shift the error token.  */
1693   YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1694 
1695   yystate = yyn;
1696   goto yynewstate;
1697 
1698 
1699 /*-------------------------------------.
1700 | yyacceptlab -- YYACCEPT comes here.  |
1701 `-------------------------------------*/
1702 yyacceptlab:
1703   yyresult = 0;
1704   goto yyreturnlab;
1705 
1706 
1707 /*-----------------------------------.
1708 | yyabortlab -- YYABORT comes here.  |
1709 `-----------------------------------*/
1710 yyabortlab:
1711   yyresult = 1;
1712   goto yyreturnlab;
1713 
1714 
1715 /*-----------------------------------------------------------.
1716 | yyexhaustedlab -- YYNOMEM (memory exhaustion) comes here.  |
1717 `-----------------------------------------------------------*/
1718 yyexhaustedlab:
1719   yyerror (YY_("memory exhausted"));
1720   yyresult = 2;
1721   goto yyreturnlab;
1722 
1723 
1724 /*----------------------------------------------------------.
1725 | yyreturnlab -- parsing is finished, clean up and return.  |
1726 `----------------------------------------------------------*/
1727 yyreturnlab:
1728   if (yychar != YYEMPTY)
1729     {
1730       /* Make sure we have latest lookahead translation.  See comments at
1731          user semantic actions for why this is necessary.  */
1732       yytoken = YYTRANSLATE (yychar);
1733       yydestruct ("Cleanup: discarding lookahead",
1734                   yytoken, &yylval);
1735     }
1736   /* Do not reclaim the symbols of the rule whose action triggered
1737      this YYABORT or YYACCEPT.  */
1738   YYPOPSTACK (yylen);
1739   YY_STACK_PRINT (yyss, yyssp);
1740   while (yyssp != yyss)
1741     {
1742       yydestruct ("Cleanup: popping",
1743                   YY_ACCESSING_SYMBOL (+*yyssp), yyvsp);
1744       YYPOPSTACK (1);
1745     }
1746 #ifndef yyoverflow
1747   if (yyss != yyssa)
1748     YYSTACK_FREE (yyss);
1749 #endif
1750 
1751   return yyresult;
1752 }
1753 
1754 #line 410 "sysinfo.y"
1755 
1756 /* four modes
1757 
1758    -d write structure definitions for sysroff in host format
1759    -i write functions to swap into sysroff format in
1760    -o write functions to swap into sysroff format out
1761    -c write code to print info in human form */
1762 
1763 int yydebug;
1764 
1765 int
main(int ac,char ** av)1766 main (int ac, char **av)
1767 {
1768   yydebug=0;
1769   if (ac > 1)
1770     writecode = av[1][1];
1771 if (writecode == 'd')
1772   {
1773     printf("typedef struct { unsigned char *data; int len; } barray; \n");
1774     printf("typedef  int INT;\n");
1775     printf("typedef  char * CHARS;\n");
1776 
1777   }
1778   yyparse();
1779 return 0;
1780 }
1781 
1782 static void
yyerror(const char * s)1783 yyerror (const char *s)
1784 {
1785   fprintf(stderr, "%s\n" , s);
1786 }
1787