Update FSF address
[deliverable/binutils-gdb.git] / binutils / defparse.y
CommitLineData
252b5132
RH
1%{ /* defparse.y - parser for .def files */
2
aef6203b 3/* Copyright 1995, 1997, 1998, 1999, 2001, 2004
7aa52b1f 4 Free Software Foundation, Inc.
252b5132 5
7aa52b1f 6 This file is part of GNU Binutils.
252b5132 7
7aa52b1f
NC
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 2 of the License, or
11 (at your option) any later version.
252b5132 12
7aa52b1f
NC
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.
252b5132 17
7aa52b1f
NC
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
b43b5d5f 20 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
252b5132
RH
21
22#include "bfd.h"
23#include "bucomm.h"
24#include "dlltool.h"
25%}
26
27%union {
28 char *id;
29 int number;
30};
31
74aba8aa
DS
32%token NAME LIBRARY DESCRIPTION STACKSIZE HEAPSIZE CODE DATA
33%token SECTIONS EXPORTS IMPORTS VERSIONK BASE CONSTANT
7aa52b1f 34%token READ WRITE EXECUTE SHARED NONSHARED NONAME PRIVATE
d7ec8102 35%token SINGLE MULTIPLE INITINSTANCE INITGLOBAL TERMINSTANCE TERMGLOBAL
252b5132
RH
36%token <id> ID
37%token <number> NUMBER
7aa52b1f 38%type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
252b5132
RH
39%type <number> attr attr_list opt_number
40%type <id> opt_name opt_equal_name
41
42%%
43
44start: start command
45 | command
46 ;
47
48command:
49 NAME opt_name opt_base { def_name ($2, $3); }
d7ec8102 50 | LIBRARY opt_name opt_base option_list { def_library ($2, $3); }
252b5132
RH
51 | EXPORTS explist
52 | DESCRIPTION ID { def_description ($2);}
53 | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
54 | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
55 | CODE attr_list { def_code ($2);}
56 | DATA attr_list { def_data ($2);}
57 | SECTIONS seclist
58 | IMPORTS implist
59 | VERSIONK NUMBER { def_version ($2,0);}
60 | VERSIONK NUMBER '.' NUMBER { def_version ($2,$4);}
61 ;
62
63
64explist:
65 /* EMPTY */
252b5132
RH
66 | explist expline
67 ;
68
69expline:
7aa52b1f
NC
70 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA opt_PRIVATE
71 { def_exports ($1, $2, $3, $4, $5, $6, $7);}
252b5132
RH
72 ;
73implist:
74 implist impline
75 | impline
76 ;
77
78impline:
79 ID '=' ID '.' ID '.' ID { def_import ($1,$3,$5,$7, 0); }
80 | ID '=' ID '.' ID '.' NUMBER { def_import ($1,$3,$5, 0,$7); }
81 | ID '=' ID '.' ID { def_import ($1,$3, 0,$5, 0); }
82 | ID '=' ID '.' NUMBER { def_import ($1,$3, 0, 0,$5); }
83 | ID '.' ID '.' ID { def_import ( 0,$1,$3,$5, 0); }
84 | ID '.' ID '.' NUMBER { def_import ( 0,$1,$3, 0,$5); }
85 | ID '.' ID { def_import ( 0,$1, 0,$3, 0); }
86 | ID '.' NUMBER { def_import ( 0,$1, 0, 0,$3); }
87;
88
89seclist:
90 seclist secline
91 | secline
92 ;
93
94secline:
95 ID attr_list { def_section ($1,$2);}
96 ;
97
98attr_list:
99 attr_list opt_comma attr
100 | attr
101 ;
102
103opt_comma:
104 ','
105 |
106 ;
107opt_number: ',' NUMBER { $$=$2;}
108 | { $$=-1;}
109 ;
110
111attr:
d7ec8102
ILT
112 READ { $$ = 1; }
113 | WRITE { $$ = 2; }
114 | EXECUTE { $$ = 4; }
115 | SHARED { $$ = 8; }
116 | NONSHARED { $$ = 0; }
117 | SINGLE { $$ = 0; }
118 | MULTIPLE { $$ = 0; }
252b5132
RH
119 ;
120
121opt_CONSTANT:
122 CONSTANT {$$=1;}
123 | {$$=0;}
124 ;
125
126opt_NONAME:
127 NONAME {$$=1;}
128 | {$$=0;}
129 ;
130
131opt_DATA:
132 DATA { $$ = 1; }
133 | { $$ = 0; }
134 ;
135
7aa52b1f
NC
136opt_PRIVATE:
137 PRIVATE { $$ = 1; }
138 | { $$ = 0; }
139 ;
140
252b5132
RH
141opt_name: ID { $$ =$1; }
142 | ID '.' ID
143 {
144 char *name = xmalloc (strlen ($1) + 1 + strlen ($3) + 1);
145 sprintf (name, "%s.%s", $1, $3);
146 $$ = name;
147 }
148 | { $$=""; }
149 ;
150
151opt_ordinal:
152 '@' NUMBER { $$=$2;}
153 | { $$=-1;}
154 ;
155
156opt_equal_name:
157 '=' ID { $$ = $2; }
04847a4d
CF
158 | '=' ID '.' ID
159 {
160 char *name = xmalloc (strlen ($2) + 1 + strlen ($4) + 1);
161 sprintf (name, "%s.%s", $2, $4);
162 $$ = name;
163 }
252b5132
RH
164 | { $$ = 0; }
165 ;
166
167opt_base: BASE '=' NUMBER { $$= $3;}
168 | { $$=-1;}
169 ;
170
d7ec8102
ILT
171option_list:
172 /* empty */
173 | option_list opt_comma option
174 ;
252b5132 175
d7ec8102
ILT
176option:
177 INITINSTANCE
178 | INITGLOBAL
179 | TERMINSTANCE
180 | TERMGLOBAL
181 ;
This page took 0.270052 seconds and 4 git commands to generate.