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