Subversion Repositories tendra.SVN

Rev

Rev 5 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
6 7u83 2
 * Copyright (c) 2002-2005 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
/*
2 7u83 32
    		 Crown Copyright (c) 1997
6 7u83 33
 
2 7u83 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:-
6 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
6 7u83 45
 
2 7u83 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;
6 7u83 49
 
2 7u83 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;
6 7u83 53
 
2 7u83 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
@special external
62
@special token
63
@special tokdec
64
@special tokdef
65
@special tagdec
66
@special tagdef
67
@special al_tagdef
68
@special version
69
@special token_defn
70
/* AUTOMATICALLY GENERATED BY %ZX VERSION %ZV FROM TDF %VA.%VB */
71
 
72
#include "config.h"
73
#include "types.h"
74
#include "de_types.h"
75
#include "enc_types.h"
76
#include "check.h"
77
#include "decode.h"
78
#include "de_capsule.h"
79
#include "de_unit.h"
80
#include "encode.h"
81
#include "node.h"
82
#include "read.h"
83
#include "shape.h"
84
#include "table.h"
85
#include "tdf.h"
86
#include "utility.h"
87
 
88
 
89
/* INITIALISE CONSTRUCTS */
90
 
6 7u83 91
void
92
init_constructs(void)
2 7u83 93
{
6 7u83 94
    sortname s;
2 7u83 95
@loop sort
96
@if sort.basic
97
@if !sort.special
98
 
6 7u83 99
    s = SORT_%SN;
2 7u83 100
@if sort.eq.sortname
6 7u83 101
    new_sort(s, %3SM);
2 7u83 102
@else
6 7u83 103
    sort_letters[s] = '%SX';
104
    sort_encoding[s] = %SB;
105
    sort_extension[s] = %SE;
106
    sort_decode[s] = de_%SN;
107
    sort_read[s] = read_%SN;
108
    new_sort(s, %1SM);
2 7u83 109
@endif
110
@loop sort.cons
111
@if cons.params
112
@if cons.token
6 7u83 113
    new_cons("%CN", s, %CE, "!");
114
    sort_tokens[s] = %CE;
2 7u83 115
@else
116
@if cons.eq.identify
6 7u83 117
    new_cons("%CN", s, %CE, "?[u]t^x{x}");
2 7u83 118
@else
6 7u83 119
    new_cons("%CN", s, %CE, "%CX");
2 7u83 120
@if cons.cond
6 7u83 121
    sort_conds[s] = %CE;
2 7u83 122
@endif
123
@endif
124
@endif
125
@else
126
@if cons.eq.alignment_sort
6 7u83 127
    new_cons("alignment", s, %CE,(char *)null);
2 7u83 128
@else
6 7u83 129
    new_cons("%CN", s, %CE,(char *)null);
2 7u83 130
@endif
131
@endif
132
@end
133
@if sort.eq.sortname
6 7u83 134
    new_cons("callees", s, %1SM,(char *)null);
135
    new_cons("error_code", s, %2SM,(char *)null);
2 7u83 136
@endif
137
@endif
138
@endif
139
@end
6 7u83 140
    return;
2 7u83 141
}
142
@special sortname
143
 
144
 
145
/* FIND A SORT NAME */
146
 
6 7u83 147
sortname
148
find_sort(char c)
2 7u83 149
{
6 7u83 150
    sortname s;
151
    switch (c) {
2 7u83 152
@loop sort
153
@if sort.basic
154
@if !sort.special
6 7u83 155
	case '%SX': s = SORT_%SN; break;
2 7u83 156
@endif
157
@endif
158
@end
159
	default : {
6 7u83 160
	    input_error("Illegal decode letter, %%c", c);
161
	    s = SORT_unknown;
162
	    break;
2 7u83 163
	}
164
    }
6 7u83 165
    return(s);
2 7u83 166
}
167
@loop sort
168
@if sort.basic
169
 
170
 
171
/* DECODE A %ST */
172
 
173
@if sort.special
6 7u83 174
long
175
de_%SN_bits(void)
2 7u83 176
@else
6 7u83 177
node *
178
de_%SN(void)
2 7u83 179
@endif
180
{
181
@if sort.extends
6 7u83 182
    long n = fetch_extn(%SB%1u);
2 7u83 183
@else
6 7u83 184
    long n = fetch(%SB%0u);
2 7u83 185
@endif
186
@if sort.special
6 7u83 187
    if (n < %u || n > %SM) {
188
	input_error("Illegal %SN value, %%ld", n);
2 7u83 189
    }
6 7u83 190
    return(n);
2 7u83 191
@else
6 7u83 192
    char *args;
193
    node *p = new_node();
194
    construct *cons = cons_no(SORT_%SN, n);
195
    p->cons = cons;
196
    if (n < %u || n > %SM || cons->name == null) {
197
	input_error("Illegal %SN value, %%ld", n);
2 7u83 198
    }
199
@if sort.eq.callees
6 7u83 200
    args = get_char_info(cons);
201
    if (args) {
202
	p->son = de_node(args);
203
    }
2 7u83 204
@else
205
@if sort.eq.error_code
6 7u83 206
    args = get_char_info(cons);
207
    if (args) {
208
	p->son = de_node(args);
209
    }
2 7u83 210
@else
6 7u83 211
    switch (n) {
2 7u83 212
@loop sort.cons
213
@if cons.token
6 7u83 214
	case %CE: {
215
	    IGNORE de_token(p, SORT_%SN);
216
	    break;
2 7u83 217
	}
218
@else
219
@if cons.cond
6 7u83 220
	case %CE: {
221
	    args = get_char_info(cons);
222
	    p->son = de_node(args);
223
	    if (do_check) {
224
		checking = "%CN";
225
		IGNORE check1(ENC_integer, p->son);
2 7u83 226
	    }
6 7u83 227
	    break;
2 7u83 228
	}
229
@else
230
@if cons.edge
6 7u83 231
	case %CE: {
2 7u83 232
@if sort.link
6 7u83 233
	    p->son = de_var_sort(%SN_var);
2 7u83 234
@else
6 7u83 235
	    long m = tdf_int();
236
	    p->son = new_node();
237
	    p->son->cons = find_%SN(m);
2 7u83 238
@endif
6 7u83 239
	    break;
2 7u83 240
	}
241
@endif
242
@endif
243
@endif
244
@end
245
	default : {
6 7u83 246
	    args = get_char_info(cons);
247
	    if (args) {
248
		p->son = de_node(args);
249
	    }
250
	    break;
2 7u83 251
	}
252
    }
253
@endif
254
@endif
255
#ifdef check_%SN
6 7u83 256
    check_%SN(p);
2 7u83 257
#endif
6 7u83 258
    return(p);
2 7u83 259
@endif
260
}
261
@endif
262
@end
263
@loop sort
264
@if sort.basic
265
@if sort.special
266
 
267
 
268
/* ENCODE A %ST */
269
 
6 7u83 270
void
271
enc_%SN_bits(bitstream *p, int n)
2 7u83 272
{
273
@if sort.extends
6 7u83 274
    enc_bits_extn(p, %SB,(long)n);
2 7u83 275
@else
6 7u83 276
    enc_bits(p, %SB,(long)n);
2 7u83 277
@endif
6 7u83 278
    return;
2 7u83 279
}
280
@else
281
@if sort.edge
282
 
283
 
284
/* ENCODE A %ST */
285
 
6 7u83 286
void
287
enc_%SN_bits(bitstream *p, int n)
2 7u83 288
{
289
@if sort.extends
6 7u83 290
    enc_bits_extn(p, %SB,(long)n);
2 7u83 291
@else
6 7u83 292
    enc_bits(p, %SB,(long)n);
2 7u83 293
@endif
6 7u83 294
    return;
2 7u83 295
}
296
@endif
297
@endif
298
@endif
299
@end
300
@special exp sequence
301
@special signed_nat make_signed_nat
302
@loop sort
303
@if sort.basic
304
@if !sort.special
305
 
306
 
307
/* READ A %ST */
308
 
6 7u83 309
node *
310
read_%SN(long n)
2 7u83 311
{
6 7u83 312
    char *args;
313
    node *p = new_node();
314
    construct *cons = cons_no(SORT_%SN, n);
315
    p->cons = cons;
316
    if (n < 0 || n > %SM || cons->name == null) {
317
	input_error("Illegal %SN value, %%ld", n);
2 7u83 318
    }
319
@if sort.eq.callees
6 7u83 320
    args = get_char_info(cons);
321
    if (args) {
322
	p->son = read_node(args);
323
    }
2 7u83 324
@else
325
@if sort.eq.error_code
6 7u83 326
    args = get_char_info(cons);
327
    if (args) {
328
	p->son = read_node(args);
329
    }
2 7u83 330
@else
6 7u83 331
    switch (n) {
2 7u83 332
@loop sort.cons
333
@if cons.token
6 7u83 334
	case %CE: {
335
	    read_token(p, SORT_%SN);
336
	    break;
2 7u83 337
	}
338
@else
339
@if cons.cond
6 7u83 340
	case %CE: {
341
	    args = get_char_info(cons);
342
	    p->son = read_node(args);
343
	    if (do_check) {
344
		checking = "%CN";
345
		IGNORE check1(ENC_integer, p->son);
2 7u83 346
	    }
6 7u83 347
	    break;
2 7u83 348
	}
349
@else
350
@if cons.edge
6 7u83 351
	case %CE: {
352
	    p->son = read_var_sort(SORT_%SN);
353
	    break;
2 7u83 354
	}
355
@else
356
@if cons.special
6 7u83 357
	case %CE: {
358
	    read_%CN(p, get_char_info(cons));
359
	    break;
2 7u83 360
	}
361
@endif
362
@endif
363
@endif
364
@endif
365
@end
366
	default : {
6 7u83 367
	    args = get_char_info(cons);
368
	    if (args) {
369
		p->son = read_node(args);
370
	    }
371
	    break;
2 7u83 372
	}
373
    }
374
@endif
375
@endif
376
#ifdef check_%SN
6 7u83 377
    check_%SN(p);
2 7u83 378
#endif
6 7u83 379
    return(p);
2 7u83 380
}
381
@endif
382
@endif
383
@end