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