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