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