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