* Added the "c_gen.pl" perl script into this directory, so the current
[binutils-gdb.git] / binutils / arparse.y
blobdccdf8e3633d26df26aafd900212843fba7b35a1
1 %{
2 /* arparse.y - Stange script language parser */
4 /* Copyright (C) 1992 Free Software Foundation, Inc.
6 This file is part of GNU Binutils.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
23 /* Contributed by Steve Chamberlain
24 sac@cygnus.com
27 #define DONTDECLARE_MALLOC
28 #include "bfd.h"
29 #include <sysdep.h>
30 #include "arsup.h"
31 extern int interactive;
32 extern bfd *inarch;
33 extern int verbose;
34 void (*command)();
35 FILE *listing;
38 %union {
39 char *name;
40 struct list *list ;
44 %token NEWLINE
45 %token VERBOSE
46 %token <name> FILENAME
47 %token ADDLIB
48 %token LIST
49 %token ADDMOD
50 %token CLEAR
51 %token CREATE
52 %token DELETE
53 %token DIRECTORY
54 %token END
55 %token EXTRACT
56 %token FULLDIR
57 %token HELP
58 %token QUIT
59 %token REPLACE
60 %token SAVE
61 %token OPEN
63 %type <list> modulelist
64 %type <list> modulename
65 %type <name> optional_filename
68 start:
69 { prompt(); } session
72 session:
73 session command_line
77 command_line:
78 command NEWLINE { prompt(); }
80 command:
81 open_command
82 | create_command
83 | verbose_command
84 | directory_command
85 | addlib_command
86 | clear_command
87 | addmod_command
88 | save_command
89 | replace_command
90 | delete_command
91 | list_command
92 | END { return 0; }
93 | error
98 replace_command:
99 REPLACE modulename
100 { ar_replace($2); }
103 clear_command:
104 CLEAR
105 { ar_clear(); }
108 delete_command:
109 DELETE modulename
110 { ar_delete($2); }
112 addmod_command:
113 ADDMOD modulename
114 { ar_addmod($2); }
117 list_command:
118 LIST
119 { ar_list(); }
122 save_command:
123 SAVE
124 { ar_save(); }
129 open_command:
130 OPEN FILENAME
131 { ar_open($2,0); }
134 create_command:
135 CREATE FILENAME
136 { ar_open($2,1); }
140 addlib_command:
141 ADDLIB FILENAME modulelist
142 { ar_addlib($2,$3); }
144 directory_command:
145 DIRECTORY FILENAME modulelist optional_filename
146 { ar_directory($2, $3, $4); }
151 optional_filename:
152 FILENAME
153 { $$ = $1; }
154 | { $$ = 0; }
157 modulelist:
158 '(' modulename ')'
159 { $$ = $2; }
161 { $$ = 0; }
164 modulename:
165 modulename optcomma FILENAME
166 { struct list *n = (struct list *) malloc(sizeof(struct list));
167 n->next = $1;
168 n->name = $3;
169 $$ = n;
171 | { $$ = 0; }
175 optcomma:
181 verbose_command:
182 VERBOSE
183 { verbose = !verbose; }
191 yyerror(x)
192 char *x;
194 extern int linenumber;
195 printf("Synax error in archive script, line %d\n", linenumber + 1);
196 return 0;