Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – tendra.SVN – Blame – /branches/tendra5-amd64/src/tools/tpl/analyse_sort.c – Rev 6

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 7u83 1
/*
2
 * Copyright (c) 2002-2006 The TenDRA Project <http://www.tendra.org/>.
3
 * All rights reserved.
4
 *
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions are met:
7
 *
8
 * 1. Redistributions of source code must retain the above copyright notice,
9
 *    this list of conditions and the following disclaimer.
10
 * 2. Redistributions in binary form must reproduce the above copyright notice,
11
 *    this list of conditions and the following disclaimer in the documentation
12
 *    and/or other materials provided with the distribution.
13
 * 3. Neither the name of The TenDRA Project nor the names of its contributors
14
 *    may be used to endorse or promote products derived from this software
15
 *    without specific, prior written permission.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
18
 * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
19
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
21
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
 * EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
 *
29
 * $Id$
30
 */
31
/*
32
    		 Crown Copyright (c) 1997
33
 
34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
42
 
43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
45
 
46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
49
 
50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
53
 
54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
/**********************************************************************
62
$Author: release $
63
$Date: 1998/01/17 15:57:24 $
64
$Revision: 1.1.1.1 $
65
$Log: analyse_sort.c,v $
66
 * Revision 1.1.1.1  1998/01/17  15:57:24  release
67
 * First version to be checked into rolling release.
68
 *
69
 * Revision 1.2  1995/06/08  09:13:46  currie
70
 * Added sigs to tokdecs/defs
71
 *
72
 * Revision 1.1  1995/04/07  14:29:07  currie
73
 * Initial revision
74
 *
75
 * Revision 1.2  1994/07/21  10:35:53  currie
76
 * Added banner
77
 *
78
***********************************************************************/
79
#include "config.h"
80
#include "util.h"
81
#include "defs.h"
82
#include "syntax.h"
83
#include "analyse_sort.h"
84
#include "encodings.h"
85
#include "enc_nos.h"
86
#include "lex.h"
87
#include "namedecs.h"
88
#include "streams.h"
89
#include "errors.h"
90
 
91
 
92
void
93
read_tdfint(void)
94
{
95
    fail("This shouldn't happen");
96
}
97
 
98
void
99
read_tdfbool(void)
100
{
101
    fail("This shouldn't happen");
102
}
103
 
104
 
105
static void
106
out_nontoksort(int sort)
107
{
108
    switch (sort) {
109
	case access_sort:
110
		o_access;
111
		return;
112
	case alignment_sort:
113
		o_alignment_sort;
114
		return;
115
	case al_tag_sort:
116
		o_al_tag;
117
		return;
118
	case bitfield_variety_sort:
119
		o_bitfield_variety;
120
		return ;
121
	case bool_sort:
122
		o_bool;
123
		return;
124
	case error_treatment_sort:
125
		o_error_treatment;
126
		return;
127
	case exp_sort:
128
		o_exp;
129
		return;
130
	case floating_variety_sort:
131
		o_floating_variety;
132
		return;
133
	case label_sort:
134
		o_label;
135
		return;
136
	case nat_sort:
137
		o_nat;
138
		return;
139
	case ntest_sort:
140
		o_ntest;
141
		return;
142
	case rounding_mode_sort:
143
		o_rounding_mode;
144
		return;
145
	case shape_sort:
146
		o_shape;
147
		return;
148
	case signed_nat_sort:
149
		o_signed_nat;
150
		return;
151
	case string_sort:
152
		o_string;
153
		return;
154
	case tag_sort:
155
		o_tag;
156
		return;
157
	case transfer_mode_sort:
158
		o_transfer_mode;
159
		return;
160
	case variety_sort:
161
		o_variety;
162
		return;
163
    }
164
    fail("Not a legal sort");
165
}
166
 
167
void
168
out_sort(Sort *s)
169
{
170
    if (s->sort != token_sort) {
171
	out_nontoksort(s->sort);
172
    } else {
173
	out_toksort(s->toksort);
174
    }
175
}
176
 
177
void
178
out_toksort(TokSort *ts)
179
{
180
    Tokpar *tp = ts->pars;
181
    o_token(
182
	out_sort(&ts->ressort),
183
	while (tp != (Tokpar *)0) {
184
	    LIST_ELEM(out_sort(&tp->par));
185
	    tp = tp->next;
186
	}
187
   );
188
}
189
 
190
 
191
void
192
analyse_sort(int sort)
193
{
194
    switch (sort) {
195
	case access_sort:
196
		read_access();
197
		return;
198
	case alignment_sort:
199
		read_alignment();
200
		return;
201
	case al_tag_sort:
202
		read_al_tag();
203
		return;
204
	case bitfield_variety_sort:
205
		read_bitfield_variety();
206
		return;
207
	case bool_sort:
208
		read_bool();
209
		return;
210
	case error_treatment_sort:
211
		read_error_treatment();
212
		return;
213
	case exp_sort:
214
		read_exp();
215
		return;
216
	case floating_variety_sort:
217
		read_floating_variety();
218
		return;
219
	case label_sort:
220
		read_label();
221
		return;
222
	case nat_sort:
223
		read_nat();
224
		return;
225
	case ntest_sort:
226
		read_ntest();
227
		return;
228
	case rounding_mode_sort:
229
		read_rounding_mode();
230
		return;
231
	case shape_sort:
232
		read_shape();
233
		return;
234
	case signed_nat_sort:
235
		read_signed_nat();
236
		return;
237
	case string_sort:
238
		read_string();
239
		return;
240
	case tag_sort:
241
		read_tag();
242
		return;
243
	case token_sort:
244
		read_token();
245
		return;
246
	case transfer_mode_sort:
247
		read_transfer_mode();
248
		return;
249
	case variety_sort:
250
		read_variety();
251
		return;
252
    }
253
    fail("Not a legal sort");
254
}
255
 
256
 
257
static void
258
tokp(Tokpar *tp)
259
{
260
    if (tp == (Tokpar *)0) {
261
	    return;
262
    }
263
    skip_term(lex_osq);
264
    analyse_sort(tp->par.sort);
265
    while ((tp=tp->next) != (Tokpar *)0) {
266
	skip_term(lex_comma);
267
	analyse_sort(tp->par.sort);
268
    }
269
    skip_term(lex_csq);
270
}
271
 
272
 
273
static void
274
tok(Tokdec *td)
275
{
276
    if (td->sort.ressort.sort != token_sort) {
277
	make_tok(&td->idname.name);
278
    } else {
279
	o_token_apply_token(make_tok(&td->idname.name), tokp(td->sort.pars));
280
	/* XXX: this only allow two levels */
281
    }
282
}
283
 
284
void
285
expand_tok(Tokdec *td, TokSort *ts)
286
{
287
    Tokpar *tp = ts->pars;
288
    switch (ts->ressort.sort) {
289
	case access_sort:
290
	    o_access_apply_token(tok(td), tokp(tp));
291
	    break;
292
	case alignment_sort:
293
	    o_alignment_apply_token(tok(td), tokp(tp));
294
	    break;
295
	case al_tag_sort:
296
	    o_al_tag_apply_token(tok(td), tokp(tp));
297
	    break;
298
	case bitfield_variety_sort:
299
	    o_bfvar_apply_token(tok(td), tokp(tp));
300
	    break;
301
	case bool_sort:
302
	    o_bool_apply_token(tok(td), tokp(tp));
303
	    break;
304
	case error_treatment_sort:
305
	    o_errt_apply_token(tok(td), tokp(tp));
306
	    break;
307
	case exp_sort:
308
	    o_exp_apply_token(tok(td), tokp(tp));
309
	    break;
310
	case floating_variety_sort:
311
	    o_flvar_apply_token(tok(td), tokp(tp));
312
	    break;
313
	case label_sort:
314
	    o_label_apply_token(tok(td), tokp(tp));
315
	    break;
316
	case nat_sort:
317
	    o_nat_apply_token(tok(td), tokp(tp));
318
	    break;
319
	case ntest_sort:
320
	    o_ntest_apply_token(tok(td), tokp(tp));
321
	    break;
322
	case rounding_mode_sort:
323
	    o_rounding_mode_apply_token(tok(td), tokp(tp));
324
	    break;
325
	case shape_sort:
326
	    o_shape_apply_token(tok(td), tokp(tp));
327
	    break;
328
	case signed_nat_sort:
329
	    o_signed_nat_apply_token(tok(td), tokp(tp));
330
	    break;
331
	case string_sort:
332
	    o_string_apply_token(tok(td), tokp(tp));
333
	    break;
334
	case tag_sort:
335
	    o_tag_apply_token(tok(td), tokp(tp));
336
	    break;
337
	case token_sort:
338
	    expand_tok(td, ts->ressort.toksort);
339
	    break;
340
	case transfer_mode_sort:
341
	    o_transfer_mode_apply_token(tok(td), tokp(tp));
342
	    break;
343
	case variety_sort:
344
	    o_var_apply_token(tok(td), tokp(tp));
345
	    break;
346
	default:
347
	    fail("Not a legal sort");
348
	    break;
349
    }
350
}