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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [binutils/] [defparse.y] - Blame information for rev 231

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

Line No. Rev Author Line
1 15 khays
%{ /* defparse.y - parser for .def files */
2
 
3
/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 2005, 2007
4
   Free Software Foundation, Inc.
5
 
6
   This file is part of GNU Binutils.
7
 
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 3 of the License, or
11
   (at your option) any later version.
12
 
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
 
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21
   MA 02110-1301, USA.  */
22
 
23
#include "sysdep.h"
24
#include "bfd.h"
25
#include "libiberty.h"
26
#include "dlltool.h"
27
%}
28
 
29
%union {
30
  char *id;
31 166 khays
  const char *id_const;
32 15 khays
  int number;
33
};
34
 
35
%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
36
%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
37
%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
38
%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
39
%token EQUAL
40
%token  ID
41
%token  NUMBER
42
%type   opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
43
%type   attr attr_list opt_number
44 166 khays
%type   opt_name opt_name2 opt_equal_name opt_import_name
45
%type   keyword_as_name
46 15 khays
 
47
%%
48
 
49
start: start command
50
        | command
51
        ;
52
 
53
command:
54
                NAME opt_name opt_base { def_name ($2, $3); }
55
        |       LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
56
        |       EXPORTS explist
57
        |       DESCRIPTION ID { def_description ($2);}
58
        |       STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
59
        |       HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
60
        |       CODE attr_list { def_code ($2);}
61
        |       DATA attr_list  { def_data ($2);}
62
        |       SECTIONS seclist
63
        |       IMPORTS implist
64
        |       VERSIONK NUMBER { def_version ($2,0);}
65
        |       VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
66
        ;
67
 
68
 
69
explist:
70
                /* EMPTY */
71
        |       explist expline
72
        ;
73
 
74
expline:
75
                ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
76
                opt_import_name
77
                        { def_exports ($1, $2, $3, $4, $5, $6, $7, $8);}
78
        ;
79
implist:
80
                implist impline
81
        |       impline
82
        ;
83
 
84
impline:
85
               ID '=' ID '.' ID '.' ID opt_import_name
86
                 { def_import ($1,$3,$5,$7, 0, $8); }
87
       |       ID '=' ID '.' ID '.' NUMBER opt_import_name
88
                 { def_import ($1,$3,$5, 0,$7, $8); }
89
       |       ID '=' ID '.' ID opt_import_name
90
                 { def_import ($1,$3, 0,$5, 0, $6); }
91
       |       ID '=' ID '.' NUMBER opt_import_name
92
                 { def_import ($1,$3, 0, 0,$5, $6); }
93
       |       ID '.' ID '.' ID opt_import_name
94
                 { def_import ( 0,$1,$3,$5, 0, $6); }
95
       |       ID '.' ID '.' NUMBER opt_import_name
96
                 { def_import ( 0,$1,$3, 0,$5, $6); }
97
       |       ID '.' ID opt_import_name
98
                 { def_import ( 0,$1, 0,$3, 0, $4); }
99
       |       ID '.' NUMBER opt_import_name
100
                 { def_import ( 0,$1, 0, 0,$3, $4); }
101
;
102
 
103
seclist:
104
                seclist secline
105
        |       secline
106
        ;
107
 
108
secline:
109
        ID attr_list { def_section ($1,$2);}
110
        ;
111
 
112
attr_list:
113
        attr_list opt_comma attr
114
        | attr
115
        ;
116
 
117
opt_comma:
118
        ','
119
        |
120
        ;
121
opt_number: ',' NUMBER { $$=$2;}
122
        |          { $$=-1;}
123
        ;
124
 
125
attr:
126
                READ { $$ = 1; }
127
        |       WRITE { $$ = 2; }
128
        |       EXECUTE { $$ = 4; }
129
        |       SHARED { $$ = 8; }
130
        |       NONSHARED { $$ = 0; }
131
        |       SINGLE { $$ = 0; }
132
        |       MULTIPLE { $$ = 0; }
133
        ;
134
 
135
opt_CONSTANT:
136
                CONSTANT {$$=1;}
137
        |                {$$=0;}
138
        ;
139
 
140
opt_NONAME:
141
                NONAME {$$=1;}
142
        |                {$$=0;}
143
        ;
144
 
145
opt_DATA:
146
                DATA { $$ = 1; }
147
        |            { $$ = 0; }
148
        ;
149
 
150
opt_PRIVATE:
151
                PRIVATE { $$ = 1; }
152
        |               { $$ = 0; }
153
        ;
154
 
155 166 khays
keyword_as_name: NAME { $$ = "NAME"; }
156
/*  Disabled LIBRARY keyword for a quirk in libtool. It places LIBRARY
157
    command after EXPORTS list, which is illegal by specification.
158
    See PR binutils/13710
159
        | LIBRARY { $$ = "LIBRARY"; } */
160
        | DESCRIPTION { $$ = "DESCRIPTION"; }
161
        | STACKSIZE { $$ = "STACKSIZE"; }
162
        | HEAPSIZE { $$ = "HEAPSIZE"; }
163
        | CODE { $$ = "CODE"; }
164
        | DATA { $$ = "DATA"; }
165
        | SECTIONS { $$ = "SECTIONS"; }
166
        | EXPORTS { $$ = "EXPORTS"; }
167
        | IMPORTS { $$ = "IMPORTS"; }
168
        | VERSIONK { $$ = "VERSION"; }
169
        | BASE { $$ = "BASE"; }
170
        | CONSTANT { $$ = "CONSTANT"; }
171
        | NONAME { $$ = "NONAME"; }
172
        | PRIVATE { $$ = "PRIVATE"; }
173
        | READ { $$ = "READ"; }
174
        | WRITE { $$ = "WRITE"; }
175
        | EXECUTE { $$ = "EXECUTE"; }
176
        | SHARED { $$ = "SHARED"; }
177
        | NONSHARED { $$ = "NONSHARED"; }
178
        | SINGLE { $$ = "SINGLE"; }
179
        | MULTIPLE { $$ = "MULTIPLE"; }
180
        | INITINSTANCE { $$ = "INITINSTANCE"; }
181
        | INITGLOBAL { $$ = "INITGLOBAL"; }
182
        | TERMINSTANCE { $$ = "TERMINSTANCE"; }
183
        | TERMGLOBAL { $$ = "TERMGLOBAL"; }
184
        ;
185
 
186
opt_name2: ID { $$ = $1; }
187
        | '.' keyword_as_name
188
          {
189
            char *name = xmalloc (strlen ($2) + 2);
190
            sprintf (name, ".%s", $2);
191
            $$ = name;
192
          }
193
        | '.' opt_name2
194 15 khays
          {
195 166 khays
            char *name = xmalloc (strlen ($2) + 2);
196
            sprintf (name, ".%s", $2);
197
            $$ = name;
198
          }
199
        | keyword_as_name '.' opt_name2
200
          {
201 15 khays
            char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
202
            sprintf (name, "%s.%s", $1, $3);
203
            $$ = name;
204
          }
205 166 khays
        | ID '.' opt_name2
206
          {
207
            char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
208
            sprintf (name, "%s.%s", $1, $3);
209
            $$ = name;
210
          }
211
        ;
212
opt_name: opt_name2 { $$ =$1; }
213 15 khays
        |               { $$=""; }
214
        ;
215
 
216
opt_ordinal:
217
          '@' NUMBER     { $$=$2;}
218
        |                { $$=-1;}
219
        ;
220
 
221
opt_import_name:
222 166 khays
          EQUAL opt_name2       { $$ = $2; }
223 15 khays
        |               { $$ = 0; }
224
        ;
225
 
226
opt_equal_name:
227 166 khays
          '=' opt_name2 { $$ = $2; }
228 15 khays
        |               { $$ =  0; }
229
        ;
230
 
231
opt_base: BASE  '=' NUMBER      { $$= $3;}
232
        |       { $$=-1;}
233
        ;
234
 
235
option_list:
236
                /* empty */
237
        |       option_list opt_comma option
238
        ;
239
 
240
option:
241
                INITINSTANCE
242
        |       INITGLOBAL
243
        |       TERMINSTANCE
244
        |       TERMGLOBAL
245
        ;

powered by: WebSVN 2.1.0

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