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