1/* A Bison parser, made by GNU Bison 1.875c. */ 2 3/* Skeleton parser for Yacc-like parsing with Bison, 4 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003 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., 59 Temple Place - Suite 330, 19 Boston, MA 02111-1307, 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/* Skeleton name. */ 40#define YYSKELETON_NAME "yacc.c" 41 42/* Pure parsers. */ 43#define YYPURE 0 44 45/* Using locations. */ 46#define YYLSP_NEEDED 0 47 48 49 50/* Tokens. */ 51#ifndef YYTOKENTYPE 52# define YYTOKENTYPE 53 /* Put the tokens into the symbol table, so that GDB and other debuggers 54 know about them. */ 55 enum yytokentype { 56 NEWLINE = 258, 57 VERBOSE = 259, 58 FILENAME = 260, 59 ADDLIB = 261, 60 LIST = 262, 61 ADDMOD = 263, 62 CLEAR = 264, 63 CREATE = 265, 64 DELETE = 266, 65 DIRECTORY = 267, 66 END = 268, 67 EXTRACT = 269, 68 FULLDIR = 270, 69 HELP = 271, 70 QUIT = 272, 71 REPLACE = 273, 72 SAVE = 274, 73 OPEN = 275 74 }; 75#endif 76#define NEWLINE 258 77#define VERBOSE 259 78#define FILENAME 260 79#define ADDLIB 261 80#define LIST 262 81#define ADDMOD 263 82#define CLEAR 264 83#define CREATE 265 84#define DELETE 266 85#define DIRECTORY 267 86#define END 268 87#define EXTRACT 269 88#define FULLDIR 270 89#define HELP 271 90#define QUIT 272 91#define REPLACE 273 92#define SAVE 274 93#define OPEN 275 94 95 96 97 98/* Copy the first part of user declarations. */ 99#line 1 "arparse.y" 100 101/* arparse.y - Stange script language parser */ 102 103/* Copyright 1992, 1993, 1995, 1997, 1999, 2002, 2003 104 Free Software Foundation, Inc. 105 106This file is part of GNU Binutils. 107 108This program is free software; you can redistribute it and/or modify 109it under the terms of the GNU General Public License as published by 110the Free Software Foundation; either version 2 of the License, or 111(at your option) any later version. 112 113This program is distributed in the hope that it will be useful, 114but WITHOUT ANY WARRANTY; without even the implied warranty of 115MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 116GNU General Public License for more details. 117 118You should have received a copy of the GNU General Public License 119along with this program; if not, write to the Free Software 120Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 121 122 123/* Contributed by Steve Chamberlain 124 sac@cygnus.com 125 126*/ 127#define DONTDECLARE_MALLOC 128#include "bfd.h" 129#include "bucomm.h" 130#include "arsup.h" 131extern int verbose; 132extern int yylex (void); 133static int yyerror (const char *); 134 135 136/* Enabling traces. */ 137#ifndef YYDEBUG 138# define YYDEBUG 0 139#endif 140 141/* Enabling verbose error messages. */ 142#ifdef YYERROR_VERBOSE 143# undef YYERROR_VERBOSE 144# define YYERROR_VERBOSE 1 145#else 146# define YYERROR_VERBOSE 0 147#endif 148 149#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) 150#line 37 "arparse.y" 151typedef union YYSTYPE { 152 char *name; 153struct list *list ; 154 155} YYSTYPE; 156/* Line 191 of yacc.c. */ 157#line 158 "arparse.c" 158# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 159# define YYSTYPE_IS_DECLARED 1 160# define YYSTYPE_IS_TRIVIAL 1 161#endif 162 163 164 165/* Copy the second part of user declarations. */ 166 167 168/* Line 214 of yacc.c. */ 169#line 170 "arparse.c" 170 171#if ! defined (yyoverflow) || YYERROR_VERBOSE 172 173# ifndef YYFREE 174# define YYFREE free 175# endif 176# ifndef YYMALLOC 177# define YYMALLOC malloc 178# endif 179 180/* The parser invokes alloca or malloc; define the necessary symbols. */ 181 182# ifdef YYSTACK_USE_ALLOCA 183# if YYSTACK_USE_ALLOCA 184# define YYSTACK_ALLOC alloca 185# endif 186# else 187# if defined (alloca) || defined (_ALLOCA_H) 188# define YYSTACK_ALLOC alloca 189# else 190# ifdef __GNUC__ 191# define YYSTACK_ALLOC __builtin_alloca 192# endif 193# endif 194# endif 195 196# ifdef YYSTACK_ALLOC 197 /* Pacify GCC's `empty if-body' warning. */ 198# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) 199# else 200# if defined (__STDC__) || defined (__cplusplus) 201# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 202# define YYSIZE_T size_t 203# endif 204# define YYSTACK_ALLOC YYMALLOC 205# define YYSTACK_FREE YYFREE 206# endif 207#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ 208 209 210#if (! defined (yyoverflow) \ 211 && (! defined (__cplusplus) \ 212 || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) 213 214/* A type that is properly aligned for any stack member. */ 215union yyalloc 216{ 217 short yyss; 218 YYSTYPE yyvs; 219 }; 220 221/* The size of the maximum gap between one aligned stack and the next. */ 222# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1) 223 224/* The size of an array large to enough to hold all stacks, each with 225 N elements. */ 226# define YYSTACK_BYTES(N) \ 227 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \ 228 + YYSTACK_GAP_MAXIMUM) 229 230/* Copy COUNT objects from FROM to TO. The source and destination do 231 not overlap. */ 232# ifndef YYCOPY 233# if defined (__GNUC__) && 1 < __GNUC__ 234# define YYCOPY(To, From, Count) \ 235 __builtin_memcpy (To, From, (Count) * sizeof (*(From))) 236# else 237# define YYCOPY(To, From, Count) \ 238 do \ 239 { \ 240 register YYSIZE_T yyi; \ 241 for (yyi = 0; yyi < (Count); yyi++) \ 242 (To)[yyi] = (From)[yyi]; \ 243 } \ 244 while (0) 245# endif 246# endif 247 248/* Relocate STACK from its old location to the new one. The 249 local variables YYSIZE and YYSTACKSIZE give the old and new number of 250 elements in the stack, and YYPTR gives the new location of the 251 stack. Advance YYPTR to a properly aligned location for the next 252 stack. */ 253# define YYSTACK_RELOCATE(Stack) \ 254 do \ 255 { \ 256 YYSIZE_T yynewbytes; \ 257 YYCOPY (&yyptr->Stack, Stack, yysize); \ 258 Stack = &yyptr->Stack; \ 259 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ 260 yyptr += yynewbytes / sizeof (*yyptr); \ 261 } \ 262 while (0) 263 264#endif 265 266#if defined (__STDC__) || defined (__cplusplus) 267 typedef signed char yysigned_char; 268#else 269 typedef short yysigned_char; 270#endif 271 272/* YYFINAL -- State number of the termination state. */ 273#define YYFINAL 3 274/* YYLAST -- Last index in YYTABLE. */ 275#define YYLAST 34 276 277/* YYNTOKENS -- Number of terminals. */ 278#define YYNTOKENS 24 279/* YYNNTS -- Number of nonterminals. */ 280#define YYNNTS 22 281/* YYNRULES -- Number of rules. */ 282#define YYNRULES 42 283/* YYNRULES -- Number of states. */ 284#define YYNSTATES 53 285 286/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ 287#define YYUNDEFTOK 2 288#define YYMAXUTOK 275 289 290#define YYTRANSLATE(YYX) \ 291 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) 292 293/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ 294static const unsigned char yytranslate[] = 295{ 296 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 297 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 298 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 299 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 300 21, 22, 2, 2, 23, 2, 2, 2, 2, 2, 301 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 302 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 303 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 304 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 305 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 306 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 307 2, 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 2, 2, 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, 1, 2, 3, 4, 322 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 323 15, 16, 17, 18, 19, 20 324}; 325 326#if YYDEBUG 327/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in 328 YYRHS. */ 329static const unsigned char yyprhs[] = 330{ 331 0, 0, 3, 4, 7, 10, 11, 14, 16, 18, 332 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 333 40, 42, 44, 45, 48, 51, 53, 56, 59, 61, 334 63, 66, 69, 73, 78, 80, 81, 85, 86, 90, 335 91, 93, 94 336}; 337 338/* YYRHS -- A `-1'-separated list of the rules' RHS. */ 339static const yysigned_char yyrhs[] = 340{ 341 25, 0, -1, -1, 26, 27, -1, 27, 28, -1, 342 -1, 29, 3, -1, 37, -1, 38, -1, 45, -1, 343 40, -1, 39, -1, 32, -1, 34, -1, 36, -1, 344 30, -1, 31, -1, 33, -1, 35, -1, 13, -1, 345 1, -1, 5, -1, -1, 14, 43, -1, 18, 43, 346 -1, 9, -1, 11, 43, -1, 8, 43, -1, 7, 347 -1, 19, -1, 20, 5, -1, 10, 5, -1, 6, 348 5, 42, -1, 12, 5, 42, 41, -1, 5, -1, 349 -1, 21, 43, 22, -1, -1, 43, 44, 5, -1, 350 -1, 23, -1, -1, 4, -1 351}; 352 353/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 354static const unsigned char yyrline[] = 355{ 356 0, 68, 68, 68, 72, 73, 77, 81, 82, 83, 357 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 358 94, 95, 96, 101, 106, 111, 116, 120, 125, 130, 359 137, 142, 148, 152, 159, 161, 165, 168, 172, 178, 360 183, 184, 189 361}; 362#endif 363 364#if YYDEBUG || YYERROR_VERBOSE 365/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. 366 First, the terminals, then, starting at YYNTOKENS, nonterminals. */ 367static const char *const yytname[] = 368{ 369 "$end", "error", "$undefined", "NEWLINE", "VERBOSE", "FILENAME", 370 "ADDLIB", "LIST", "ADDMOD", "CLEAR", "CREATE", "DELETE", "DIRECTORY", 371 "END", "EXTRACT", "FULLDIR", "HELP", "QUIT", "REPLACE", "SAVE", "OPEN", 372 "'('", "')'", "','", "$accept", "start", "@1", "session", "command_line", 373 "command", "extract_command", "replace_command", "clear_command", 374 "delete_command", "addmod_command", "list_command", "save_command", 375 "open_command", "create_command", "addlib_command", "directory_command", 376 "optional_filename", "modulelist", "modulename", "optcomma", 377 "verbose_command", 0 378}; 379#endif 380 381# ifdef YYPRINT 382/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to 383 token YYLEX-NUM. */ 384static const unsigned short yytoknum[] = 385{ 386 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 387 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 388 275, 40, 41, 44 389}; 390# endif 391 392/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ 393static const unsigned char yyr1[] = 394{ 395 0, 24, 26, 25, 27, 27, 28, 29, 29, 29, 396 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 397 29, 29, 29, 30, 31, 32, 33, 34, 35, 36, 398 37, 38, 39, 40, 41, 41, 42, 42, 43, 43, 399 44, 44, 45 400}; 401 402/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ 403static const unsigned char yyr2[] = 404{ 405 0, 2, 0, 2, 2, 0, 2, 1, 1, 1, 406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 407 1, 1, 0, 2, 2, 1, 2, 2, 1, 1, 408 2, 2, 3, 4, 1, 0, 3, 0, 3, 0, 409 1, 0, 1 410}; 411 412/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 413 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 414 means the default is an error. */ 415static const unsigned char yydefact[] = 416{ 417 2, 0, 5, 1, 0, 20, 42, 21, 0, 28, 418 39, 25, 0, 39, 0, 19, 39, 39, 29, 0, 419 4, 0, 15, 16, 12, 17, 13, 18, 14, 7, 420 8, 11, 10, 9, 37, 27, 31, 26, 37, 23, 421 24, 30, 6, 39, 32, 40, 0, 35, 41, 38, 422 34, 33, 36 423}; 424 425/* YYDEFGOTO[NTERM-NUM]. */ 426static const yysigned_char yydefgoto[] = 427{ 428 -1, 1, 2, 4, 20, 21, 22, 23, 24, 25, 429 26, 27, 28, 29, 30, 31, 32, 51, 44, 35, 430 46, 33 431}; 432 433/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing 434 STATE-NUM. */ 435#define YYPACT_NINF -14 436static const yysigned_char yypact[] = 437{ 438 -14, 1, -14, -14, 5, -14, -14, -14, 2, -14, 439 -14, -14, 21, -14, 22, -14, -14, -14, -14, 23, 440 -14, 26, -14, -14, -14, -14, -14, -14, -14, -14, 441 -14, -14, -14, -14, 10, -3, -14, -3, 10, -3, 442 -3, -14, -14, -14, -14, -14, 27, 28, -1, -14, 443 -14, -14, -14 444}; 445 446/* YYPGOTO[NTERM-NUM]. */ 447static const yysigned_char yypgoto[] = 448{ 449 -14, -14, -14, -14, -14, -14, -14, -14, -14, -14, 450 -14, -14, -14, -14, -14, -14, -14, -14, -4, -13, 451 -14, -14 452}; 453 454/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 455 positive, shift that token. If negative, reduce the rule which 456 number is the opposite. If zero, do what YYDEFACT says. 457 If YYTABLE_NINF, syntax error. */ 458#define YYTABLE_NINF -42 459static const yysigned_char yytable[] = 460{ 461 37, 3, -41, 39, 40, -3, 5, 34, -22, 6, 462 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 463 45, 52, 45, 17, 18, 19, 36, 38, 41, 42, 464 48, 43, 49, 50, 47 465}; 466 467static const unsigned char yycheck[] = 468{ 469 13, 0, 5, 16, 17, 0, 1, 5, 3, 4, 470 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 471 23, 22, 23, 18, 19, 20, 5, 5, 5, 3, 472 43, 21, 5, 5, 38 473}; 474 475/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing 476 symbol of state STATE-NUM. */ 477static const unsigned char yystos[] = 478{ 479 0, 25, 26, 0, 27, 1, 4, 5, 6, 7, 480 8, 9, 10, 11, 12, 13, 14, 18, 19, 20, 481 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 482 38, 39, 40, 45, 5, 43, 5, 43, 5, 43, 483 43, 5, 3, 21, 42, 23, 44, 42, 43, 5, 484 5, 41, 22 485}; 486 487#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) 488# define YYSIZE_T __SIZE_TYPE__ 489#endif 490#if ! defined (YYSIZE_T) && defined (size_t) 491# define YYSIZE_T size_t 492#endif 493#if ! defined (YYSIZE_T) 494# if defined (__STDC__) || defined (__cplusplus) 495# include <stddef.h> /* INFRINGES ON USER NAME SPACE */ 496# define YYSIZE_T size_t 497# endif 498#endif 499#if ! defined (YYSIZE_T) 500# define YYSIZE_T unsigned int 501#endif 502 503#define yyerrok (yyerrstatus = 0) 504#define yyclearin (yychar = YYEMPTY) 505#define YYEMPTY (-2) 506#define YYEOF 0 507 508#define YYACCEPT goto yyacceptlab 509#define YYABORT goto yyabortlab 510#define YYERROR goto yyerrorlab 511 512 513/* Like YYERROR except do call yyerror. This remains here temporarily 514 to ease the transition to the new meaning of YYERROR, for GCC. 515 Once GCC version 2 has supplanted version 1, this can go. */ 516 517#define YYFAIL goto yyerrlab 518 519#define YYRECOVERING() (!!yyerrstatus) 520 521#define YYBACKUP(Token, Value) \ 522do \ 523 if (yychar == YYEMPTY && yylen == 1) \ 524 { \ 525 yychar = (Token); \ 526 yylval = (Value); \ 527 yytoken = YYTRANSLATE (yychar); \ 528 YYPOPSTACK; \ 529 goto yybackup; \ 530 } \ 531 else \ 532 { \ 533 yyerror ("syntax error: cannot back up");\ 534 YYERROR; \ 535 } \ 536while (0) 537 538#define YYTERROR 1 539#define YYERRCODE 256 540 541/* YYLLOC_DEFAULT -- Compute the default location (before the actions 542 are run). */ 543 544#ifndef YYLLOC_DEFAULT 545# define YYLLOC_DEFAULT(Current, Rhs, N) \ 546 ((Current).first_line = (Rhs)[1].first_line, \ 547 (Current).first_column = (Rhs)[1].first_column, \ 548 (Current).last_line = (Rhs)[N].last_line, \ 549 (Current).last_column = (Rhs)[N].last_column) 550#endif 551 552/* YYLEX -- calling `yylex' with the right arguments. */ 553 554#ifdef YYLEX_PARAM 555# define YYLEX yylex (YYLEX_PARAM) 556#else 557# define YYLEX yylex () 558#endif 559 560/* Enable debugging if requested. */ 561#if YYDEBUG 562 563# ifndef YYFPRINTF 564# include <stdio.h> /* INFRINGES ON USER NAME SPACE */ 565# define YYFPRINTF fprintf 566# endif 567 568# define YYDPRINTF(Args) \ 569do { \ 570 if (yydebug) \ 571 YYFPRINTF Args; \ 572} while (0) 573 574# define YYDSYMPRINT(Args) \ 575do { \ 576 if (yydebug) \ 577 yysymprint Args; \ 578} while (0) 579 580# define YYDSYMPRINTF(Title, Token, Value, Location) \ 581do { \ 582 if (yydebug) \ 583 { \ 584 YYFPRINTF (stderr, "%s ", Title); \ 585 yysymprint (stderr, \ 586 Token, Value); \ 587 YYFPRINTF (stderr, "\n"); \ 588 } \ 589} while (0) 590 591/*------------------------------------------------------------------. 592| yy_stack_print -- Print the state stack from its BOTTOM up to its | 593| TOP (included). | 594`------------------------------------------------------------------*/ 595 596#if defined (__STDC__) || defined (__cplusplus) 597static void 598yy_stack_print (short *bottom, short *top) 599#else 600static void 601yy_stack_print (bottom, top) 602 short *bottom; 603 short *top; 604#endif 605{ 606 YYFPRINTF (stderr, "Stack now"); 607 for (/* Nothing. */; bottom <= top; ++bottom) 608 YYFPRINTF (stderr, " %d", *bottom); 609 YYFPRINTF (stderr, "\n"); 610} 611 612# define YY_STACK_PRINT(Bottom, Top) \ 613do { \ 614 if (yydebug) \ 615 yy_stack_print ((Bottom), (Top)); \ 616} while (0) 617 618 619/*------------------------------------------------. 620| Report that the YYRULE is going to be reduced. | 621`------------------------------------------------*/ 622 623#if defined (__STDC__) || defined (__cplusplus) 624static void 625yy_reduce_print (int yyrule) 626#else 627static void 628yy_reduce_print (yyrule) 629 int yyrule; 630#endif 631{ 632 int yyi; 633 unsigned int yylno = yyrline[yyrule]; 634 YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ", 635 yyrule - 1, yylno); 636 /* Print the symbols being reduced, and their result. */ 637 for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) 638 YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]); 639 YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]); 640} 641 642# define YY_REDUCE_PRINT(Rule) \ 643do { \ 644 if (yydebug) \ 645 yy_reduce_print (Rule); \ 646} while (0) 647 648/* Nonzero means print parse trace. It is left uninitialized so that 649 multiple parsers can coexist. */ 650int yydebug; 651#else /* !YYDEBUG */ 652# define YYDPRINTF(Args) 653# define YYDSYMPRINT(Args) 654# define YYDSYMPRINTF(Title, Token, Value, Location) 655# define YY_STACK_PRINT(Bottom, Top) 656# define YY_REDUCE_PRINT(Rule) 657#endif /* !YYDEBUG */ 658 659 660/* YYINITDEPTH -- initial size of the parser's stacks. */ 661#ifndef YYINITDEPTH 662# define YYINITDEPTH 200 663#endif 664 665/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only 666 if the built-in stack extension method is used). 667 668 Do not make this value too large; the results are undefined if 669 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH) 670 evaluated with infinite-precision integer arithmetic. */ 671 672#if defined (YYMAXDEPTH) && YYMAXDEPTH == 0 673# undef YYMAXDEPTH 674#endif 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. */ 689static YYSIZE_T 690# if defined (__STDC__) || defined (__cplusplus) 691yystrlen (const char *yystr) 692# else 693yystrlen (yystr) 694 const char *yystr; 695# endif 696{ 697 register 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. */ 713static char * 714# if defined (__STDC__) || defined (__cplusplus) 715yystpcpy (char *yydest, const char *yysrc) 716# else 717yystpcpy (yydest, yysrc) 718 char *yydest; 719 const char *yysrc; 720# endif 721{ 722 register char *yyd = yydest; 723 register const char *yys = yysrc; 724 725 while ((*yyd++ = *yys++) != '\0') 726 continue; 727 728 return yyd - 1; 729} 730# endif 731# endif 732 733#endif /* !YYERROR_VERBOSE */ 734 735 736 737#if YYDEBUG 738/*--------------------------------. 739| Print this symbol on YYOUTPUT. | 740`--------------------------------*/ 741 742#if defined (__STDC__) || defined (__cplusplus) 743static void 744yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) 745#else 746static void 747yysymprint (yyoutput, yytype, yyvaluep) 748 FILE *yyoutput; 749 int yytype; 750 YYSTYPE *yyvaluep; 751#endif 752{ 753 /* Pacify ``unused variable'' warnings. */ 754 (void) yyvaluep; 755 756 if (yytype < YYNTOKENS) 757 { 758 YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); 759# ifdef YYPRINT 760 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); 761# endif 762 } 763 else 764 YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); 765 766 switch (yytype) 767 { 768 default: 769 break; 770 } 771 YYFPRINTF (yyoutput, ")"); 772} 773 774#endif /* ! YYDEBUG */ 775/*-----------------------------------------------. 776| Release the memory associated to this symbol. | 777`-----------------------------------------------*/ 778 779#if defined (__STDC__) || defined (__cplusplus) 780static void 781yydestruct (int yytype, YYSTYPE *yyvaluep) 782#else 783static void 784yydestruct (yytype, yyvaluep) 785 int yytype; 786 YYSTYPE *yyvaluep; 787#endif 788{ 789 /* Pacify ``unused variable'' warnings. */ 790 (void) yyvaluep; 791 792 switch (yytype) 793 { 794 795 default: 796 break; 797 } 798} 799 800 801/* Prevent warnings from -Wmissing-prototypes. */ 802 803#ifdef YYPARSE_PARAM 804# if defined (__STDC__) || defined (__cplusplus) 805int yyparse (void *YYPARSE_PARAM); 806# else 807int yyparse (); 808# endif 809#else /* ! YYPARSE_PARAM */ 810#if defined (__STDC__) || defined (__cplusplus) 811int yyparse (void); 812#else 813int yyparse (); 814#endif 815#endif /* ! YYPARSE_PARAM */ 816 817 818 819/* The lookahead symbol. */ 820int yychar; 821 822/* The semantic value of the lookahead symbol. */ 823YYSTYPE yylval; 824 825/* Number of syntax errors so far. */ 826int yynerrs; 827 828 829 830/*----------. 831| yyparse. | 832`----------*/ 833 834#ifdef YYPARSE_PARAM 835# if defined (__STDC__) || defined (__cplusplus) 836int yyparse (void *YYPARSE_PARAM) 837# else 838int yyparse (YYPARSE_PARAM) 839 void *YYPARSE_PARAM; 840# endif 841#else /* ! YYPARSE_PARAM */ 842#if defined (__STDC__) || defined (__cplusplus) 843int 844yyparse (void) 845#else 846int 847yyparse () 848 849#endif 850#endif 851{ 852 853 register int yystate; 854 register int yyn; 855 int yyresult; 856 /* Number of tokens to shift before error messages enabled. */ 857 int yyerrstatus; 858 /* Lookahead token as an internal (translated) token number. */ 859 int yytoken = 0; 860 861 /* Three stacks and their tools: 862 `yyss': related to states, 863 `yyvs': related to semantic values, 864 `yyls': related to locations. 865 866 Refer to the stacks thru separate pointers, to allow yyoverflow 867 to reallocate them elsewhere. */ 868 869 /* The state stack. */ 870 short yyssa[YYINITDEPTH]; 871 short *yyss = yyssa; 872 register short *yyssp; 873 874 /* The semantic value stack. */ 875 YYSTYPE yyvsa[YYINITDEPTH]; 876 YYSTYPE *yyvs = yyvsa; 877 register YYSTYPE *yyvsp; 878 879 880 881#define YYPOPSTACK (yyvsp--, yyssp--) 882 883 YYSIZE_T yystacksize = YYINITDEPTH; 884 885 /* The variables used to return semantic value and location from the 886 action routines. */ 887 YYSTYPE yyval; 888 889 890 /* When reducing, the number of symbols on the RHS of the reduced 891 rule. */ 892 int yylen; 893 894 YYDPRINTF ((stderr, "Starting parse\n")); 895 896 yystate = 0; 897 yyerrstatus = 0; 898 yynerrs = 0; 899 yychar = YYEMPTY; /* Cause a token to be read. */ 900 901 /* Initialize stack pointers. 902 Waste one element of value and location stack 903 so that they stay on the same level as the state stack. 904 The wasted elements are never initialized. */ 905 906 yyssp = yyss; 907 yyvsp = yyvs; 908 909 goto yysetstate; 910 911/*------------------------------------------------------------. 912| yynewstate -- Push a new state, which is found in yystate. | 913`------------------------------------------------------------*/ 914 yynewstate: 915 /* In all cases, when you get here, the value and location stacks 916 have just been pushed. so pushing a state here evens the stacks. 917 */ 918 yyssp++; 919 920 yysetstate: 921 *yyssp = yystate; 922 923 if (yyss + yystacksize - 1 <= yyssp) 924 { 925 /* Get the current used size of the three stacks, in elements. */ 926 YYSIZE_T yysize = yyssp - yyss + 1; 927 928#ifdef yyoverflow 929 { 930 /* Give user a chance to reallocate the stack. Use copies of 931 these so that the &'s don't force the real ones into 932 memory. */ 933 YYSTYPE *yyvs1 = yyvs; 934 short *yyss1 = yyss; 935 936 937 /* Each stack pointer address is followed by the size of the 938 data in use in that stack, in bytes. This used to be a 939 conditional around just the two extra args, but that might 940 be undefined if yyoverflow is a macro. */ 941 yyoverflow ("parser stack overflow", 942 &yyss1, yysize * sizeof (*yyssp), 943 &yyvs1, yysize * sizeof (*yyvsp), 944 945 &yystacksize); 946 947 yyss = yyss1; 948 yyvs = yyvs1; 949 } 950#else /* no yyoverflow */ 951# ifndef YYSTACK_RELOCATE 952 goto yyoverflowlab; 953# else 954 /* Extend the stack our own way. */ 955 if (YYMAXDEPTH <= yystacksize) 956 goto yyoverflowlab; 957 yystacksize *= 2; 958 if (YYMAXDEPTH < yystacksize) 959 yystacksize = YYMAXDEPTH; 960 961 { 962 short *yyss1 = yyss; 963 union yyalloc *yyptr = 964 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); 965 if (! yyptr) 966 goto yyoverflowlab; 967 YYSTACK_RELOCATE (yyss); 968 YYSTACK_RELOCATE (yyvs); 969 970# undef YYSTACK_RELOCATE 971 if (yyss1 != yyssa) 972 YYSTACK_FREE (yyss1); 973 } 974# endif 975#endif /* no yyoverflow */ 976 977 yyssp = yyss + yysize - 1; 978 yyvsp = yyvs + yysize - 1; 979 980 981 YYDPRINTF ((stderr, "Stack size increased to %lu\n", 982 (unsigned long int) yystacksize)); 983 984 if (yyss + yystacksize - 1 <= yyssp) 985 YYABORT; 986 } 987 988 YYDPRINTF ((stderr, "Entering state %d\n", yystate)); 989 990 goto yybackup; 991 992/*-----------. 993| yybackup. | 994`-----------*/ 995yybackup: 996 997/* Do appropriate processing given the current state. */ 998/* Read a lookahead token if we need one and don't already have one. */ 999/* yyresume: */ 1000 1001 /* First try to decide what to do without reference to lookahead token. */ 1002 1003 yyn = yypact[yystate]; 1004 if (yyn == YYPACT_NINF) 1005 goto yydefault; 1006 1007 /* Not known => get a lookahead token if don't already have one. */ 1008 1009 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */ 1010 if (yychar == YYEMPTY) 1011 { 1012 YYDPRINTF ((stderr, "Reading a token: ")); 1013 yychar = YYLEX; 1014 } 1015 1016 if (yychar <= YYEOF) 1017 { 1018 yychar = yytoken = YYEOF; 1019 YYDPRINTF ((stderr, "Now at end of input.\n")); 1020 } 1021 else 1022 { 1023 yytoken = YYTRANSLATE (yychar); 1024 YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc); 1025 } 1026 1027 /* If the proper action on seeing token YYTOKEN is to reduce or to 1028 detect an error, take that action. */ 1029 yyn += yytoken; 1030 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken) 1031 goto yydefault; 1032 yyn = yytable[yyn]; 1033 if (yyn <= 0) 1034 { 1035 if (yyn == 0 || yyn == YYTABLE_NINF) 1036 goto yyerrlab; 1037 yyn = -yyn; 1038 goto yyreduce; 1039 } 1040 1041 if (yyn == YYFINAL) 1042 YYACCEPT; 1043 1044 /* Shift the lookahead token. */ 1045 YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken])); 1046 1047 /* Discard the token being shifted unless it is eof. */ 1048 if (yychar != YYEOF) 1049 yychar = YYEMPTY; 1050 1051 *++yyvsp = yylval; 1052 1053 1054 /* Count tokens shifted since error; after three, turn off error 1055 status. */ 1056 if (yyerrstatus) 1057 yyerrstatus--; 1058 1059 yystate = yyn; 1060 goto yynewstate; 1061 1062 1063/*-----------------------------------------------------------. 1064| yydefault -- do the default action for the current state. | 1065`-----------------------------------------------------------*/ 1066yydefault: 1067 yyn = yydefact[yystate]; 1068 if (yyn == 0) 1069 goto yyerrlab; 1070 goto yyreduce; 1071 1072 1073/*-----------------------------. 1074| yyreduce -- Do a reduction. | 1075`-----------------------------*/ 1076yyreduce: 1077 /* yyn is the number of a rule to reduce with. */ 1078 yylen = yyr2[yyn]; 1079 1080 /* If YYLEN is nonzero, implement the default value of the action: 1081 `$$ = $1'. 1082 1083 Otherwise, the following line sets YYVAL to garbage. 1084 This behavior is undocumented and Bison 1085 users should not rely upon it. Assigning to YYVAL 1086 unconditionally makes the parser a bit smaller, and it avoids a 1087 GCC warning that YYVAL may be used uninitialized. */ 1088 yyval = yyvsp[1-yylen]; 1089 1090 1091 YY_REDUCE_PRINT (yyn); 1092 switch (yyn) 1093 { 1094 case 2: 1095#line 68 "arparse.y" 1096 { prompt(); } 1097 break; 1098 1099 case 6: 1100#line 77 "arparse.y" 1101 { prompt(); } 1102 break; 1103 1104 case 19: 1105#line 93 "arparse.y" 1106 { ar_end(); return 0; } 1107 break; 1108 1109 case 21: 1110#line 95 "arparse.y" 1111 { yyerror("foo"); } 1112 break; 1113 1114 case 23: 1115#line 102 "arparse.y" 1116 { ar_extract(yyvsp[0].list); } 1117 break; 1118 1119 case 24: 1120#line 107 "arparse.y" 1121 { ar_replace(yyvsp[0].list); } 1122 break; 1123 1124 case 25: 1125#line 112 "arparse.y" 1126 { ar_clear(); } 1127 break; 1128 1129 case 26: 1130#line 117 "arparse.y" 1131 { ar_delete(yyvsp[0].list); } 1132 break; 1133 1134 case 27: 1135#line 121 "arparse.y" 1136 { ar_addmod(yyvsp[0].list); } 1137 break; 1138 1139 case 28: 1140#line 126 "arparse.y" 1141 { ar_list(); } 1142 break; 1143 1144 case 29: 1145#line 131 "arparse.y" 1146 { ar_save(); } 1147 break; 1148 1149 case 30: 1150#line 138 "arparse.y" 1151 { ar_open(yyvsp[0].name,0); } 1152 break; 1153 1154 case 31: 1155#line 143 "arparse.y" 1156 { ar_open(yyvsp[0].name,1); } 1157 break; 1158 1159 case 32: 1160#line 149 "arparse.y" 1161 { ar_addlib(yyvsp[-1].name,yyvsp[0].list); } 1162 break; 1163 1164 case 33: 1165#line 153 "arparse.y" 1166 { ar_directory(yyvsp[-2].name, yyvsp[-1].list, yyvsp[0].name); } 1167 break; 1168 1169 case 34: 1170#line 160 "arparse.y" 1171 { yyval.name = yyvsp[0].name; } 1172 break; 1173 1174 case 35: 1175#line 161 "arparse.y" 1176 { yyval.name = 0; } 1177 break; 1178 1179 case 36: 1180#line 166 "arparse.y" 1181 { yyval.list = yyvsp[-1].list; } 1182 break; 1183 1184 case 37: 1185#line 168 "arparse.y" 1186 { yyval.list = 0; } 1187 break; 1188 1189 case 38: 1190#line 173 "arparse.y" 1191 { struct list *n = (struct list *) malloc(sizeof(struct list)); 1192 n->next = yyvsp[-2].list; 1193 n->name = yyvsp[0].name; 1194 yyval.list = n; 1195 } 1196 break; 1197 1198 case 39: 1199#line 178 "arparse.y" 1200 { yyval.list = 0; } 1201 break; 1202 1203 case 42: 1204#line 190 "arparse.y" 1205 { verbose = !verbose; } 1206 break; 1207 1208 1209 } 1210 1211/* Line 1000 of yacc.c. */ 1212#line 1213 "arparse.c" 1213 1214 yyvsp -= yylen; 1215 yyssp -= yylen; 1216 1217 1218 YY_STACK_PRINT (yyss, yyssp); 1219 1220 *++yyvsp = yyval; 1221 1222 1223 /* Now `shift' the result of the reduction. Determine what state 1224 that goes to, based on the state we popped back to and the rule 1225 number reduced by. */ 1226 1227 yyn = yyr1[yyn]; 1228 1229 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; 1230 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) 1231 yystate = yytable[yystate]; 1232 else 1233 yystate = yydefgoto[yyn - YYNTOKENS]; 1234 1235 goto yynewstate; 1236 1237 1238/*------------------------------------. 1239| yyerrlab -- here on detecting error | 1240`------------------------------------*/ 1241yyerrlab: 1242 /* If not already recovering from an error, report this error. */ 1243 if (!yyerrstatus) 1244 { 1245 ++yynerrs; 1246#if YYERROR_VERBOSE 1247 yyn = yypact[yystate]; 1248 1249 if (YYPACT_NINF < yyn && yyn < YYLAST) 1250 { 1251 YYSIZE_T yysize = 0; 1252 int yytype = YYTRANSLATE (yychar); 1253 const char* yyprefix; 1254 char *yymsg; 1255 int yyx; 1256 1257 /* Start YYX at -YYN if negative to avoid negative indexes in 1258 YYCHECK. */ 1259 int yyxbegin = yyn < 0 ? -yyn : 0; 1260 1261 /* Stay within bounds of both yycheck and yytname. */ 1262 int yychecklim = YYLAST - yyn; 1263 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; 1264 int yycount = 0; 1265 1266 yyprefix = ", expecting "; 1267 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1268 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1269 { 1270 yysize += yystrlen (yyprefix) + yystrlen (yytname [yyx]); 1271 yycount += 1; 1272 if (yycount == 5) 1273 { 1274 yysize = 0; 1275 break; 1276 } 1277 } 1278 yysize += (sizeof ("syntax error, unexpected ") 1279 + yystrlen (yytname[yytype])); 1280 yymsg = (char *) YYSTACK_ALLOC (yysize); 1281 if (yymsg != 0) 1282 { 1283 char *yyp = yystpcpy (yymsg, "syntax error, unexpected "); 1284 yyp = yystpcpy (yyp, yytname[yytype]); 1285 1286 if (yycount < 5) 1287 { 1288 yyprefix = ", expecting "; 1289 for (yyx = yyxbegin; yyx < yyxend; ++yyx) 1290 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) 1291 { 1292 yyp = yystpcpy (yyp, yyprefix); 1293 yyp = yystpcpy (yyp, yytname[yyx]); 1294 yyprefix = " or "; 1295 } 1296 } 1297 yyerror (yymsg); 1298 YYSTACK_FREE (yymsg); 1299 } 1300 else 1301 yyerror ("syntax error; also virtual memory exhausted"); 1302 } 1303 else 1304#endif /* YYERROR_VERBOSE */ 1305 yyerror ("syntax error"); 1306 } 1307 1308 1309 1310 if (yyerrstatus == 3) 1311 { 1312 /* If just tried and failed to reuse lookahead token after an 1313 error, discard it. */ 1314 1315 if (yychar <= YYEOF) 1316 { 1317 /* If at end of input, pop the error token, 1318 then the rest of the stack, then return failure. */ 1319 if (yychar == YYEOF) 1320 for (;;) 1321 { 1322 YYPOPSTACK; 1323 if (yyssp == yyss) 1324 YYABORT; 1325 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1326 yydestruct (yystos[*yyssp], yyvsp); 1327 } 1328 } 1329 else 1330 { 1331 YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc); 1332 yydestruct (yytoken, &yylval); 1333 yychar = YYEMPTY; 1334 1335 } 1336 } 1337 1338 /* Else will try to reuse lookahead token after shifting the error 1339 token. */ 1340 goto yyerrlab1; 1341 1342 1343/*---------------------------------------------------. 1344| yyerrorlab -- error raised explicitly by YYERROR. | 1345`---------------------------------------------------*/ 1346yyerrorlab: 1347 1348#ifdef __GNUC__ 1349 /* Pacify GCC when the user code never invokes YYERROR and the label 1350 yyerrorlab therefore never appears in user code. */ 1351 if (0) 1352 goto yyerrorlab; 1353#endif 1354 1355 yyvsp -= yylen; 1356 yyssp -= yylen; 1357 yystate = *yyssp; 1358 goto yyerrlab1; 1359 1360 1361/*-------------------------------------------------------------. 1362| yyerrlab1 -- common code for both syntax error and YYERROR. | 1363`-------------------------------------------------------------*/ 1364yyerrlab1: 1365 yyerrstatus = 3; /* Each real token shifted decrements this. */ 1366 1367 for (;;) 1368 { 1369 yyn = yypact[yystate]; 1370 if (yyn != YYPACT_NINF) 1371 { 1372 yyn += YYTERROR; 1373 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 1374 { 1375 yyn = yytable[yyn]; 1376 if (0 < yyn) 1377 break; 1378 } 1379 } 1380 1381 /* Pop the current state because it cannot handle the error token. */ 1382 if (yyssp == yyss) 1383 YYABORT; 1384 1385 YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp); 1386 yydestruct (yystos[yystate], yyvsp); 1387 YYPOPSTACK; 1388 yystate = *yyssp; 1389 YY_STACK_PRINT (yyss, yyssp); 1390 } 1391 1392 if (yyn == YYFINAL) 1393 YYACCEPT; 1394 1395 YYDPRINTF ((stderr, "Shifting error token, ")); 1396 1397 *++yyvsp = yylval; 1398 1399 1400 yystate = yyn; 1401 goto yynewstate; 1402 1403 1404/*-------------------------------------. 1405| yyacceptlab -- YYACCEPT comes here. | 1406`-------------------------------------*/ 1407yyacceptlab: 1408 yyresult = 0; 1409 goto yyreturn; 1410 1411/*-----------------------------------. 1412| yyabortlab -- YYABORT comes here. | 1413`-----------------------------------*/ 1414yyabortlab: 1415 yyresult = 1; 1416 goto yyreturn; 1417 1418#ifndef yyoverflow 1419/*----------------------------------------------. 1420| yyoverflowlab -- parser overflow comes here. | 1421`----------------------------------------------*/ 1422yyoverflowlab: 1423 yyerror ("parser stack overflow"); 1424 yyresult = 2; 1425 /* Fall through. */ 1426#endif 1427 1428yyreturn: 1429#ifndef yyoverflow 1430 if (yyss != yyssa) 1431 YYSTACK_FREE (yyss); 1432#endif 1433 return yyresult; 1434} 1435 1436 1437#line 194 "arparse.y" 1438 1439 1440static int 1441yyerror (const char *x ATTRIBUTE_UNUSED) 1442{ 1443 extern int linenumber; 1444 1445 printf (_("Syntax error in archive script, line %d\n"), linenumber + 1); 1446 return 0; 1447} 1448 1449