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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [binutils-2.18.50/] [binutils/] [defparse.y] - Blame information for rev 868

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

Line No. Rev Author Line
1 38 julius
%{ /* defparse.y - parser for .def files */
2
 
3
/* Copyright 1995, 1997, 1998, 1999, 2001, 2004, 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
  int number;
32
};
33
 
34
%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
35
%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
36
%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
37
%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
38
%token  ID
39
%token  NUMBER
40
%type   opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
41
%type   attr attr_list opt_number
42
%type   opt_name opt_equal_name
43
 
44
%%
45
 
46
start: start command
47
        | command
48
        ;
49
 
50
command:
51
                NAME opt_name opt_base { def_name ($2, $3); }
52
        |       LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
53
        |       EXPORTS explist
54
        |       DESCRIPTION ID { def_description ($2);}
55
        |       STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
56
        |       HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
57
        |       CODE attr_list { def_code ($2);}
58
        |       DATA attr_list  { def_data ($2);}
59
        |       SECTIONS seclist
60
        |       IMPORTS implist
61
        |       VERSIONK NUMBER { def_version ($2,0);}
62
        |       VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
63
        ;
64
 
65
 
66
explist:
67
                /* EMPTY */
68
        |       explist expline
69
        ;
70
 
71
expline:
72
                ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
73
                        { def_exports ($1, $2, $3, $4, $5, $6, $7);}
74
        ;
75
implist:
76
                implist impline
77
        |       impline
78
        ;
79
 
80
impline:
81
               ID '=' ID '.' ID '.' ID     { def_import ($1,$3,$5,$7, 0); }
82
       |       ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); }
83
       |       ID '=' ID '.' ID            { def_import ($1,$3, 0,$5, 0); }
84
       |       ID '=' ID '.' NUMBER        { def_import ($1,$3, 0, 0,$5); }
85
       |       ID '.' ID '.' ID            { def_import ( 0,$1,$3,$5, 0); }
86
       |       ID '.' ID '.' NUMBER        { def_import ( 0,$1,$3, 0,$5); }
87
       |       ID '.' ID                   { def_import ( 0,$1, 0,$3, 0); }
88
       |       ID '.' NUMBER               { def_import ( 0,$1, 0, 0,$3); }
89
;
90
 
91
seclist:
92
                seclist secline
93
        |       secline
94
        ;
95
 
96
secline:
97
        ID attr_list { def_section ($1,$2);}
98
        ;
99
 
100
attr_list:
101
        attr_list opt_comma attr
102
        | attr
103
        ;
104
 
105
opt_comma:
106
        ','
107
        |
108
        ;
109
opt_number: ',' NUMBER { $$=$2;}
110
        |          { $$=-1;}
111
        ;
112
 
113
attr:
114
                READ { $$ = 1; }
115
        |       WRITE { $$ = 2; }
116
        |       EXECUTE { $$ = 4; }
117
        |       SHARED { $$ = 8; }
118
        |       NONSHARED { $$ = 0; }
119
        |       SINGLE { $$ = 0; }
120
        |       MULTIPLE { $$ = 0; }
121
        ;
122
 
123
opt_CONSTANT:
124
                CONSTANT {$$=1;}
125
        |                {$$=0;}
126
        ;
127
 
128
opt_NONAME:
129
                NONAME {$$=1;}
130
        |                {$$=0;}
131
        ;
132
 
133
opt_DATA:
134
                DATA { $$ = 1; }
135
        |            { $$ = 0; }
136
        ;
137
 
138
opt_PRIVATE:
139
                PRIVATE { $$ = 1; }
140
        |               { $$ = 0; }
141
        ;
142
 
143
opt_name: ID            { $$ =$1; }
144
        | ID '.' ID
145
          {
146
            char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
147
            sprintf (name, "%s.%s", $1, $3);
148
            $$ = name;
149
          }
150
        |               { $$=""; }
151
        ;
152
 
153
opt_ordinal:
154
          '@' NUMBER     { $$=$2;}
155
        |                { $$=-1;}
156
        ;
157
 
158
opt_equal_name:
159
          '=' ID        { $$ = $2; }
160
        | '=' ID '.' ID
161
          {
162
            char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1);
163
            sprintf (name, "%s.%s", $2, $4);
164
            $$ = name;
165
          }
166
        |               { $$ =  0; }
167
        ;
168
 
169
opt_base: BASE  '=' NUMBER      { $$= $3;}
170
        |       { $$=-1;}
171
        ;
172
 
173
option_list:
174
                /* empty */
175
        |       option_list opt_comma option
176
        ;
177
 
178
option:
179
                INITINSTANCE
180
        |       INITGLOBAL
181
        |       TERMINSTANCE
182
        |       TERMGLOBAL
183
        ;

powered by: WebSVN 2.1.0

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