* dlltool.h: New file.
[platform/upstream/binutils.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 attr attr_list opt_number
37 %type  <id> opt_name opt_equal_name 
38
39 %%
40
41 start: start command
42         | command
43         ;
44
45 command: 
46                 NAME opt_name opt_base { def_name ($2, $3); }
47         |       LIBRARY opt_name opt_base { def_library ($2, $3); }
48         |       EXPORTS explist 
49         |       DESCRIPTION ID { def_description ($2);}
50         |       STACKSIZE NUMBER opt_number { def_stacksize ($2, $3);}
51         |       HEAPSIZE NUMBER opt_number { def_heapsize ($2, $3);}
52         |       CODE attr_list { def_code ($2);}
53         |       DATA attr_list  { def_data ($2);}
54         |       SECTIONS seclist
55         |       IMPORTS implist
56         |       VERSION NUMBER { def_version ($2,0);}
57         |       VERSION NUMBER '.' NUMBER { def_version ($2,$4);}
58         ;
59
60
61 explist:
62                 explist expline
63         |       expline
64         ;
65
66 expline:
67                 ID opt_equal_name opt_ordinal opt_NONAME opt_CONSTANT
68                         { def_exports ($1, $2, $3, $4, $5);}
69         ;
70 implist:        
71                 implist impline
72         |       impline
73         ;
74
75 impline:
76                 ID '=' ID '.' ID { def_import ($1,$3,$5);}
77         |       ID '.' ID        { def_import (0, $1,$3);}
78         ;
79 seclist:
80                 seclist secline
81         |       secline
82         ;
83
84 secline:
85         ID attr_list { def_section ($1,$2);}
86         ;
87
88 attr_list:
89         attr_list opt_comma attr
90         | attr
91         ;
92
93 opt_comma:
94         ','
95         | 
96         ;
97 opt_number: ',' NUMBER { $$=$2;}
98         |          { $$=-1;}
99         ;
100         
101 attr:
102                 READ { $$ = 1;}
103         |       WRITE { $$ = 2;}        
104         |       EXECUTE { $$=4;}
105         |       SHARED { $$=8;}
106         ;
107
108 opt_CONSTANT:
109                 CONSTANT {$$=1;}
110         |                {$$=0;}
111         ;
112 opt_NONAME:
113                 NONAME {$$=1;}
114         |                {$$=0;}
115         ;
116
117 opt_name: ID            { $$ =$1; }
118         |               { $$=""; }
119         ;
120
121 opt_ordinal: 
122           '@' NUMBER     { $$=$2;}
123         |                { $$=-1;}
124         ;
125
126 opt_equal_name:
127           '=' ID        { $$ = $2; }
128         |               { $$ =  0; }                     
129         ;
130
131 opt_base: BASE  '=' NUMBER      { $$= $3;}
132         |       { $$=-1;}
133         ;
134
135         
136