2001-03-22 Philip Blundell <philb@gnu.org>
[binutils.git] / binutils / arparse.c
blob23d6565ead65ba713acb072dd84309228efef573
2 /* A Bison parser, made from arparse.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define NEWLINE 257
8 #define VERBOSE 258
9 #define FILENAME 259
10 #define ADDLIB 260
11 #define LIST 261
12 #define ADDMOD 262
13 #define CLEAR 263
14 #define CREATE 264
15 #define DELETE 265
16 #define DIRECTORY 266
17 #define END 267
18 #define EXTRACT 268
19 #define FULLDIR 269
20 #define HELP 270
21 #define QUIT 271
22 #define REPLACE 272
23 #define SAVE 273
24 #define OPEN 274
26 #line 1 "arparse.y"
28 /* arparse.y - Stange script language parser */
30 /* Copyright (C) 1992, 93, 95, 97, 98, 1999 Free Software Foundation, Inc.
32 This file is part of GNU Binutils.
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.
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.
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. */
49 /* Contributed by Steve Chamberlain
50 sac@cygnus.com
53 #define DONTDECLARE_MALLOC
54 #include "bfd.h"
55 #include "bucomm.h"
56 #include "arsup.h"
57 extern int verbose;
58 extern int yylex PARAMS ((void));
59 static int yyerror PARAMS ((const char *));
61 #line 36 "arparse.y"
62 typedef union {
63 char *name;
64 struct list *list ;
66 } YYSTYPE;
67 #include <stdio.h>
69 #ifndef __cplusplus
70 #ifndef __STDC__
71 #define const
72 #endif
73 #endif
77 #define YYFINAL 53
78 #define YYFLAG -32768
79 #define YYNTBASE 24
81 #define YYTRANSLATE(x) ((unsigned)(x) <= 274 ? yytranslate[x] : 45)
83 static const char yytranslate[] = { 0,
84 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
85 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
86 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 21,
88 22, 2, 2, 23, 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 2, 2, 2, 2, 2, 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, 1, 3, 4, 5, 6,
110 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
111 17, 18, 19, 20
114 #if YYDEBUG != 0
115 static const short yyprhs[] = { 0,
116 0, 1, 4, 7, 8, 11, 13, 15, 17, 19,
117 21, 23, 25, 27, 29, 31, 33, 35, 37, 39,
118 41, 42, 45, 48, 50, 53, 56, 58, 60, 63,
119 66, 70, 75, 77, 78, 82, 83, 87, 88, 90,
123 static const short yyrhs[] = { -1,
124 25, 26, 0, 26, 27, 0, 0, 28, 3, 0,
125 36, 0, 37, 0, 44, 0, 39, 0, 38, 0,
126 31, 0, 33, 0, 35, 0, 29, 0, 30, 0,
127 32, 0, 34, 0, 13, 0, 1, 0, 5, 0,
128 0, 14, 42, 0, 18, 42, 0, 9, 0, 11,
129 42, 0, 8, 42, 0, 7, 0, 19, 0, 20,
130 5, 0, 10, 5, 0, 6, 5, 41, 0, 12,
131 5, 41, 40, 0, 5, 0, 0, 21, 42, 22,
132 0, 0, 42, 43, 5, 0, 0, 23, 0, 0,
133 4, 0
136 #endif
138 #if YYDEBUG != 0
139 static const short yyrline[] = { 0,
140 66, 68, 70, 72, 75, 78, 80, 81, 82, 83,
141 84, 85, 86, 87, 88, 89, 90, 91, 92, 93,
142 94, 98, 103, 108, 113, 117, 122, 127, 134, 139,
143 145, 149, 156, 159, 162, 165, 169, 176, 180, 182,
146 #endif
149 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
151 static const char * const yytname[] = { "$","error","$undefined.","NEWLINE",
152 "VERBOSE","FILENAME","ADDLIB","LIST","ADDMOD","CLEAR","CREATE","DELETE","DIRECTORY",
153 "END","EXTRACT","FULLDIR","HELP","QUIT","REPLACE","SAVE","OPEN","'('","')'",
154 "','","start","@1","session","command_line","command","extract_command","replace_command",
155 "clear_command","delete_command","addmod_command","list_command","save_command",
156 "open_command","create_command","addlib_command","directory_command","optional_filename",
157 "modulelist","modulename","optcomma","verbose_command", NULL
159 #endif
161 static const short yyr1[] = { 0,
162 25, 24, 26, 26, 27, 28, 28, 28, 28, 28,
163 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
164 28, 29, 30, 31, 32, 33, 34, 35, 36, 37,
165 38, 39, 40, 40, 41, 41, 42, 42, 43, 43,
169 static const short yyr2[] = { 0,
170 0, 2, 2, 0, 2, 1, 1, 1, 1, 1,
171 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
172 0, 2, 2, 1, 2, 2, 1, 1, 2, 2,
173 3, 4, 1, 0, 3, 0, 3, 0, 1, 0,
177 static const short yydefact[] = { 1,
178 4, 0, 19, 41, 20, 0, 27, 38, 24, 0,
179 38, 0, 18, 38, 38, 28, 0, 3, 0, 14,
180 15, 11, 16, 12, 17, 13, 6, 7, 10, 9,
181 8, 36, 26, 30, 25, 36, 22, 23, 29, 5,
182 38, 31, 39, 0, 34, 40, 37, 33, 32, 35,
183 0, 0, 0
186 static const short yydefgoto[] = { 51,
187 1, 2, 18, 19, 20, 21, 22, 23, 24, 25,
188 26, 27, 28, 29, 30, 49, 42, 33, 44, 31
191 static const short yypact[] = {-32768,
192 -32768, 5,-32768,-32768,-32768, -4,-32768,-32768,-32768, 2,
193 -32768, 21,-32768,-32768,-32768,-32768, 22,-32768, 25,-32768,
194 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
195 -32768, 8, -3,-32768, -3, 8, -3, -3,-32768,-32768,
196 -32768,-32768,-32768, 26, 27, -1,-32768,-32768,-32768,-32768,
197 33, 34,-32768
200 static const short yypgoto[] = {-32768,
201 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
202 -32768,-32768,-32768,-32768,-32768,-32768, 0, -11,-32768,-32768
206 #define YYLAST 36
209 static const short yytable[] = { 35,
210 32, -40, 37, 38, -2, 3, 34, -21, 4, 5,
211 6, 7, 8, 9, 10, 11, 12, 13, 14, 43,
212 50, 43, 15, 16, 17, 36, 39, 40, 41, 46,
213 47, 48, 52, 53, 0, 45
216 static const short yycheck[] = { 11,
217 5, 5, 14, 15, 0, 1, 5, 3, 4, 5,
218 6, 7, 8, 9, 10, 11, 12, 13, 14, 23,
219 22, 23, 18, 19, 20, 5, 5, 3, 21, 41,
220 5, 5, 0, 0, -1, 36
222 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
223 #line 3 "/usr/share/misc/bison.simple"
224 /* This file comes from bison-1.28. */
226 /* Skeleton output parser for bison,
227 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
229 This program is free software; you can redistribute it and/or modify
230 it under the terms of the GNU General Public License as published by
231 the Free Software Foundation; either version 2, or (at your option)
232 any later version.
234 This program is distributed in the hope that it will be useful,
235 but WITHOUT ANY WARRANTY; without even the implied warranty of
236 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
237 GNU General Public License for more details.
239 You should have received a copy of the GNU General Public License
240 along with this program; if not, write to the Free Software
241 Foundation, Inc., 59 Temple Place - Suite 330,
242 Boston, MA 02111-1307, USA. */
244 /* As a special exception, when this file is copied by Bison into a
245 Bison output file, you may use that output file without restriction.
246 This special exception was added by the Free Software Foundation
247 in version 1.24 of Bison. */
249 /* This is the parser code that is written into each bison parser
250 when the %semantic_parser declaration is not specified in the grammar.
251 It was written by Richard Stallman by simplifying the hairy parser
252 used when %semantic_parser is specified. */
254 #ifndef YYSTACK_USE_ALLOCA
255 #ifdef alloca
256 #define YYSTACK_USE_ALLOCA
257 #else /* alloca not defined */
258 #ifdef __GNUC__
259 #define YYSTACK_USE_ALLOCA
260 #define alloca __builtin_alloca
261 #else /* not GNU C. */
262 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
263 #define YYSTACK_USE_ALLOCA
264 #include <alloca.h>
265 #else /* not sparc */
266 /* We think this test detects Watcom and Microsoft C. */
267 /* This used to test MSDOS, but that is a bad idea
268 since that symbol is in the user namespace. */
269 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
270 #if 0 /* No need for malloc.h, which pollutes the namespace;
271 instead, just don't use alloca. */
272 #include <malloc.h>
273 #endif
274 #else /* not MSDOS, or __TURBOC__ */
275 #if defined(_AIX)
276 /* I don't know what this was needed for, but it pollutes the namespace.
277 So I turned it off. rms, 2 May 1997. */
278 /* #include <malloc.h> */
279 #pragma alloca
280 #define YYSTACK_USE_ALLOCA
281 #else /* not MSDOS, or __TURBOC__, or _AIX */
282 #if 0
283 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
284 and on HPUX 10. Eventually we can turn this on. */
285 #define YYSTACK_USE_ALLOCA
286 #define alloca __builtin_alloca
287 #endif /* __hpux */
288 #endif
289 #endif /* not _AIX */
290 #endif /* not MSDOS, or __TURBOC__ */
291 #endif /* not sparc */
292 #endif /* not GNU C */
293 #endif /* alloca not defined */
294 #endif /* YYSTACK_USE_ALLOCA not defined */
296 #ifdef YYSTACK_USE_ALLOCA
297 #define YYSTACK_ALLOC alloca
298 #else
299 #define YYSTACK_ALLOC malloc
300 #endif
302 /* Note: there must be only one dollar sign in this file.
303 It is replaced by the list of actions, each action
304 as one case of the switch. */
306 #define yyerrok (yyerrstatus = 0)
307 #define yyclearin (yychar = YYEMPTY)
308 #define YYEMPTY -2
309 #define YYEOF 0
310 #define YYACCEPT goto yyacceptlab
311 #define YYABORT goto yyabortlab
312 #define YYERROR goto yyerrlab1
313 /* Like YYERROR except do call yyerror.
314 This remains here temporarily to ease the
315 transition to the new meaning of YYERROR, for GCC.
316 Once GCC version 2 has supplanted version 1, this can go. */
317 #define YYFAIL goto yyerrlab
318 #define YYRECOVERING() (!!yyerrstatus)
319 #define YYBACKUP(token, value) \
320 do \
321 if (yychar == YYEMPTY && yylen == 1) \
322 { yychar = (token), yylval = (value); \
323 yychar1 = YYTRANSLATE (yychar); \
324 YYPOPSTACK; \
325 goto yybackup; \
327 else \
328 { yyerror ("syntax error: cannot back up"); YYERROR; } \
329 while (0)
331 #define YYTERROR 1
332 #define YYERRCODE 256
334 #ifndef YYPURE
335 #define YYLEX yylex()
336 #endif
338 #ifdef YYPURE
339 #ifdef YYLSP_NEEDED
340 #ifdef YYLEX_PARAM
341 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
342 #else
343 #define YYLEX yylex(&yylval, &yylloc)
344 #endif
345 #else /* not YYLSP_NEEDED */
346 #ifdef YYLEX_PARAM
347 #define YYLEX yylex(&yylval, YYLEX_PARAM)
348 #else
349 #define YYLEX yylex(&yylval)
350 #endif
351 #endif /* not YYLSP_NEEDED */
352 #endif
354 /* If nonreentrant, generate the variables here */
356 #ifndef YYPURE
358 int yychar; /* the lookahead symbol */
359 YYSTYPE yylval; /* the semantic value of the */
360 /* lookahead symbol */
362 #ifdef YYLSP_NEEDED
363 YYLTYPE yylloc; /* location data for the lookahead */
364 /* symbol */
365 #endif
367 int yynerrs; /* number of parse errors so far */
368 #endif /* not YYPURE */
370 #if YYDEBUG != 0
371 int yydebug; /* nonzero means print parse trace */
372 /* Since this is uninitialized, it does not stop multiple parsers
373 from coexisting. */
374 #endif
376 /* YYINITDEPTH indicates the initial size of the parser's stacks */
378 #ifndef YYINITDEPTH
379 #define YYINITDEPTH 200
380 #endif
382 /* YYMAXDEPTH is the maximum size the stacks can grow to
383 (effective only if the built-in stack extension method is used). */
385 #if YYMAXDEPTH == 0
386 #undef YYMAXDEPTH
387 #endif
389 #ifndef YYMAXDEPTH
390 #define YYMAXDEPTH 10000
391 #endif
393 /* Define __yy_memcpy. Note that the size argument
394 should be passed with type unsigned int, because that is what the non-GCC
395 definitions require. With GCC, __builtin_memcpy takes an arg
396 of type size_t, but it can handle unsigned int. */
398 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
399 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
400 #else /* not GNU C or C++ */
401 #ifndef __cplusplus
403 /* This is the most reliable way to avoid incompatibilities
404 in available built-in functions on various systems. */
405 static void
406 __yy_memcpy (to, from, count)
407 char *to;
408 char *from;
409 unsigned int count;
411 register char *f = from;
412 register char *t = to;
413 register int i = count;
415 while (i-- > 0)
416 *t++ = *f++;
419 #else /* __cplusplus */
421 /* This is the most reliable way to avoid incompatibilities
422 in available built-in functions on various systems. */
423 static void
424 __yy_memcpy (char *to, char *from, unsigned int count)
426 register char *t = to;
427 register char *f = from;
428 register int i = count;
430 while (i-- > 0)
431 *t++ = *f++;
434 #endif
435 #endif
437 #line 217 "/usr/share/misc/bison.simple"
439 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
440 into yyparse. The argument should have type void *.
441 It should actually point to an object.
442 Grammar actions can access the variable by casting it
443 to the proper pointer type. */
445 #ifdef YYPARSE_PARAM
446 #ifdef __cplusplus
447 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
448 #define YYPARSE_PARAM_DECL
449 #else /* not __cplusplus */
450 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
451 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
452 #endif /* not __cplusplus */
453 #else /* not YYPARSE_PARAM */
454 #define YYPARSE_PARAM_ARG
455 #define YYPARSE_PARAM_DECL
456 #endif /* not YYPARSE_PARAM */
458 /* Prevent warning if -Wstrict-prototypes. */
459 #ifdef __GNUC__
460 #ifdef YYPARSE_PARAM
461 int yyparse (void *);
462 #else
463 int yyparse (void);
464 #endif
465 #endif
468 yyparse(YYPARSE_PARAM_ARG)
469 YYPARSE_PARAM_DECL
471 register int yystate;
472 register int yyn;
473 register short *yyssp;
474 register YYSTYPE *yyvsp;
475 int yyerrstatus; /* number of tokens to shift before error messages enabled */
476 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
478 short yyssa[YYINITDEPTH]; /* the state stack */
479 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
481 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
482 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
484 #ifdef YYLSP_NEEDED
485 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
486 YYLTYPE *yyls = yylsa;
487 YYLTYPE *yylsp;
489 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
490 #else
491 #define YYPOPSTACK (yyvsp--, yyssp--)
492 #endif
494 int yystacksize = YYINITDEPTH;
495 int yyfree_stacks = 0;
497 #ifdef YYPURE
498 int yychar;
499 YYSTYPE yylval;
500 int yynerrs;
501 #ifdef YYLSP_NEEDED
502 YYLTYPE yylloc;
503 #endif
504 #endif
506 YYSTYPE yyval; /* the variable used to return */
507 /* semantic values from the action */
508 /* routines */
510 int yylen;
512 #if YYDEBUG != 0
513 if (yydebug)
514 fprintf(stderr, "Starting parse\n");
515 #endif
517 yystate = 0;
518 yyerrstatus = 0;
519 yynerrs = 0;
520 yychar = YYEMPTY; /* Cause a token to be read. */
522 /* Initialize stack pointers.
523 Waste one element of value and location stack
524 so that they stay on the same level as the state stack.
525 The wasted elements are never initialized. */
527 yyssp = yyss - 1;
528 yyvsp = yyvs;
529 #ifdef YYLSP_NEEDED
530 yylsp = yyls;
531 #endif
533 /* Push a new state, which is found in yystate . */
534 /* In all cases, when you get here, the value and location stacks
535 have just been pushed. so pushing a state here evens the stacks. */
536 yynewstate:
538 *++yyssp = yystate;
540 if (yyssp >= yyss + yystacksize - 1)
542 /* Give user a chance to reallocate the stack */
543 /* Use copies of these so that the &'s don't force the real ones into memory. */
544 YYSTYPE *yyvs1 = yyvs;
545 short *yyss1 = yyss;
546 #ifdef YYLSP_NEEDED
547 YYLTYPE *yyls1 = yyls;
548 #endif
550 /* Get the current used size of the three stacks, in elements. */
551 int size = yyssp - yyss + 1;
553 #ifdef yyoverflow
554 /* Each stack pointer address is followed by the size of
555 the data in use in that stack, in bytes. */
556 #ifdef YYLSP_NEEDED
557 /* This used to be a conditional around just the two extra args,
558 but that might be undefined if yyoverflow is a macro. */
559 yyoverflow("parser stack overflow",
560 &yyss1, size * sizeof (*yyssp),
561 &yyvs1, size * sizeof (*yyvsp),
562 &yyls1, size * sizeof (*yylsp),
563 &yystacksize);
564 #else
565 yyoverflow("parser stack overflow",
566 &yyss1, size * sizeof (*yyssp),
567 &yyvs1, size * sizeof (*yyvsp),
568 &yystacksize);
569 #endif
571 yyss = yyss1; yyvs = yyvs1;
572 #ifdef YYLSP_NEEDED
573 yyls = yyls1;
574 #endif
575 #else /* no yyoverflow */
576 /* Extend the stack our own way. */
577 if (yystacksize >= YYMAXDEPTH)
579 yyerror("parser stack overflow");
580 if (yyfree_stacks)
582 free (yyss);
583 free (yyvs);
584 #ifdef YYLSP_NEEDED
585 free (yyls);
586 #endif
588 return 2;
590 yystacksize *= 2;
591 if (yystacksize > YYMAXDEPTH)
592 yystacksize = YYMAXDEPTH;
593 #ifndef YYSTACK_USE_ALLOCA
594 yyfree_stacks = 1;
595 #endif
596 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
597 __yy_memcpy ((char *)yyss, (char *)yyss1,
598 size * (unsigned int) sizeof (*yyssp));
599 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
600 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
601 size * (unsigned int) sizeof (*yyvsp));
602 #ifdef YYLSP_NEEDED
603 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
604 __yy_memcpy ((char *)yyls, (char *)yyls1,
605 size * (unsigned int) sizeof (*yylsp));
606 #endif
607 #endif /* no yyoverflow */
609 yyssp = yyss + size - 1;
610 yyvsp = yyvs + size - 1;
611 #ifdef YYLSP_NEEDED
612 yylsp = yyls + size - 1;
613 #endif
615 #if YYDEBUG != 0
616 if (yydebug)
617 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
618 #endif
620 if (yyssp >= yyss + yystacksize - 1)
621 YYABORT;
624 #if YYDEBUG != 0
625 if (yydebug)
626 fprintf(stderr, "Entering state %d\n", yystate);
627 #endif
629 goto yybackup;
630 yybackup:
632 /* Do appropriate processing given the current state. */
633 /* Read a lookahead token if we need one and don't already have one. */
634 /* yyresume: */
636 /* First try to decide what to do without reference to lookahead token. */
638 yyn = yypact[yystate];
639 if (yyn == YYFLAG)
640 goto yydefault;
642 /* Not known => get a lookahead token if don't already have one. */
644 /* yychar is either YYEMPTY or YYEOF
645 or a valid token in external form. */
647 if (yychar == YYEMPTY)
649 #if YYDEBUG != 0
650 if (yydebug)
651 fprintf(stderr, "Reading a token: ");
652 #endif
653 yychar = YYLEX;
656 /* Convert token to internal form (in yychar1) for indexing tables with */
658 if (yychar <= 0) /* This means end of input. */
660 yychar1 = 0;
661 yychar = YYEOF; /* Don't call YYLEX any more */
663 #if YYDEBUG != 0
664 if (yydebug)
665 fprintf(stderr, "Now at end of input.\n");
666 #endif
668 else
670 yychar1 = YYTRANSLATE(yychar);
672 #if YYDEBUG != 0
673 if (yydebug)
675 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
676 /* Give the individual parser a way to print the precise meaning
677 of a token, for further debugging info. */
678 #ifdef YYPRINT
679 YYPRINT (stderr, yychar, yylval);
680 #endif
681 fprintf (stderr, ")\n");
683 #endif
686 yyn += yychar1;
687 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
688 goto yydefault;
690 yyn = yytable[yyn];
692 /* yyn is what to do for this token type in this state.
693 Negative => reduce, -yyn is rule number.
694 Positive => shift, yyn is new state.
695 New state is final state => don't bother to shift,
696 just return success.
697 0, or most negative number => error. */
699 if (yyn < 0)
701 if (yyn == YYFLAG)
702 goto yyerrlab;
703 yyn = -yyn;
704 goto yyreduce;
706 else if (yyn == 0)
707 goto yyerrlab;
709 if (yyn == YYFINAL)
710 YYACCEPT;
712 /* Shift the lookahead token. */
714 #if YYDEBUG != 0
715 if (yydebug)
716 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
717 #endif
719 /* Discard the token being shifted unless it is eof. */
720 if (yychar != YYEOF)
721 yychar = YYEMPTY;
723 *++yyvsp = yylval;
724 #ifdef YYLSP_NEEDED
725 *++yylsp = yylloc;
726 #endif
728 /* count tokens shifted since error; after three, turn off error status. */
729 if (yyerrstatus) yyerrstatus--;
731 yystate = yyn;
732 goto yynewstate;
734 /* Do the default action for the current state. */
735 yydefault:
737 yyn = yydefact[yystate];
738 if (yyn == 0)
739 goto yyerrlab;
741 /* Do a reduction. yyn is the number of a rule to reduce with. */
742 yyreduce:
743 yylen = yyr2[yyn];
744 if (yylen > 0)
745 yyval = yyvsp[1-yylen]; /* implement default value of the action */
747 #if YYDEBUG != 0
748 if (yydebug)
750 int i;
752 fprintf (stderr, "Reducing via rule %d (line %d), ",
753 yyn, yyrline[yyn]);
755 /* Print the symbols being reduced, and their result. */
756 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
757 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
758 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
760 #endif
763 switch (yyn) {
765 case 1:
766 #line 67 "arparse.y"
767 { prompt(); ;
768 break;}
769 case 5:
770 #line 76 "arparse.y"
771 { prompt(); ;
772 break;}
773 case 18:
774 #line 91 "arparse.y"
775 { ar_end(); return 0; ;
776 break;}
777 case 20:
778 #line 93 "arparse.y"
779 { yyerror("foo"); ;
780 break;}
781 case 22:
782 #line 100 "arparse.y"
783 { ar_extract(yyvsp[0].list); ;
784 break;}
785 case 23:
786 #line 105 "arparse.y"
787 { ar_replace(yyvsp[0].list); ;
788 break;}
789 case 24:
790 #line 110 "arparse.y"
791 { ar_clear(); ;
792 break;}
793 case 25:
794 #line 115 "arparse.y"
795 { ar_delete(yyvsp[0].list); ;
796 break;}
797 case 26:
798 #line 119 "arparse.y"
799 { ar_addmod(yyvsp[0].list); ;
800 break;}
801 case 27:
802 #line 124 "arparse.y"
803 { ar_list(); ;
804 break;}
805 case 28:
806 #line 129 "arparse.y"
807 { ar_save(); ;
808 break;}
809 case 29:
810 #line 136 "arparse.y"
811 { ar_open(yyvsp[0].name,0); ;
812 break;}
813 case 30:
814 #line 141 "arparse.y"
815 { ar_open(yyvsp[0].name,1); ;
816 break;}
817 case 31:
818 #line 147 "arparse.y"
819 { ar_addlib(yyvsp[-1].name,yyvsp[0].list); ;
820 break;}
821 case 32:
822 #line 151 "arparse.y"
823 { ar_directory(yyvsp[-2].name, yyvsp[-1].list, yyvsp[0].name); ;
824 break;}
825 case 33:
826 #line 158 "arparse.y"
827 { yyval.name = yyvsp[0].name; ;
828 break;}
829 case 34:
830 #line 159 "arparse.y"
831 { yyval.name = 0; ;
832 break;}
833 case 35:
834 #line 164 "arparse.y"
835 { yyval.list = yyvsp[-1].list; ;
836 break;}
837 case 36:
838 #line 166 "arparse.y"
839 { yyval.list = 0; ;
840 break;}
841 case 37:
842 #line 171 "arparse.y"
843 { struct list *n = (struct list *) malloc(sizeof(struct list));
844 n->next = yyvsp[-2].list;
845 n->name = yyvsp[0].name;
846 yyval.list = n;
848 break;}
849 case 38:
850 #line 176 "arparse.y"
851 { yyval.list = 0; ;
852 break;}
853 case 41:
854 #line 188 "arparse.y"
855 { verbose = !verbose; ;
856 break;}
858 /* the action file gets copied in in place of this dollarsign */
859 #line 543 "/usr/share/misc/bison.simple"
861 yyvsp -= yylen;
862 yyssp -= yylen;
863 #ifdef YYLSP_NEEDED
864 yylsp -= yylen;
865 #endif
867 #if YYDEBUG != 0
868 if (yydebug)
870 short *ssp1 = yyss - 1;
871 fprintf (stderr, "state stack now");
872 while (ssp1 != yyssp)
873 fprintf (stderr, " %d", *++ssp1);
874 fprintf (stderr, "\n");
876 #endif
878 *++yyvsp = yyval;
880 #ifdef YYLSP_NEEDED
881 yylsp++;
882 if (yylen == 0)
884 yylsp->first_line = yylloc.first_line;
885 yylsp->first_column = yylloc.first_column;
886 yylsp->last_line = (yylsp-1)->last_line;
887 yylsp->last_column = (yylsp-1)->last_column;
888 yylsp->text = 0;
890 else
892 yylsp->last_line = (yylsp+yylen-1)->last_line;
893 yylsp->last_column = (yylsp+yylen-1)->last_column;
895 #endif
897 /* Now "shift" the result of the reduction.
898 Determine what state that goes to,
899 based on the state we popped back to
900 and the rule number reduced by. */
902 yyn = yyr1[yyn];
904 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
905 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
906 yystate = yytable[yystate];
907 else
908 yystate = yydefgoto[yyn - YYNTBASE];
910 goto yynewstate;
912 yyerrlab: /* here on detecting error */
914 if (! yyerrstatus)
915 /* If not already recovering from an error, report this error. */
917 ++yynerrs;
919 #ifdef YYERROR_VERBOSE
920 yyn = yypact[yystate];
922 if (yyn > YYFLAG && yyn < YYLAST)
924 int size = 0;
925 char *msg;
926 int x, count;
928 count = 0;
929 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
930 for (x = (yyn < 0 ? -yyn : 0);
931 x < (sizeof(yytname) / sizeof(char *)); x++)
932 if (yycheck[x + yyn] == x)
933 size += strlen(yytname[x]) + 15, count++;
934 msg = (char *) malloc(size + 15);
935 if (msg != 0)
937 strcpy(msg, "parse error");
939 if (count < 5)
941 count = 0;
942 for (x = (yyn < 0 ? -yyn : 0);
943 x < (sizeof(yytname) / sizeof(char *)); x++)
944 if (yycheck[x + yyn] == x)
946 strcat(msg, count == 0 ? ", expecting `" : " or `");
947 strcat(msg, yytname[x]);
948 strcat(msg, "'");
949 count++;
952 yyerror(msg);
953 free(msg);
955 else
956 yyerror ("parse error; also virtual memory exceeded");
958 else
959 #endif /* YYERROR_VERBOSE */
960 yyerror("parse error");
963 goto yyerrlab1;
964 yyerrlab1: /* here on error raised explicitly by an action */
966 if (yyerrstatus == 3)
968 /* if just tried and failed to reuse lookahead token after an error, discard it. */
970 /* return failure if at end of input */
971 if (yychar == YYEOF)
972 YYABORT;
974 #if YYDEBUG != 0
975 if (yydebug)
976 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
977 #endif
979 yychar = YYEMPTY;
982 /* Else will try to reuse lookahead token
983 after shifting the error token. */
985 yyerrstatus = 3; /* Each real token shifted decrements this */
987 goto yyerrhandle;
989 yyerrdefault: /* current state does not do anything special for the error token. */
991 #if 0
992 /* This is wrong; only states that explicitly want error tokens
993 should shift them. */
994 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
995 if (yyn) goto yydefault;
996 #endif
998 yyerrpop: /* pop the current state because it cannot handle the error token */
1000 if (yyssp == yyss) YYABORT;
1001 yyvsp--;
1002 yystate = *--yyssp;
1003 #ifdef YYLSP_NEEDED
1004 yylsp--;
1005 #endif
1007 #if YYDEBUG != 0
1008 if (yydebug)
1010 short *ssp1 = yyss - 1;
1011 fprintf (stderr, "Error: state stack now");
1012 while (ssp1 != yyssp)
1013 fprintf (stderr, " %d", *++ssp1);
1014 fprintf (stderr, "\n");
1016 #endif
1018 yyerrhandle:
1020 yyn = yypact[yystate];
1021 if (yyn == YYFLAG)
1022 goto yyerrdefault;
1024 yyn += YYTERROR;
1025 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1026 goto yyerrdefault;
1028 yyn = yytable[yyn];
1029 if (yyn < 0)
1031 if (yyn == YYFLAG)
1032 goto yyerrpop;
1033 yyn = -yyn;
1034 goto yyreduce;
1036 else if (yyn == 0)
1037 goto yyerrpop;
1039 if (yyn == YYFINAL)
1040 YYACCEPT;
1042 #if YYDEBUG != 0
1043 if (yydebug)
1044 fprintf(stderr, "Shifting error token, ");
1045 #endif
1047 *++yyvsp = yylval;
1048 #ifdef YYLSP_NEEDED
1049 *++yylsp = yylloc;
1050 #endif
1052 yystate = yyn;
1053 goto yynewstate;
1055 yyacceptlab:
1056 /* YYACCEPT comes here. */
1057 if (yyfree_stacks)
1059 free (yyss);
1060 free (yyvs);
1061 #ifdef YYLSP_NEEDED
1062 free (yyls);
1063 #endif
1065 return 0;
1067 yyabortlab:
1068 /* YYABORT comes here. */
1069 if (yyfree_stacks)
1071 free (yyss);
1072 free (yyvs);
1073 #ifdef YYLSP_NEEDED
1074 free (yyls);
1075 #endif
1077 return 1;
1079 #line 192 "arparse.y"
1082 static int
1083 yyerror (x)
1084 const char *x ATTRIBUTE_UNUSED;
1086 extern int linenumber;
1088 printf (_("Syntax error in archive script, line %d\n"), linenumber + 1);
1089 return 0;