Subversion Repositories tendra.SVN

Rev

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

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
@special external
32
@special token
33
@special tokdec
34
@special tokdef
35
@special tagdec
36
@special tagdef
37
@special al_tagdef
38
@special version
39
@special token_defn
40
/* AUTOMATICALLY GENERATED BY %ZX VERSION %ZV FROM TDF %VA.%VB */
41
 
42
#include "config.h"
43
#include "types.h"
44
#include "de_types.h"
45
#include "enc_types.h"
46
#include "check.h"
47
#include "decode.h"
48
#include "de_capsule.h"
49
#include "de_unit.h"
50
#include "encode.h"
51
#include "node.h"
52
#include "read.h"
53
#include "shape.h"
54
#include "table.h"
55
#include "tdf.h"
56
#include "utility.h"
57
 
58
 
59
/* INITIALISE CONSTRUCTS */
60
 
61
void init_constructs
62
    PROTO_Z ()
63
{
64
    sortname s ;
65
@loop sort
66
@if sort.basic
67
@if !sort.special
68
 
69
    s = SORT_%SN ;
70
@if sort.eq.sortname
71
    new_sort ( s, %3SM ) ;
72
@else
73
    sort_letters [s] = '%SX' ;
74
    sort_encoding [s] = %SB ;
75
    sort_extension [s] = %SE ;
76
    sort_decode [s] = de_%SN ;
77
    sort_read [s] = read_%SN ;
78
    new_sort ( s, %1SM ) ;
79
@endif
80
@loop sort.cons
81
@if cons.params
82
@if cons.token
83
    new_cons ( "%CN", s, %CE, "!" ) ;
84
    sort_tokens [s] = %CE ;
85
@else
86
@if cons.eq.identify
87
    new_cons ( "%CN", s, %CE, "?[u]t^x{x}" ) ;
88
@else
89
    new_cons ( "%CN", s, %CE, "%CX" ) ;
90
@if cons.cond
91
    sort_conds [s] = %CE ;
92
@endif
93
@endif
94
@endif
95
@else
96
@if cons.eq.alignment_sort
97
    new_cons ( "alignment", s, %CE, ( char * ) null ) ;
98
@else
99
    new_cons ( "%CN", s, %CE, ( char * ) null ) ;
100
@endif
101
@endif
102
@end
103
@if sort.eq.sortname
104
    new_cons ( "callees", s, %1SM, ( char * ) null ) ;
105
    new_cons ( "error_code", s, %2SM, ( char * ) null ) ;
106
@endif
107
@endif
108
@endif
109
@end
110
    return ;
111
}
112
@special sortname
113
 
114
 
115
/* FIND A SORT NAME */
116
 
117
sortname find_sort
118
    PROTO_N ( ( c ) )
119
    PROTO_T ( char c )
120
{
121
    sortname s ;
122
    switch ( c ) {
123
@loop sort
124
@if sort.basic
125
@if !sort.special
126
	case '%SX' : s = SORT_%SN ; break ;
127
@endif
128
@endif
129
@end
130
	default : {
131
	    input_error ( "Illegal decode letter, %%c", c ) ;
132
	    s = SORT_unknown ;
133
	    break ;
134
	}
135
    }
136
    return ( s ) ;
137
}
138
@loop sort
139
@if sort.basic
140
 
141
 
142
/* DECODE A %ST */
143
 
144
@if sort.special
145
long de_%SN_bits
146
@else
147
node *de_%SN
148
@endif
149
    PROTO_Z ()
150
{
151
@if sort.extends
152
    long n = fetch_extn ( %SB%1u ) ;
153
@else
154
    long n = fetch ( %SB%0u ) ;
155
@endif
156
@if sort.special
157
    if ( n < %u || n > %SM ) {
158
	input_error ( "Illegal %SN value, %%ld", n ) ;
159
    }
160
    return ( n ) ;
161
@else
162
    char *args ;
163
    node *p = new_node () ;
164
    construct *cons = cons_no ( SORT_%SN, n ) ;
165
    p->cons = cons ;
166
    if ( n < %u || n > %SM || cons->name == null ) {
167
	input_error ( "Illegal %SN value, %%ld", n ) ;
168
    }
169
@if sort.eq.callees
170
    args = get_char_info ( cons ) ;
171
    if ( args ) p->son = de_node ( args ) ;
172
@else
173
@if sort.eq.error_code
174
    args = get_char_info ( cons ) ;
175
    if ( args ) p->son = de_node ( args ) ;
176
@else
177
    switch ( n ) {
178
@loop sort.cons
179
@if cons.token
180
	case %CE : {
181
	    IGNORE de_token ( p, SORT_%SN ) ;
182
	    break ;
183
	}
184
@else
185
@if cons.cond
186
	case %CE : {
187
	    args = get_char_info ( cons ) ;
188
	    p->son = de_node ( args ) ;
189
	    if ( do_check ) {
190
		checking = "%CN" ;
191
		IGNORE check1 ( ENC_integer, p->son ) ;
192
	    }
193
	    break ;
194
	}
195
@else
196
@if cons.edge
197
	case %CE : {
198
@if sort.link
199
	    p->son = de_var_sort ( %SN_var ) ;
200
@else
201
	    long m = tdf_int () ;
202
	    p->son = new_node () ;
203
	    p->son->cons = find_%SN ( m ) ;
204
@endif
205
	    break ;
206
	}
207
@endif
208
@endif
209
@endif
210
@end
211
	default : {
212
	    args = get_char_info ( cons ) ;
213
	    if ( args ) p->son = de_node ( args ) ;
214
	    break ;
215
	}
216
    }
217
@endif
218
@endif
219
#ifdef check_%SN
220
    check_%SN ( p ) ;
221
#endif
222
    return ( p ) ;
223
@endif
224
}
225
@endif
226
@end
227
@loop sort
228
@if sort.basic
229
@if sort.special
230
 
231
 
232
/* ENCODE A %ST */
233
 
234
void enc_%SN_bits
235
    PROTO_N ( ( p, n ) )
236
    PROTO_T ( bitstream *p X int n )
237
{
238
@if sort.extends
239
    enc_bits_extn ( p, %SB, ( long ) n ) ;
240
@else
241
    enc_bits ( p, %SB, ( long ) n ) ;
242
@endif
243
    return ;
244
}
245
@else
246
@if sort.edge
247
 
248
 
249
/* ENCODE A %ST */
250
 
251
void enc_%SN_bits
252
    PROTO_N ( ( p, n ) )
253
    PROTO_T ( bitstream *p X int n )
254
{
255
@if sort.extends
256
    enc_bits_extn ( p, %SB, ( long ) n ) ;
257
@else
258
    enc_bits ( p, %SB, ( long ) n ) ;
259
@endif
260
    return ;
261
}
262
@endif
263
@endif
264
@endif
265
@end
266
@special exp sequence
267
@special signed_nat make_signed_nat
268
@loop sort
269
@if sort.basic
270
@if !sort.special
271
 
272
 
273
/* READ A %ST */
274
 
275
node *read_%SN
276
    PROTO_N ( ( n ) )
277
    PROTO_T ( long n )
278
{
279
    char *args ;
280
    node *p = new_node () ;
281
    construct *cons = cons_no ( SORT_%SN, n ) ;
282
    p->cons = cons ;
283
    if ( n < 0 || n > %SM || cons->name == null ) {
284
	input_error ( "Illegal %SN value, %%ld", n ) ;
285
    }
286
@if sort.eq.callees
287
    args = get_char_info ( cons ) ;
288
    if ( args ) p->son = read_node ( args ) ;
289
@else
290
@if sort.eq.error_code
291
    args = get_char_info ( cons ) ;
292
    if ( args ) p->son = read_node ( args ) ;
293
@else
294
    switch ( n ) {
295
@loop sort.cons
296
@if cons.token
297
	case %CE : {
298
	    read_token ( p, SORT_%SN ) ;
299
	    break ;
300
	}
301
@else
302
@if cons.cond
303
	case %CE : {
304
	    args = get_char_info ( cons ) ;
305
	    p->son = read_node ( args ) ;
306
	    if ( do_check ) {
307
		checking = "%CN" ;
308
		IGNORE check1 ( ENC_integer, p->son ) ;
309
	    }
310
	    break ;
311
	}
312
@else
313
@if cons.edge
314
	case %CE : {
315
	    p->son = read_var_sort ( SORT_%SN ) ;
316
	    break ;
317
	}
318
@else
319
@if cons.special
320
	case %CE : {
321
	    read_%CN ( p, get_char_info ( cons ) ) ;
322
	    break ;
323
	}
324
@endif
325
@endif
326
@endif
327
@endif
328
@end
329
	default : {
330
	    args = get_char_info ( cons ) ;
331
	    if ( args ) p->son = read_node ( args ) ;
332
	    break ;
333
	}
334
    }
335
@endif
336
@endif
337
#ifdef check_%SN
338
    check_%SN ( p ) ;
339
#endif
340
    return ( p ) ;
341
}
342
@endif
343
@endif
344
@end