Commit | Line | Data |
---|---|---|
252b5132 RH |
1 | %{ |
2 | /* arparse.y - Stange script language parser */ | |
3 | ||
aef6203b | 4 | /* Copyright 1992, 1993, 1995, 1997, 1999, 2002, 2003 |
2da42df6 | 5 | Free Software Foundation, Inc. |
252b5132 RH |
6 | |
7 | This file is part of GNU Binutils. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 2 of the License, or | |
12 | (at your option) any later version. | |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with this program; if not, write to the Free Software | |
b43b5d5f | 21 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
252b5132 RH |
22 | |
23 | ||
24 | /* Contributed by Steve Chamberlain | |
25 | sac@cygnus.com | |
26 | ||
27 | */ | |
28 | #define DONTDECLARE_MALLOC | |
29 | #include "bfd.h" | |
30 | #include "bucomm.h" | |
31 | #include "arsup.h" | |
32 | extern int verbose; | |
2da42df6 AJ |
33 | extern int yylex (void); |
34 | static int yyerror (const char *); | |
252b5132 RH |
35 | %} |
36 | ||
37 | %union { | |
38 | char *name; | |
39 | struct list *list ; | |
40 | ||
41 | }; | |
42 | ||
43 | %token NEWLINE | |
44 | %token VERBOSE | |
45 | %token <name> FILENAME | |
46 | %token ADDLIB | |
47 | %token LIST | |
48 | %token ADDMOD | |
49 | %token CLEAR | |
50 | %token CREATE | |
51 | %token DELETE | |
52 | %token DIRECTORY | |
53 | %token END | |
54 | %token EXTRACT | |
55 | %token FULLDIR | |
56 | %token HELP | |
57 | %token QUIT | |
58 | %token REPLACE | |
59 | %token SAVE | |
60 | %token OPEN | |
61 | ||
62 | %type <list> modulelist | |
63 | %type <list> modulename | |
64 | %type <name> optional_filename | |
65 | %% | |
66 | ||
67 | start: | |
68 | { prompt(); } session | |
69 | ; | |
70 | ||
71 | session: | |
72 | session command_line | |
73 | | | |
74 | ; | |
75 | ||
76 | command_line: | |
77 | command NEWLINE { prompt(); } | |
944cd72c | 78 | ; |
252b5132 RH |
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 | | extract_command | |
90 | | replace_command | |
91 | | delete_command | |
92 | | list_command | |
93 | | END { ar_end(); return 0; } | |
94 | | error | |
95 | | FILENAME { yyerror("foo"); } | |
96 | | | |
97 | ; | |
98 | ||
99 | ||
100 | extract_command: | |
101 | EXTRACT modulename | |
102 | { ar_extract($2); } | |
103 | ; | |
104 | ||
105 | replace_command: | |
106 | REPLACE modulename | |
107 | { ar_replace($2); } | |
108 | ; | |
109 | ||
110 | clear_command: | |
111 | CLEAR | |
112 | { ar_clear(); } | |
113 | ; | |
114 | ||
115 | delete_command: | |
116 | DELETE modulename | |
117 | { ar_delete($2); } | |
118 | ; | |
119 | addmod_command: | |
120 | ADDMOD modulename | |
121 | { ar_addmod($2); } | |
122 | ; | |
123 | ||
124 | list_command: | |
125 | LIST | |
126 | { ar_list(); } | |
127 | ; | |
128 | ||
129 | save_command: | |
130 | SAVE | |
131 | { ar_save(); } | |
132 | ; | |
133 | ||
134 | ||
135 | ||
136 | open_command: | |
137 | OPEN FILENAME | |
138 | { ar_open($2,0); } | |
139 | ; | |
140 | ||
141 | create_command: | |
142 | CREATE FILENAME | |
143 | { ar_open($2,1); } | |
144 | ; | |
145 | ||
146 | ||
147 | addlib_command: | |
148 | ADDLIB FILENAME modulelist | |
149 | { ar_addlib($2,$3); } | |
150 | ; | |
151 | directory_command: | |
152 | DIRECTORY FILENAME modulelist optional_filename | |
153 | { ar_directory($2, $3, $4); } | |
154 | ; | |
155 | ||
156 | ||
157 | ||
158 | optional_filename: | |
159 | FILENAME | |
160 | { $$ = $1; } | |
161 | | { $$ = 0; } | |
162 | ; | |
163 | ||
164 | modulelist: | |
165 | '(' modulename ')' | |
166 | { $$ = $2; } | |
167 | | | |
168 | { $$ = 0; } | |
169 | ; | |
170 | ||
171 | modulename: | |
172 | modulename optcomma FILENAME | |
173 | { struct list *n = (struct list *) malloc(sizeof(struct list)); | |
174 | n->next = $1; | |
175 | n->name = $3; | |
176 | $$ = n; | |
177 | } | |
178 | | { $$ = 0; } | |
179 | ; | |
180 | ||
181 | ||
182 | optcomma: | |
183 | ',' | |
184 | | | |
185 | ; | |
186 | ||
187 | ||
188 | verbose_command: | |
189 | VERBOSE | |
190 | { verbose = !verbose; } | |
191 | ; | |
192 | ||
193 | ||
194 | %% | |
195 | ||
196 | static int | |
2da42df6 | 197 | yyerror (const char *x ATTRIBUTE_UNUSED) |
252b5132 RH |
198 | { |
199 | extern int linenumber; | |
200 | ||
201 | printf (_("Syntax error in archive script, line %d\n"), linenumber + 1); | |
202 | return 0; | |
203 | } |