fix typo in last change
[deliverable/binutils-gdb.git] / binutils / arparse.y
CommitLineData
c0cc6912
SC
1%{
2/* arparse.y - Stange script language parser */
3
4/* Copyright (C) 1992 Free Software Foundation, Inc.
5
6This file is part of GNU Binutils.
7
8This program is free software; you can redistribute it and/or modify
9it under the terms of the GNU General Public License as published by
10the Free Software Foundation; either version 2 of the License, or
11(at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, 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"
31extern int interactive;
32extern bfd *inarch;
33extern int verbose;
34void (*command)();
35FILE *listing;
36%}
37
38%union {
39 char *name;
40struct 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
68start:
69 { prompt(); } session
70 ;
71
72session:
73 session command_line
74 |
75 ;
76
77command_line:
78 command NEWLINE { prompt(); }
79
80command:
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
98replace_command:
99 REPLACE modulename
100 { ar_replace($2); }
101 ;
102
103clear_command:
104 CLEAR
105 { ar_clear(); }
106 ;
107
108delete_command:
109 DELETE modulename
110 { ar_delete($2); }
111 ;
112addmod_command:
113 ADDMOD modulename
114 { ar_addmod($2); }
115 ;
116
117list_command:
118 LIST
119 { ar_list(); }
120 ;
121
122save_command:
123 SAVE
124 { ar_save(); }
125 ;
126
127
128
129open_command:
130 OPEN FILENAME
131 { ar_open($2,0); }
132 ;
133
134create_command:
135 CREATE FILENAME
136 { ar_open($2,1); }
137 ;
138
139
140addlib_command:
141 ADDLIB FILENAME modulelist
142 { ar_addlib($2,$3); }
143 ;
144directory_command:
145 DIRECTORY FILENAME modulelist optional_filename
146 { ar_directory($2, $3, $4); }
147 ;
148
149
150
151optional_filename:
152 FILENAME
153 { $$ = $1; }
154 | { $$ = 0; }
155 ;
156
157modulelist:
158 '(' modulename ')'
159 { $$ = $2; }
160 |
161 { $$ = 0; }
162 ;
163
164modulename:
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
175optcomma:
176 ','
177 |
178 ;
179
180
181verbose_command:
182 VERBOSE
183 { verbose = !verbose; }
184 ;
185
186
187%%
188
189
190int
191yyerror(x)
192char *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.129276 seconds and 4 git commands to generate.