* elf64-ppc.c: Don't include elf/ppc.h.
[deliverable/binutils-gdb.git] / binutils / arparse.y
CommitLineData
252b5132
RH
1%{
2/* arparse.y - Stange script language parser */
3
8c2bc687 4/* Copyright 1992, 1993, 1995, 1997, 1999 Free Software Foundation, Inc.
252b5132
RH
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21
22
23/* Contributed by Steve Chamberlain
24 sac@cygnus.com
25
26*/
27#define DONTDECLARE_MALLOC
28#include "bfd.h"
29#include "bucomm.h"
30#include "arsup.h"
31extern int verbose;
32extern int yylex PARAMS ((void));
33static int yyerror PARAMS ((const char *));
34%}
35
36%union {
37 char *name;
38struct list *list ;
39
40};
41
42%token NEWLINE
43%token VERBOSE
44%token <name> FILENAME
45%token ADDLIB
46%token LIST
47%token ADDMOD
48%token CLEAR
49%token CREATE
50%token DELETE
51%token DIRECTORY
52%token END
53%token EXTRACT
54%token FULLDIR
55%token HELP
56%token QUIT
57%token REPLACE
58%token SAVE
59%token OPEN
60
61%type <list> modulelist
62%type <list> modulename
63%type <name> optional_filename
64%%
65
66start:
67 { prompt(); } session
68 ;
69
70session:
71 session command_line
72 |
73 ;
74
75command_line:
76 command NEWLINE { prompt(); }
944cd72c 77 ;
252b5132
RH
78
79command:
80 open_command
81 | create_command
82 | verbose_command
83 | directory_command
84 | addlib_command
85 | clear_command
86 | addmod_command
87 | save_command
88 | extract_command
89 | replace_command
90 | delete_command
91 | list_command
92 | END { ar_end(); return 0; }
93 | error
94 | FILENAME { yyerror("foo"); }
95 |
96 ;
97
98
99extract_command:
100 EXTRACT modulename
101 { ar_extract($2); }
102 ;
103
104replace_command:
105 REPLACE modulename
106 { ar_replace($2); }
107 ;
108
109clear_command:
110 CLEAR
111 { ar_clear(); }
112 ;
113
114delete_command:
115 DELETE modulename
116 { ar_delete($2); }
117 ;
118addmod_command:
119 ADDMOD modulename
120 { ar_addmod($2); }
121 ;
122
123list_command:
124 LIST
125 { ar_list(); }
126 ;
127
128save_command:
129 SAVE
130 { ar_save(); }
131 ;
132
133
134
135open_command:
136 OPEN FILENAME
137 { ar_open($2,0); }
138 ;
139
140create_command:
141 CREATE FILENAME
142 { ar_open($2,1); }
143 ;
144
145
146addlib_command:
147 ADDLIB FILENAME modulelist
148 { ar_addlib($2,$3); }
149 ;
150directory_command:
151 DIRECTORY FILENAME modulelist optional_filename
152 { ar_directory($2, $3, $4); }
153 ;
154
155
156
157optional_filename:
158 FILENAME
159 { $$ = $1; }
160 | { $$ = 0; }
161 ;
162
163modulelist:
164 '(' modulename ')'
165 { $$ = $2; }
166 |
167 { $$ = 0; }
168 ;
169
170modulename:
171 modulename optcomma FILENAME
172 { struct list *n = (struct list *) malloc(sizeof(struct list));
173 n->next = $1;
174 n->name = $3;
175 $$ = n;
176 }
177 | { $$ = 0; }
178 ;
179
180
181optcomma:
182 ','
183 |
184 ;
185
186
187verbose_command:
188 VERBOSE
189 { verbose = !verbose; }
190 ;
191
192
193%%
194
195static int
196yyerror (x)
b4c96d0d 197 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}
This page took 0.163099 seconds and 4 git commands to generate.