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 #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 YYCASE_(0, YY_("syntax error")); 944 YYCASE_(1, YY_("syntax error, unexpected %s")); 945 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); 946 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); 947 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); 948 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); 949 # undef YYCASE_ 950 } 951 952 { 953 YYSIZE_T yysize1 = yysize + yystrlen (yyformat); 954 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) 955 return 2; 956 yysize = yysize1; 957 } 958 959 if (*yymsg_alloc < yysize) 960 { 961 *yymsg_alloc = 2 * yysize; 962 if (! (yysize <= *yymsg_alloc 963 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) 964 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; 965 return 1; 966 } 967 968 /* Avoid sprintf, as that infringes on the user's name space. 969 Don't have undefined behavior even if the translation 970 produced a string with the wrong number of "%s"s. */ 971 { 972 char *yyp = *yymsg; 973 int yyi = 0; 974 while ((*yyp = *yyformat) != '\0') 975 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) 976 { 977 yyp += yytnamerr (yyp, yyarg[yyi++]); 978 yyformat += 2; 979 } 980 else 981 { 982 yyp++; 983 yyformat++; 984 } 985 } 986 return 0; 987 } 988 #endif /* YYERROR_VERBOSE */ 989 990 /*-----------------------------------------------. 991 | Release the memory associated to this symbol. | 992 `-----------------------------------------------*/ 993 994 static void 995 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) 996 { 997 YYUSE (yyvaluep); 998 if (!yymsg) 999 yymsg = "Deleting"; 1000 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); 1001 1002 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1003 YYUSE (yytype); 1004 YY_IGNORE_MAYBE_UNINITIALIZED_END 1005 } 1006 1007 1008 1009 1010 /* The lookahead symbol. */ 1011 int yychar; 1012 1013 /* The semantic value of the lookahead symbol. */ 1014 YYSTYPE yylval; 1015 /* Number of syntax errors so far. */ 1016 int yynerrs; 1017 1018 1019 /*----------. 1020 | yyparse. | 1021 `----------*/ 1022 1023 int 1024 yyparse (void) 1025 { 1026 int yystate; 1027 /* Number of tokens to shift before error messages enabled. */ 1028 int yyerrstatus; 1029 1030 /* The stacks and their tools: 1031 'yyss': related to states. 1032 'yyvs': related to semantic values. 1033 1034 Refer to the stacks through separate pointers, to allow yyoverflow 1035 to reallocate them elsewhere. */ 1036 1037 /* The state stack. */ 1038 yytype_int16 yyssa[YYINITDEPTH]; 1039 yytype_int16 *yyss; 1040 yytype_int16 *yyssp; 1041 1042 /* The semantic value stack. */ 1043 YYSTYPE yyvsa[YYINITDEPTH]; 1044 YYSTYPE *yyvs; 1045 YYSTYPE *yyvsp; 1046 1047 YYSIZE_T yystacksize; 1048 1049 int yyn; 1050 int yyresult; 1051 /* Lookahead token as an internal (translated) token number. */ 1052 int yytoken = 0; 1053 /* The variables used to return semantic value and location from the 1054 action routines. */ 1055 YYSTYPE yyval; 1056 1057 #if YYERROR_VERBOSE 1058 /* Buffer for error messages, and its allocated size. */ 1059 char yymsgbuf[128]; 1060 char *yymsg = yymsgbuf; 1061 YYSIZE_T yymsg_alloc = sizeof yymsgbuf; 1062 #endif 1063 1064 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) 1065 1066 /* The number of symbols on the RHS of the reduced rule. 1067 Keep to zero when no symbol should be popped. */ 1068 int yylen = 0; 1069 1070 yyssp = yyss = yyssa; 1071 yyvsp = yyvs = yyvsa; 1072 yystacksize = YYINITDEPTH; 1073 1074 YYDPRINTF ((stderr, "Starting parse\n")); 1075 1076 yystate = 0; 1077 yyerrstatus = 0; 1078 yynerrs = 0; 1079 yychar = YYEMPTY; /* Cause a token to be read. */ 1080 goto yysetstate; 1081 1082 /*------------------------------------------------------------. 1083 | yynewstate -- Push a new state, which is found in yystate. | 1084 `------------------------------------------------------------*/ 1085 yynewstate: 1086 /* In all cases, when you get here, the value and location stacks 1087 have just been pushed. So pushing a state here evens the stacks. */ 1088 yyssp++; 1089 1090 yysetstate: 1091 *yyssp = yystate; 1092 1093 if (yyss + yystacksize - 1 <= yyssp) 1094 { 1095 /* Get the current used size of the three stacks, in elements. */ 1096 YYSIZE_T yysize = yyssp - yyss + 1; 1097 1098 #ifdef yyoverflow 1099 { 1100 /* Give user a chance to reallocate the stack. Use copies of 1101 these so that the &'s don't force the real ones into 1102 memory. */ 1103 YYSTYPE *yyvs1 = yyvs; 1104 yytype_int16 *yyss1 = yyss; 1105 1106 /* Each stack pointer address is followed by the size of the 1107 data in use in that stack, in bytes. This used to be a 1108 conditional around just the two extra args, but that might 1109 be undefined if yyoverflow is a macro. */ 1110 yyoverflow (YY_("memory exhausted"), 1111 &yyss1, yysize * sizeof (*yyssp), 1112 &yyvs1, yysize * sizeof (*yyvsp), 1113 &yystacksize); 1114 1115 yyss = yyss1; 1116 yyvs = yyvs1; 1117 } 1118 #else /* no yyoverflow */ 1119 # ifndef YYSTACK_RELOCATE 1120 goto yyexhaustedlab; 1121 # else 1122 /* Extend the stack our own way. */ 1123 if (YYMAXDEPTH <= yystacksize) 1124 goto yyexhaustedlab; 1125 yystacksize *= 2; 1126 if (YYMAXDEPTH < yystacksize) 1127 yystacksize = YYMAXDEPTH; 1128 1129 { 1130 yytype_int16 *yyss1 = yyss; 1131 union yyalloc *yyptr = 1132 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 1133 if (! yyptr) 1134 goto yyexhaustedlab; 1135 YYSTACK_RELOCATE (yyss_alloc, yyss); 1136 YYSTACK_RELOCATE (yyvs_alloc, yyvs); 1137 # undef YYSTACK_RELOCATE 1138 if (yyss1 != yyssa) 1139 YYSTACK_FREE (yyss1); 1140 } 1141 # endif 1142 #endif /* no yyoverflow */ 1143 1144 yyssp = yyss + yysize - 1; 1145 yyvsp = yyvs + yysize - 1; 1146 1147 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 1148 (unsigned long int) yystacksize)); 1149 1150 if (yyss + yystacksize - 1 <= yyssp) 1151 YYABORT; 1152 } 1153 1154 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 1155 1156 if (yystate == YYFINAL) 1157 YYACCEPT; 1158 1159 goto yybackup; 1160 1161 /*-----------. 1162 | yybackup. | 1163 `-----------*/ 1164 yybackup: 1165 1166 /* Do appropriate processing given the current state. Read a 1167 lookahead token if we need one and don't already have one. */ 1168 1169 /* First try to decide what to do without reference to lookahead token. */ 1170 yyn = yypact[yystate]; 1171 if (yypact_value_is_default (yyn)) 1172 goto yydefault; 1173 1174 /* Not known => get a lookahead token if don't already have one. */ 1175 1176 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 1177 if (yychar == YYEMPTY) 1178 { 1179 YYDPRINTF ((stderr, "Reading a token: ")); 1180 yychar = yylex (); 1181 } 1182 1183 if (yychar <= YYEOF) 1184 { 1185 yychar = yytoken = YYEOF; 1186 YYDPRINTF ((stderr, "Now at end of input.\n")); 1187 } 1188 else 1189 { 1190 yytoken = YYTRANSLATE (yychar); 1191 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc); 1192 } 1193 1194 /* If the proper action on seeing token YYTOKEN is to reduce or to 1195 detect an error, take that action. */ 1196 yyn += yytoken; 1197 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1198 goto yydefault; 1199 yyn = yytable[yyn]; 1200 if (yyn <= 0) 1201 { 1202 if (yytable_value_is_error (yyn)) 1203 goto yyerrlab; 1204 yyn = -yyn; 1205 goto yyreduce; 1206 } 1207 1208 /* Count tokens shifted since error; after three, turn off error 1209 status. */ 1210 if (yyerrstatus) 1211 yyerrstatus--; 1212 1213 /* Shift the lookahead token. */ 1214 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); 1215 1216 /* Discard the shifted token. */ 1217 yychar = YYEMPTY; 1218 1219 yystate = yyn; 1220 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1221 *++yyvsp = yylval; 1222 YY_IGNORE_MAYBE_UNINITIALIZED_END 1223 1224 goto yynewstate; 1225 1226 1227 /*-----------------------------------------------------------. 1228 | yydefault -- do the default action for the current state. | 1229 `-----------------------------------------------------------*/ 1230 yydefault: 1231 yyn = yydefact[yystate]; 1232 if (yyn == 0) 1233 goto yyerrlab; 1234 goto yyreduce; 1235 1236 1237 /*-----------------------------. 1238 | yyreduce -- Do a reduction. | 1239 `-----------------------------*/ 1240 yyreduce: 1241 /* yyn is the number of a rule to reduce with. */ 1242 yylen = yyr2[yyn]; 1243 1244 /* If YYLEN is nonzero, implement the default value of the action: 1245 '$$ = $1'. 1246 1247 Otherwise, the following line sets YYVAL to garbage. 1248 This behavior is undocumented and Bison 1249 users should not rely upon it. Assigning to YYVAL 1250 unconditionally makes the parser a bit smaller, and it avoids a 1251 GCC warning that YYVAL may be used uninitialized. */ 1252 yyval = yyvsp[1-yylen]; 1253 1254 1255 YY_REDUCE_PRINT (yyn); 1256 switch (yyn) 1257 { 1258 case 2: 1259 #line 55 "sysinfo.y" /* yacc.c:1646 */ 1260 { 1261 switch (writecode) 1262 { 1263 case 'i': 1264 printf("#ifdef SYSROFF_SWAP_IN\n"); 1265 break; 1266 case 'p': 1267 printf("#ifdef SYSROFF_p\n"); 1268 break; 1269 case 'd': 1270 break; 1271 case 'g': 1272 printf("#ifdef SYSROFF_SWAP_OUT\n"); 1273 break; 1274 case 'c': 1275 printf("#ifdef SYSROFF_PRINT\n"); 1276 printf("#include <stdio.h>\n"); 1277 printf("#include <stdlib.h>\n"); 1278 printf("#include <ansidecl.h>\n"); 1279 break; 1280 } 1281 } 1282 #line 1283 "sysinfo.c" /* yacc.c:1646 */ 1283 break; 1284 1285 case 3: 1286 #line 77 "sysinfo.y" /* yacc.c:1646 */ 1287 { 1288 switch (writecode) { 1289 case 'i': 1290 case 'p': 1291 case 'g': 1292 case 'c': 1293 printf("#endif\n"); 1294 break; 1295 case 'd': 1296 break; 1297 } 1298 } 1299 #line 1300 "sysinfo.c" /* yacc.c:1646 */ 1300 break; 1301 1302 case 6: 1303 #line 99 "sysinfo.y" /* yacc.c:1646 */ 1304 { 1305 it = (yyvsp[-1].s); code = (yyvsp[0].i); 1306 switch (writecode) 1307 { 1308 case 'd': 1309 printf("\n\n\n#define IT_%s_CODE 0x%x\n", it,code); 1310 printf("struct IT_%s;\n", it); 1311 printf("extern void sysroff_swap_%s_in (struct IT_%s *);\n", 1312 (yyvsp[-1].s), it); 1313 printf("extern void sysroff_swap_%s_out (FILE *, struct IT_%s *);\n", 1314 (yyvsp[-1].s), it); 1315 printf("extern void sysroff_print_%s_out (struct IT_%s *);\n", 1316 (yyvsp[-1].s), it); 1317 printf("struct IT_%s { \n", it); 1318 break; 1319 case 'i': 1320 printf("void sysroff_swap_%s_in (struct IT_%s * ptr)\n",(yyvsp[-1].s),it); 1321 printf("{\n"); 1322 printf("\tunsigned char raw[255];\n"); 1323 printf("\tint idx = 0;\n"); 1324 printf("\tint size;\n"); 1325 printf("\tmemset(raw,0,255);\n"); 1326 printf("\tmemset(ptr,0,sizeof(*ptr));\n"); 1327 printf("\tsize = fillup(raw);\n"); 1328 break; 1329 case 'g': 1330 printf("void sysroff_swap_%s_out (FILE * ffile, struct IT_%s * ptr)\n",(yyvsp[-1].s),it); 1331 printf("{\n"); 1332 printf("\tunsigned char raw[255];\n"); 1333 printf("\tint idx = 16;\n"); 1334 printf("\tmemset (raw, 0, 255);\n"); 1335 printf("\tcode = IT_%s_CODE;\n", it); 1336 break; 1337 case 'o': 1338 printf("void sysroff_swap_%s_out (bfd * abfd, struct IT_%s * ptr)\n",(yyvsp[-1].s), it); 1339 printf("{\n"); 1340 printf("\tint idx = 0;\n"); 1341 break; 1342 case 'c': 1343 printf("void sysroff_print_%s_out (struct IT_%s *ptr)\n",(yyvsp[-1].s),it); 1344 printf("{\n"); 1345 printf("itheader(\"%s\", IT_%s_CODE);\n",(yyvsp[-1].s),(yyvsp[-1].s)); 1346 break; 1347 1348 case 't': 1349 break; 1350 } 1351 1352 } 1353 #line 1354 "sysinfo.c" /* yacc.c:1646 */ 1354 break; 1355 1356 case 7: 1357 #line 150 "sysinfo.y" /* yacc.c:1646 */ 1358 { 1359 switch (writecode) { 1360 case 'd': 1361 printf("};\n"); 1362 break; 1363 case 'g': 1364 printf("\tchecksum(ffile,raw, idx, IT_%s_CODE);\n", it); 1365 /* Fall through. */ 1366 case 'i': 1367 case 'o': 1368 case 'c': 1369 printf("}\n"); 1370 } 1371 1372 free (it); 1373 } 1374 #line 1375 "sysinfo.c" /* yacc.c:1646 */ 1375 break; 1376 1377 case 12: 1378 #line 178 "sysinfo.y" /* yacc.c:1646 */ 1379 { 1380 rdepth++; 1381 switch (writecode) 1382 { 1383 case 'c': 1384 if (rdepth==1) 1385 printf("\tprintf(\"repeat %%d\\n\", %s);\n",(yyvsp[0].s)); 1386 if (rdepth==2) 1387 printf("\tprintf(\"repeat %%d\\n\", %s[n]);\n",(yyvsp[0].s)); 1388 /* Fall through. */ 1389 case 'i': 1390 case 'g': 1391 case 'o': 1392 1393 if (rdepth==1) 1394 { 1395 printf("\t{ int n; for (n = 0; n < %s; n++) {\n", (yyvsp[0].s)); 1396 } 1397 if (rdepth == 2) { 1398 printf("\t{ int m; for (m = 0; m < %s[n]; m++) {\n", (yyvsp[0].s)); 1399 } 1400 1401 break; 1402 } 1403 1404 oldrepeat = repeat; 1405 repeat = (yyvsp[0].s); 1406 } 1407 #line 1408 "sysinfo.c" /* yacc.c:1646 */ 1408 break; 1409 1410 case 13: 1411 #line 209 "sysinfo.y" /* yacc.c:1646 */ 1412 { 1413 free (repeat); 1414 1415 repeat = oldrepeat; 1416 oldrepeat =0; 1417 rdepth--; 1418 switch (writecode) 1419 { 1420 case 'i': 1421 case 'g': 1422 case 'o': 1423 case 'c': 1424 printf("\t}}\n"); 1425 } 1426 } 1427 #line 1428 "sysinfo.c" /* yacc.c:1646 */ 1428 break; 1429 1430 case 14: 1431 #line 228 "sysinfo.y" /* yacc.c:1646 */ 1432 { 1433 switch (writecode) 1434 { 1435 case 'i': 1436 case 'g': 1437 case 'o': 1438 case 'c': 1439 printf("\tif (%s) {\n", (yyvsp[0].s)); 1440 break; 1441 } 1442 1443 free ((yyvsp[0].s)); 1444 } 1445 #line 1446 "sysinfo.c" /* yacc.c:1646 */ 1446 break; 1447 1448 case 15: 1449 #line 243 "sysinfo.y" /* yacc.c:1646 */ 1450 { 1451 switch (writecode) 1452 { 1453 case 'i': 1454 case 'g': 1455 case 'o': 1456 case 'c': 1457 printf("\t}\n"); 1458 } 1459 } 1460 #line 1461 "sysinfo.c" /* yacc.c:1646 */ 1461 break; 1462 1463 case 16: 1464 #line 257 "sysinfo.y" /* yacc.c:1646 */ 1465 {name = (yyvsp[0].s); } 1466 #line 1467 "sysinfo.c" /* yacc.c:1646 */ 1467 break; 1468 1469 case 17: 1470 #line 259 "sysinfo.y" /* yacc.c:1646 */ 1471 { 1472 char *desc = (yyvsp[-8].s); 1473 char *type = (yyvsp[-6].s); 1474 int size = (yyvsp[-5].i); 1475 char *id = (yyvsp[-3].s); 1476 char *p = names[rdepth]; 1477 char *ptr = pnames[rdepth]; 1478 switch (writecode) 1479 { 1480 case 'g': 1481 if (size % 8) 1482 { 1483 1484 printf("\twriteBITS(ptr->%s%s,raw,&idx,%d);\n", 1485 id, 1486 names[rdepth], size); 1487 1488 } 1489 else { 1490 printf("\twrite%s(ptr->%s%s,raw,&idx,%d,ffile);\n", 1491 type, 1492 id, 1493 names[rdepth],size/8); 1494 } 1495 break; 1496 case 'i': 1497 { 1498 1499 if (rdepth >= 1) 1500 1501 { 1502 printf("if (!ptr->%s) ptr->%s = (%s*)xcalloc(%s, sizeof(ptr->%s[0]));\n", 1503 id, 1504 id, 1505 type, 1506 repeat, 1507 id); 1508 } 1509 1510 if (rdepth == 2) 1511 { 1512 printf("if (!ptr->%s[n]) ptr->%s[n] = (%s**)xcalloc(%s[n], sizeof(ptr->%s[n][0]));\n", 1513 id, 1514 id, 1515 type, 1516 repeat, 1517 id); 1518 } 1519 1520 } 1521 1522 if (size % 8) 1523 { 1524 printf("\tptr->%s%s = getBITS(raw,&idx, %d,size);\n", 1525 id, 1526 names[rdepth], 1527 size); 1528 } 1529 else { 1530 printf("\tptr->%s%s = get%s(raw,&idx, %d,size);\n", 1531 id, 1532 names[rdepth], 1533 type, 1534 size/8); 1535 } 1536 break; 1537 case 'o': 1538 printf("\tput%s(raw,%d,%d,&idx,ptr->%s%s);\n", type,size/8,size%8,id,names[rdepth]); 1539 break; 1540 case 'd': 1541 if (repeat) 1542 printf("\t/* repeat %s */\n", repeat); 1543 1544 if (type[0] == 'I') { 1545 printf("\tint %s%s; \t/* %s */\n",ptr,id, desc); 1546 } 1547 else if (type[0] =='C') { 1548 printf("\tchar %s*%s;\t /* %s */\n",ptr,id, desc); 1549 } 1550 else { 1551 printf("\tbarray %s%s;\t /* %s */\n",ptr,id, desc); 1552 } 1553 break; 1554 case 'c': 1555 printf("tabout();\n"); 1556 printf("\tprintf(\"/*%-30s*/ ptr->%s = \");\n", desc, id); 1557 1558 if (type[0] == 'I') 1559 printf("\tprintf(\"%%d\\n\",ptr->%s%s);\n", id,p); 1560 else if (type[0] == 'C') 1561 printf("\tprintf(\"%%s\\n\",ptr->%s%s);\n", id,p); 1562 1563 else if (type[0] == 'B') 1564 { 1565 printf("\tpbarray(&ptr->%s%s);\n", id,p); 1566 } 1567 else abort(); 1568 break; 1569 } 1570 1571 free (desc); 1572 free (id); 1573 } 1574 #line 1575 "sysinfo.c" /* yacc.c:1646 */ 1575 break; 1576 1577 case 18: 1578 #line 367 "sysinfo.y" /* yacc.c:1646 */ 1579 { (yyval.s) = (yyvsp[0].s); } 1580 #line 1581 "sysinfo.c" /* yacc.c:1646 */ 1581 break; 1582 1583 case 19: 1584 #line 368 "sysinfo.y" /* yacc.c:1646 */ 1585 { (yyval.s) = "INT";} 1586 #line 1587 "sysinfo.c" /* yacc.c:1646 */ 1587 break; 1588 1589 case 20: 1590 #line 373 "sysinfo.y" /* yacc.c:1646 */ 1591 { (yyval.s) = (yyvsp[-1].s); } 1592 #line 1593 "sysinfo.c" /* yacc.c:1646 */ 1593 break; 1594 1595 case 21: 1596 #line 378 "sysinfo.y" /* yacc.c:1646 */ 1597 { (yyval.i) = (yyvsp[-1].i) * (yyvsp[0].i); } 1598 #line 1599 "sysinfo.c" /* yacc.c:1646 */ 1599 break; 1600 1601 case 22: 1602 #line 383 "sysinfo.y" /* yacc.c:1646 */ 1603 { (yyval.s) = (yyvsp[-1].s); } 1604 #line 1605 "sysinfo.c" /* yacc.c:1646 */ 1605 break; 1606 1607 case 23: 1608 #line 384 "sysinfo.y" /* yacc.c:1646 */ 1609 { (yyval.s) = strdup ("dummy");} 1610 #line 1611 "sysinfo.c" /* yacc.c:1646 */ 1611 break; 1612 1613 case 27: 1614 #line 392 "sysinfo.y" /* yacc.c:1646 */ 1615 { 1616 switch (writecode) 1617 { 1618 case 'd': 1619 printf("#define %s %s\n", (yyvsp[-2].s),(yyvsp[-1].s)); 1620 break; 1621 case 'c': 1622 printf("if (ptr->%s%s == %s) { tabout(); printf(\"%s\\n\");}\n", name, names[rdepth],(yyvsp[-1].s),(yyvsp[-2].s)); 1623 } 1624 1625 free ((yyvsp[-2].s)); 1626 free ((yyvsp[-1].s)); 1627 } 1628 #line 1629 "sysinfo.c" /* yacc.c:1646 */ 1629 break; 1630 1631 1632 #line 1633 "sysinfo.c" /* yacc.c:1646 */ 1633 default: break; 1634 } 1635 /* User semantic actions sometimes alter yychar, and that requires 1636 that yytoken be updated with the new translation. We take the 1637 approach of translating immediately before every use of yytoken. 1638 One alternative is translating here after every semantic action, 1639 but that translation would be missed if the semantic action invokes 1640 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or 1641 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an 1642 incorrect destructor might then be invoked immediately. In the 1643 case of YYERROR or YYBACKUP, subsequent parser actions might lead 1644 to an incorrect destructor call or verbose syntax error message 1645 before the lookahead is translated. */ 1646 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 1647 1648 YYPOPSTACK (yylen); 1649 yylen = 0; 1650 YY_STACK_PRINT (yyss, yyssp); 1651 1652 *++yyvsp = yyval; 1653 1654 /* Now 'shift' the result of the reduction. Determine what state 1655 that goes to, based on the state we popped back to and the rule 1656 number reduced by. */ 1657 1658 yyn = yyr1[yyn]; 1659 1660 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 1661 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1662 yystate = yytable[yystate]; 1663 else 1664 yystate = yydefgoto[yyn - YYNTOKENS]; 1665 1666 goto yynewstate; 1667 1668 1669 /*--------------------------------------. 1670 | yyerrlab -- here on detecting error. | 1671 `--------------------------------------*/ 1672 yyerrlab: 1673 /* Make sure we have latest lookahead translation. See comments at 1674 user semantic actions for why this is necessary. */ 1675 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); 1676 1677 /* If not already recovering from an error, report this error. */ 1678 if (!yyerrstatus) 1679 { 1680 ++yynerrs; 1681 #if ! YYERROR_VERBOSE 1682 yyerror (YY_("syntax error")); 1683 #else 1684 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ 1685 yyssp, yytoken) 1686 { 1687 char const *yymsgp = YY_("syntax error"); 1688 int yysyntax_error_status; 1689 yysyntax_error_status = YYSYNTAX_ERROR; 1690 if (yysyntax_error_status == 0) 1691 yymsgp = yymsg; 1692 else if (yysyntax_error_status == 1) 1693 { 1694 if (yymsg != yymsgbuf) 1695 YYSTACK_FREE (yymsg); 1696 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); 1697 if (!yymsg) 1698 { 1699 yymsg = yymsgbuf; 1700 yymsg_alloc = sizeof yymsgbuf; 1701 yysyntax_error_status = 2; 1702 } 1703 else 1704 { 1705 yysyntax_error_status = YYSYNTAX_ERROR; 1706 yymsgp = yymsg; 1707 } 1708 } 1709 yyerror (yymsgp); 1710 if (yysyntax_error_status == 2) 1711 goto yyexhaustedlab; 1712 } 1713 # undef YYSYNTAX_ERROR 1714 #endif 1715 } 1716 1717 1718 1719 if (yyerrstatus == 3) 1720 { 1721 /* If just tried and failed to reuse lookahead token after an 1722 error, discard it. */ 1723 1724 if (yychar <= YYEOF) 1725 { 1726 /* Return failure if at end of input. */ 1727 if (yychar == YYEOF) 1728 YYABORT; 1729 } 1730 else 1731 { 1732 yydestruct ("Error: discarding", 1733 yytoken, &yylval); 1734 yychar = YYEMPTY; 1735 } 1736 } 1737 1738 /* Else will try to reuse lookahead token after shifting the error 1739 token. */ 1740 goto yyerrlab1; 1741 1742 1743 /*---------------------------------------------------. 1744 | yyerrorlab -- error raised explicitly by YYERROR. | 1745 `---------------------------------------------------*/ 1746 yyerrorlab: 1747 1748 /* Pacify compilers like GCC when the user code never invokes 1749 YYERROR and the label yyerrorlab therefore never appears in user 1750 code. */ 1751 if (/*CONSTCOND*/ 0) 1752 goto yyerrorlab; 1753 1754 /* Do not reclaim the symbols of the rule whose action triggered 1755 this YYERROR. */ 1756 YYPOPSTACK (yylen); 1757 yylen = 0; 1758 YY_STACK_PRINT (yyss, yyssp); 1759 yystate = *yyssp; 1760 goto yyerrlab1; 1761 1762 1763 /*-------------------------------------------------------------. 1764 | yyerrlab1 -- common code for both syntax error and YYERROR. | 1765 `-------------------------------------------------------------*/ 1766 yyerrlab1: 1767 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1768 1769 for (;;) 1770 { 1771 yyn = yypact[yystate]; 1772 if (!yypact_value_is_default (yyn)) 1773 { 1774 yyn += YYTERROR; 1775 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 1776 { 1777 yyn = yytable[yyn]; 1778 if (0 < yyn) 1779 break; 1780 } 1781 } 1782 1783 /* Pop the current state because it cannot handle the error token. */ 1784 if (yyssp == yyss) 1785 YYABORT; 1786 1787 1788 yydestruct ("Error: popping", 1789 yystos[yystate], yyvsp); 1790 YYPOPSTACK (1); 1791 yystate = *yyssp; 1792 YY_STACK_PRINT (yyss, yyssp); 1793 } 1794 1795 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN 1796 *++yyvsp = yylval; 1797 YY_IGNORE_MAYBE_UNINITIALIZED_END 1798 1799 1800 /* Shift the error token. */ 1801 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); 1802 1803 yystate = yyn; 1804 goto yynewstate; 1805 1806 1807 /*-------------------------------------. 1808 | yyacceptlab -- YYACCEPT comes here. | 1809 `-------------------------------------*/ 1810 yyacceptlab: 1811 yyresult = 0; 1812 goto yyreturn; 1813 1814 /*-----------------------------------. 1815 | yyabortlab -- YYABORT comes here. | 1816 `-----------------------------------*/ 1817 yyabortlab: 1818 yyresult = 1; 1819 goto yyreturn; 1820 1821 #if !defined yyoverflow || YYERROR_VERBOSE 1822 /*-------------------------------------------------. 1823 | yyexhaustedlab -- memory exhaustion comes here. | 1824 `-------------------------------------------------*/ 1825 yyexhaustedlab: 1826 yyerror (YY_("memory exhausted")); 1827 yyresult = 2; 1828 /* Fall through. */ 1829 #endif 1830 1831 yyreturn: 1832 if (yychar != YYEMPTY) 1833 { 1834 /* Make sure we have latest lookahead translation. See comments at 1835 user semantic actions for why this is necessary. */ 1836 yytoken = YYTRANSLATE (yychar); 1837 yydestruct ("Cleanup: discarding lookahead", 1838 yytoken, &yylval); 1839 } 1840 /* Do not reclaim the symbols of the rule whose action triggered 1841 this YYABORT or YYACCEPT. */ 1842 YYPOPSTACK (yylen); 1843 YY_STACK_PRINT (yyss, yyssp); 1844 while (yyssp != yyss) 1845 { 1846 yydestruct ("Cleanup: popping", 1847 yystos[*yyssp], yyvsp); 1848 YYPOPSTACK (1); 1849 } 1850 #ifndef yyoverflow 1851 if (yyss != yyssa) 1852 YYSTACK_FREE (yyss); 1853 #endif 1854 #if YYERROR_VERBOSE 1855 if (yymsg != yymsgbuf) 1856 YYSTACK_FREE (yymsg); 1857 #endif 1858 return yyresult; 1859 } 1860 #line 410 "sysinfo.y" /* yacc.c:1906 */ 1861 1862 /* four modes 1863 1864 -d write structure definitions for sysroff in host format 1865 -i write functions to swap into sysroff format in 1866 -o write functions to swap into sysroff format out 1867 -c write code to print info in human form */ 1868 1869 int yydebug; 1870 1871 int 1872 main (int ac, char **av) 1873 { 1874 yydebug=0; 1875 if (ac > 1) 1876 writecode = av[1][1]; 1877 if (writecode == 'd') 1878 { 1879 printf("typedef struct { unsigned char *data; int len; } barray; \n"); 1880 printf("typedef int INT;\n"); 1881 printf("typedef char * CHARS;\n"); 1882 1883 } 1884 yyparse(); 1885 return 0; 1886 } 1887 1888 static int 1889 yyerror (char *s) 1890 { 1891 fprintf(stderr, "%s\n" , s); 1892 return 0; 1893 } 1894