OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [binutils-2.20.1/] [binutils/] [arparse.y] - Blame information for rev 205

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
%{
2
/* arparse.y - Stange script language parser */
3
 
4
/* Copyright 1992, 1993, 1995, 1997, 1999, 2002, 2003, 2005, 2007
5
   Free Software Foundation, Inc.
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 3 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
21
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22
   MA 02110-1301, USA.  */
23
 
24
 
25
/* Contributed by Steve Chamberlain
26
                  sac@cygnus.com
27
 
28
*/
29
#define DONTDECLARE_MALLOC
30
#include "sysdep.h"
31
#include "bfd.h"
32
#include "arsup.h"
33
extern int verbose;
34
extern int yylex (void);
35
static int yyerror (const char *);
36
%}
37
 
38
%union {
39
  char *name;
40
struct list *list ;
41
 
42
};
43
 
44
%token NEWLINE
45
%token VERBOSE
46
%token  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  modulelist
64
%type  modulename
65
%type  optional_filename
66
%%
67
 
68
start:
69
        { prompt(); } session
70
        ;
71
 
72
session:
73
            session command_line
74
        |
75
        ;
76
 
77
command_line:
78
                command NEWLINE { prompt(); }
79
        ;
80
 
81
command:
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
 
101
extract_command:
102
                EXTRACT modulename
103
                { ar_extract($2); }
104
        ;
105
 
106
replace_command:
107
                REPLACE modulename
108
                { ar_replace($2); }
109
        ;
110
 
111
clear_command:
112
                CLEAR
113
                { ar_clear(); }
114
        ;
115
 
116
delete_command:
117
                DELETE modulename
118
                { ar_delete($2); }
119
        ;
120
addmod_command:
121
        ADDMOD modulename
122
                { ar_addmod($2); }
123
        ;
124
 
125
list_command:
126
                LIST
127
                { ar_list(); }
128
        ;
129
 
130
save_command:
131
                SAVE
132
                { ar_save(); }
133
        ;
134
 
135
 
136
 
137
open_command:
138
                OPEN FILENAME
139
                { ar_open($2,0); }
140
        ;
141
 
142
create_command:
143
                CREATE FILENAME
144
                { ar_open($2,1); }
145
        ;
146
 
147
 
148
addlib_command:
149
                ADDLIB FILENAME modulelist
150
                { ar_addlib($2,$3); }
151
        ;
152
directory_command:
153
                DIRECTORY FILENAME modulelist optional_filename
154
                { ar_directory($2, $3, $4); }
155
        ;
156
 
157
 
158
 
159
optional_filename:
160
                FILENAME
161
                { $$ = $1; }
162
        |       { $$ = 0; }
163
        ;
164
 
165
modulelist:
166
        '(' modulename ')'
167
                { $$ = $2; }
168
        |
169
                { $$ = 0; }
170
        ;
171
 
172
modulename:
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
 
183
optcomma:
184
                ','
185
        |
186
        ;
187
 
188
 
189
verbose_command:
190
        VERBOSE
191
                { verbose = !verbose; }
192
        ;
193
 
194
 
195
%%
196
 
197
static int
198
yyerror (const char *x ATTRIBUTE_UNUSED)
199
{
200
  extern int linenumber;
201
 
202
  printf (_("Syntax error in archive script, line %d\n"), linenumber + 1);
203
  return 0;
204
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.