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/src/utilities/calculus/calculus.alg – Rev 2

Subversion Repositories tendra.SVN

Rev

Go to most recent revision | Details | 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
/*
32
    TYPE ALGEBRA FOR CALCULUS TOOL
33
 
34
    This algebra describes the types used by the calculus tool.
35
*/
36
 
37
ALGEBRA calculus (1.2):
38
 
39
 
40
/*
41
    PRIMITIVE TYPES
42
 
43
    The primitive types, from which everything else is built are integers
44
    and strings.
45
*/
46
 
47
int =			"int" ;
48
number =		"unsigned long" ;
49
string =		"char *" ;
50
 
51
 
52
/*
53
    IDENTITY TYPES
54
 
55
    Convenient shorthands are introduced for most pointer types, along
56
    with some aliases used in the disk reading and writing routines.
57
*/
58
 
59
name_string =		string ;
60
zero_int =		int ;
61
int_P =			PTR int ;
62
number_P =		PTR number ;
63
string_P =		PTR string ;
64
ARGUMENT_P =		PTR ARGUMENT ;
65
CLASS_ID_P =		PTR CLASS_ID ;
66
CLASS_ID_P_P =		PTR CLASS_ID_P ;
67
COMPONENT_P =		PTR COMPONENT ;
68
ECONST_P =		PTR ECONST ;
69
ENUM_P =		PTR ENUM ;
70
FIELD_P =		PTR FIELD ;
71
IDENTITY_P =		PTR IDENTITY ;
72
MAP_P =			PTR MAP ;
73
PRIMITIVE_P =		PTR PRIMITIVE ;
74
STRUCTURE_P =		PTR STRUCTURE ;
75
TYPE_P =		PTR TYPE ;
76
TYPE_P_P =		PTR TYPE_P ;
77
UNION_P =		PTR UNION ;
78
 
79
 
80
/*
81
    OVERALL ALGEBRA DEFINITION
82
 
83
    A complete algebra consists of a name, lists of primitives, identities,
84
    enumerations, structures and unions, plus a list of all types used in
85
    the algebra definition.
86
*/
87
 
88
struct ALGEBRA_DEFN (alg) = {
89
    string name ;
90
    int major_no, minor_no ;
91
    LIST PRIMITIVE_P primitives ;
92
    LIST IDENTITY_P identities ;
93
    LIST ENUM_P enumerations ;
94
    LIST STRUCTURE_P structures ;
95
    LIST UNION_P unions ;
96
    LIST TYPE_P types ;
97
} ;
98
 
99
 
100
/*
101
    CLASS IDENTIFIERS
102
 
103
    Each type defined by the algebra has an associated class identifier
104
    giving its name (both long and short forms).  These names may also
105
    be qualified by a hash symbol or a colon. 
106
*/
107
 
108
struct CLASS_ID (cid) = {
109
    string name ;
110
    string name_aux ;
111
    int flag ;
112
    name_string file ;
113
    int line ;
114
} ;
115
 
116
 
117
/*
118
    PRIMITIVE TYPES
119
 
120
    A primitive type consists of a class identifier, giving the name of
121
    the type, and a string, giving the type definition.
122
*/
123
 
124
struct PRIMITIVE (prim) = {
125
    CLASS_ID_P id ;
126
    string defn ;
127
} ;
128
 
129
 
130
/*
131
    ENUMERATION CONSTANTS
132
 
133
    An enumeration constant consists of an enumerator name and an associated
134
    integral value.
135
*/
136
 
137
struct ECONST (ec) = {
138
    string name ;
139
    number value ;
140
} ;
141
 
142
 
143
/*
144
    ENUMERATION TYPES
145
 
146
    An enumeration type consists of a class identifier, giving the type
147
    name, the list of enumeration constants comprising the type, and
148
    the order of the type (one more than the largest constant).
149
*/
150
 
151
struct ENUM (en) = {
152
    CLASS_ID_P id ;
153
    LIST ECONST_P consts ;
154
    number order ;
155
    int lists ;
156
} ;
157
 
158
 
159
/*
160
    IDENTITY TYPES
161
 
162
    A type identity consists of a class identifier, and the type which is
163
    named by this identifier.
164
*/
165
 
166
struct IDENTITY (ident) = {
167
    CLASS_ID_P id ;
168
    TYPE_P defn ;
169
} ;
170
 
171
 
172
/*
173
    STRUCTURE COMPONENTS
174
 
175
    A structure component consists of a string, giving the component name,
176
    and the associated component type.  A default value may also be
177
    provided.
178
*/
179
 
180
struct COMPONENT (cmp) = {
181
    string name ;
182
    TYPE_P type ;
183
    string value ;
184
} ;
185
 
186
 
187
/*
188
    STRUCTURE TYPES
189
 
190
    A structure type consists of a class identifier, giving the type name,
191
    and a list of structure components.
192
*/
193
 
194
struct STRUCTURE (str) = {
195
    CLASS_ID_P id ;
196
    STRUCTURE_P base ;
197
    LIST COMPONENT_P defn ;
198
    zero_int output ;
199
} ;
200
 
201
 
202
/*
203
    UNION FIELDS
204
 
205
    A union field consists of a string, giving the field name, and the list
206
    of structure components comprising the field.  The field name may be
207
    qualified by a hash symbol.  A field may be the first element of a
208
    set.  In this case the int of elements in the set is given by the
209
    set field.
210
*/
211
 
212
struct FIELD (fld) = {
213
    string name ;
214
    int tag ;
215
    int flag ;
216
    int set ;
217
    FIELD_P base ;
218
    LIST COMPONENT_P defn ;
219
} ;
220
 
221
 
222
/*
223
    UNION MAP ARGUMENTS
224
 
225
    A union map argument consists of a string, giving the argument name,
226
    plus an associated argument type.
227
*/
228
 
229
struct ARGUMENT (arg) = {
230
    string name ;
231
    TYPE_P type ;
232
} ;
233
 
234
 
235
/*
236
    UNION MAPS
237
 
238
    A union map consists of a string, giving the map name, plus the map
239
    return type and a list of map arguments.  The map name may be qualified
240
    by a hash symbol.
241
*/
242
 
243
struct MAP (map) = {
244
    string name ;
245
    int flag ;
246
    TYPE_P ret_type ;
247
    LIST ARGUMENT_P args ;
248
} ;
249
 
250
 
251
/*
252
    UNION TYPES
253
 
254
    A union type consists of a class identifier, giving the type name,
255
    plus lists of structure components (giving those components common
256
    to all the union fields), union fields and union maps.  The int
257
    of union fields is recorded for convenience.
258
*/
259
 
260
struct UNION (un) = {
261
    CLASS_ID_P id ;
262
    UNION_P base ;
263
    LIST COMPONENT_P s_defn ;
264
    LIST FIELD_P u_defn ;
265
    LIST MAP_P map ;
266
    int no_fields ;
267
} ;
268
 
269
 
270
/*
271
    TYPES
272
 
273
    A type can be either one of the types defined by the algebra (a
274
    primitive, an identity, an enumeration, a structure or a union),
275
    a quoted C type, or a type derived from these using the PTR, LIST,
276
    VEC and VEC_PTR type constructors.  To allow types to be used before
277
    they are defined, undefined types are also permitted.  Note that
278
    all the real types are aliased.
279
*/
280
 
281
union TYPE (type) = {
282
    zero_int size ;
283
} + {
284
    #	primitive ->			{ PRIMITIVE_P prim ; },
285
    #	ident ->			{ IDENTITY_P id ; },
286
    #	enumeration ->			{ ENUM_P en ; },
287
    #	structure ->			{ STRUCTURE_P struc ; },
288
    #	onion ->			{ UNION_P un ; },
289
    #	ptr, list, stack, vec, vec_ptr ->
290
					{ TYPE_P sub ; },
291
    	quote ->			{ string defn ; },
292
    	undef ->			{ string name ; }
293
} ;
294
 
295
 
296
/*
297
    COMMANDS
298
 
299
    A command for a template file consists of either a simple string,
300
    a list of commands, a conditional or a loop.
301
*/
302
 
303
union COMMAND (cmd) = {
304
    int line ;
305
} + {
306
    simple -> {
307
	string text ;
308
    },
309
    compound -> {
310
	LIST COMMAND seq ;
311
    },
312
    loop -> {
313
	string control ;
314
	COMMAND body ;
315
    },
316
    cond -> {
317
	string control ;
318
	COMMAND true_code ;
319
	COMMAND false_code ;
320
    }
321
} ;