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