* object.h (class Relocate_info): Add reloc_shdr and data_shdr
[deliverable/binutils-gdb.git] / binutils / arparse.y
CommitLineData
252b5132
RH
1%{
2/* arparse.y - Stange script language parser */
3
aa820537 4/* Copyright 1992, 1993, 1995, 1997, 1999, 2002, 2003, 2005, 2007
32866df7 5 Free Software Foundation, Inc.
252b5132 6
32866df7 7 This file is part of GNU Binutils.
252b5132 8
32866df7
NC
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 3 of the License, or
12 (at your option) any later version.
252b5132 13
32866df7
NC
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.
252b5132 18
32866df7
NC
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
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
252b5132
RH
23
24
25/* Contributed by Steve Chamberlain
26 sac@cygnus.com
27
28*/
29#define DONTDECLARE_MALLOC
3db64b00 30#include "sysdep.h"
252b5132 31#include "bfd.h"
252b5132
RH
32#include "arsup.h"
33extern int verbose;
2da42df6
AJ
34extern int yylex (void);
35static int yyerror (const char *);
252b5132
RH
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(); }
944cd72c 79 ;
252b5132
RH
80
81command:
82 open_command
83 | create_command
84 | verbose_command
85 | directory_command
86 | addlib_command
87 | clear_command
88 | addmod_command
89 | save_command
90 | extract_command
91 | replace_command
92 | delete_command
93 | list_command
94 | END { ar_end(); return 0; }
95 | error
96 | FILENAME { yyerror("foo"); }
97 |
98 ;
99
100
101extract_command:
102 EXTRACT modulename
103 { ar_extract($2); }
104 ;
105
106replace_command:
107 REPLACE modulename
108 { ar_replace($2); }
109 ;
110
111clear_command:
112 CLEAR
113 { ar_clear(); }
114 ;
115
116delete_command:
117 DELETE modulename
118 { ar_delete($2); }
119 ;
120addmod_command:
121 ADDMOD modulename
122 { ar_addmod($2); }
123 ;
124
125list_command:
126 LIST
127 { ar_list(); }
128 ;
129
130save_command:
131 SAVE
132 { ar_save(); }
133 ;
134
135
136
137open_command:
138 OPEN FILENAME
139 { ar_open($2,0); }
140 ;
141
142create_command:
143 CREATE FILENAME
144 { ar_open($2,1); }
145 ;
146
147
148addlib_command:
149 ADDLIB FILENAME modulelist
150 { ar_addlib($2,$3); }
151 ;
152directory_command:
153 DIRECTORY FILENAME modulelist optional_filename
154 { ar_directory($2, $3, $4); }
155 ;
156
157
158
159optional_filename:
160 FILENAME
161 { $$ = $1; }
162 | { $$ = 0; }
163 ;
164
165modulelist:
166 '(' modulename ')'
167 { $$ = $2; }
168 |
169 { $$ = 0; }
170 ;
171
172modulename:
173 modulename optcomma FILENAME
174 { struct list *n = (struct list *) malloc(sizeof(struct list));
175 n->next = $1;
176 n->name = $3;
177 $$ = n;
178 }
179 | { $$ = 0; }
180 ;
181
182
183optcomma:
184 ','
185 |
186 ;
187
188
189verbose_command:
190 VERBOSE
191 { verbose = !verbose; }
192 ;
193
194
195%%
196
197static int
2da42df6 198yyerror (const char *x ATTRIBUTE_UNUSED)
252b5132
RH
199{
200 extern int linenumber;
201
202 printf (_("Syntax error in archive script, line %d\n"), linenumber + 1);
203 return 0;
204}
This page took 0.380274 seconds and 4 git commands to generate.