]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - binutils/defparse.y
21b687655986a6923a7e52770076a1e8bfc0eea9
[thirdparty/binutils-gdb.git] / binutils / defparse.y
1 %{ /* defparse.y - parser for .def files */
2
3 /* Copyright (C) 1995, 1997 Free Software Foundation, Inc.
4
5 This file is part of GNU Binutils.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
20
21 #include "bfd.h"
22 #include "bucomm.h"
23 #include "dlltool.h"
24 %}
25
26 %union {
27 char *id;
28 int number;
29 };
30
31 %token NAME, LIBRARY, DESCRIPTION, STACKSIZE, HEAPSIZE, CODE, DATA
32 %token SECTIONS, EXPORTS, IMPORTS, VERSION, BASE, CONSTANT
33 %token READ WRITE EXECUTE SHARED NONAME
34 %token <id> ID
35 %token <number> NUMBER
36 %type <number> opt_base opt_ordinal opt_NONAME opt_CONSTANT opt_DATA
37 %type <number> attr attr_list opt_number
38 %type <id> opt_name opt_equal_name
39
40 %%
41
42 start: start command
43 | command
44 ;
45
46 command:
47 NAME opt_name opt_base { def_name ($2, $3); }
48 | LIBRARY opt_name opt_base { def_library ($2, $3); }
49 | EXPORTS explist
50 | DESCRIPTION ID { def_description ($2);}
51 | STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
52 | HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
53 | CODE attr_list { def_code ($2);}
54 | DATA attr_list { def_data ($2);}
55 | SECTIONS seclist
56 | IMPORTS implist
57 | VERSION NUMBER { def_version ($2,0);}
58 | VERSION NUMBER '.' NUMBER { def_version ($2,$4);}
59 ;
60
61
62 explist:
63 explist expline
64 | expline
65 ;
66
67 expline:
68 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT opt_DATA
69 { def_exports ($1, $2, $3, $4, $5, $6);}
70 ;
71 implist:
72 implist impline
73 | impline
74 ;
75
76 impline:
77 ID '=' ID '.' ID { def_import ($1,$3,$5);}
78 | ID '.' ID { def_import (0, $1,$3);}
79 ;
80 seclist:
81 seclist secline
82 | secline
83 ;
84
85 secline:
86 ID attr_list { def_section ($1,$2);}
87 ;
88
89 attr_list:
90 attr_list opt_comma attr
91 | attr
92 ;
93
94 opt_comma:
95 ','
96 |
97 ;
98 opt_number: ',' NUMBER { $$=$2;}
99 | { $$=-1;}
100 ;
101
102 attr:
103 READ { $$ = 1;}
104 | WRITE { $$ = 2;}
105 | EXECUTE { $$=4;}
106 | SHARED { $$=8;}
107 ;
108
109 opt_CONSTANT:
110 CONSTANT {$$=1;}
111 | {$$=0;}
112 ;
113
114 opt_NONAME:
115 NONAME {$$=1;}
116 | {$$=0;}
117 ;
118
119 opt_DATA:
120 DATA { $$ = 1; }
121 | { $$ = 0; }
122 ;
123
124 opt_name: ID { $$ =$1; }
125 | { $$=""; }
126 ;
127
128 opt_ordinal:
129 '@' NUMBER { $$=$2;}
130 | { $$=-1;}
131 ;
132
133 opt_equal_name:
134 '=' ID { $$ = $2; }
135 | { $$ = 0; }
136 ;
137
138 opt_base: BASE '=' NUMBER { $$= $3;}
139 | { $$=-1;}
140 ;
141
142
143