Wed Apr 15 14:33:07 1992 Steve Chamberlain (sac@thepub.cygnus.com)
[deliverable/binutils-gdb.git] / binutils / arparse.y
1 %{
2 /* arparse.y - Stange script language parser */
3
4 /* Copyright (C) 1992 Free Software Foundation, Inc.
5
6 This file is part of GNU Binutils.
7
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.
12
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.
17
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. */
21
22
23 /* Contributed by Steve Chamberlain
24 sac@cygnus.com
25
26 */
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;
36 %}
37
38 %union {
39 char *name;
40 struct list *list ;
41
42 };
43
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
62
63 %type <list> modulelist
64 %type <list> modulename
65 %type <name> optional_filename
66 %%
67
68 start:
69 { prompt(); } session
70 ;
71
72 session:
73 session command_line
74 |
75 ;
76
77 command_line:
78 command NEWLINE { prompt(); }
79
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
94 |
95 ;
96
97
98 replace_command:
99 REPLACE modulename
100 { ar_replace($2); }
101 ;
102
103 clear_command:
104 CLEAR
105 { ar_clear(); }
106 ;
107
108 delete_command:
109 DELETE modulename
110 { ar_delete($2); }
111 ;
112 addmod_command:
113 ADDMOD modulename
114 { ar_addmod($2); }
115 ;
116
117 list_command:
118 LIST
119 { ar_list(); }
120 ;
121
122 save_command:
123 SAVE
124 { ar_save(); }
125 ;
126
127
128
129 open_command:
130 OPEN FILENAME
131 { ar_open($2,0); }
132 ;
133
134 create_command:
135 CREATE FILENAME
136 { ar_open($2,1); }
137 ;
138
139
140 addlib_command:
141 ADDLIB FILENAME modulelist
142 { ar_addlib($2,$3); }
143 ;
144 directory_command:
145 DIRECTORY FILENAME modulelist optional_filename
146 { ar_directory($2, $3, $4); }
147 ;
148
149
150
151 optional_filename:
152 FILENAME
153 { $$ = $1; }
154 | { $$ = 0; }
155 ;
156
157 modulelist:
158 '(' modulename ')'
159 { $$ = $2; }
160 |
161 { $$ = 0; }
162 ;
163
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;
170 }
171 | { $$ = 0; }
172 ;
173
174
175 optcomma:
176 ','
177 |
178 ;
179
180
181 verbose_command:
182 VERBOSE
183 { verbose = !verbose; }
184 ;
185
186
187 %%
188
189
190 int
191 yyerror(x)
192 char *x;
193 {
194 extern int linenumber;
195 printf("Synax error in archive script, line %d\n", linenumber + 1);
196 return 0;
197 }
This page took 0.039031 seconds and 5 git commands to generate.