Subversion Repositories tendra.SVN

Rev

Rev 2 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 7
Line -... Line 1...
-
 
1
/*
-
 
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
 */
1
/*
31
/*
2
    		 Crown Copyright (c) 1997
32
    		 Crown Copyright (c) 1997
3
    
33
 
4
    This TenDRA(r) Computer Program is subject to Copyright
34
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
35
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 46... Line 76...
46
 * Initial revision
76
 * Initial revision
47
 *
77
 *
48
***********************************************************************/
78
***********************************************************************/
49
#ifndef toktypes_key
79
#ifndef toktypes_key
50
#define toktypes_key 1
80
#define toktypes_key 1
51
 
-
 
52
 
-
 
53
 
81
 
54
/* definitions of types used in read_fns.c */
82
/* definitions of types used in read_fns.c */
55
 
83
 
56
struct place_t {
84
struct place_t {
57
  int  flag;  /* false if reading from stream, true if reading from pl_mem */
85
	int   flag;	/* false if reading from stream, true if reading from
-
 
86
			   pl_mem */
58
  char *pl_mem;	/* pointer to the characters */
87
	char *pl_mem;	/* pointer to the characters */
59
  int  bits_on; /* bit_index displacement of the start */
88
	int   bits_on;	/* bit_index displacement of the start */
60
};
89
};
61
 
90
 
62
typedef struct place_t  place;
91
typedef struct place_t place;
63
typedef place bitstream;
92
typedef place bitstream;
64
typedef place bytestream;
93
typedef place bytestream;
65
 
94
 
66
typedef struct sortname_t
95
typedef struct sortname_t {
67
  {int code;	/* code number for the sort - see sortmacs.h */
96
	int code;	/* code number for the sort - see sortmacs.h */
68
   int result;	/* if code is TOKEN this is the code for the result */
97
	int result;	/* if code is TOKEN this is the code for the result */
-
 
98
	struct sortname_list_t {
69
   struct sortname_list_t {struct sortname_t * elems;
99
		struct sortname_t *elems;
70
                           int number;
100
		int number;
71
                          } pars;
101
	} pars;
72
	/* pars.elems is an array of pars.number parameter sorts 
102
	/* pars.elems is an array of pars.number parameter sorts if the code
73
	   if the code is TOKEN */
103
	   is TOKEN */
74
  } sortname;
104
} sortname;
75
 
105
 
76
typedef struct sortname_list_t sortname_list;
106
typedef struct sortname_list_t sortname_list;
77
 
107
 
78
	/* dummy definition types */
108
/* dummy definition types */
79
typedef int token_defn;
109
typedef int token_defn;
80
typedef int capsule;
110
typedef int capsule;
81
typedef int tokextern_list;
111
typedef int tokextern_list;
82
typedef int tagextern_list;
112
typedef int tagextern_list;
83
typedef int tokdef_list;
113
typedef int tokdef_list;
Line 101... Line 131...
101
typedef int tokdec_unit_list;
131
typedef int tokdec_unit_list;
102
typedef int tokdef_unit_list;
132
typedef int tokdef_unit_list;
103
typedef int tagdec_unit_list;
133
typedef int tagdec_unit_list;
104
typedef int tagdef_unit_list;
134
typedef int tagdef_unit_list;
105
typedef int linkinfo_props;
135
typedef int linkinfo_props;
106
 
-
 
107
 
136
 
108
typedef char usage;
137
typedef char usage;
109
 
138
 
110
struct tok_define_t;
-
 
111
 
-
 
112
#include "sort_union.h"
139
#include "sort_union.h"
113
 
140
 
114
#define LOCAL_TOKS 4
141
#define LOCAL_TOKS 4
115
 
142
 
116
typedef struct t_tag_con {
143
struct tag_con_t {
117
	dec * namet;
144
	dec *namet;
118
	exp e;
145
	exp e;
119
	struct t_tag_con * rest;
146
	struct tag_con_t *rest;
120
} tag_con;
147
};
-
 
148
typedef struct tag_con_t tag_con;
121
 
149
 
122
typedef struct t_lab_con {
150
struct lab_con_t {
123
	label namel;
151
	label namel;
124
	exp e;
152
	exp e;
125
	struct t_lab_con * rest;
153
	struct lab_con_t *rest;
126
} lab_con;
154
};
-
 
155
typedef struct lab_con_t lab_con;
127
 
156
 
128
 
157
 
129
typedef union tokval_u tokval;
158
typedef union tokval_u tokval;
130
 
159
 
-
 
160
/* struct holding a token definition */
131
struct tok_define_t {
161
struct tok_define_t {
132
     dec * * my_tagtab;		/* the tagtab current at the definition */
162
	dec **my_tagtab;	/* the tagtab current at the definition */
133
     aldef * * my_altab;	/* the altab current at the definition */
163
	aldef **my_altab;	/* the altab current at the definition */
134
     exp * my_labtab;		/* the labtab current at the definition */
164
	exp *my_labtab;		/* the labtab current at the definition */
135
     struct tok_define_t * * my_toktab;
165
	struct tok_define_t **my_toktab;
136
		/* the toktab current at the definition */
166
				/* the toktab current at the definition */
137
     diag_tagdef * * my_diagtab;	/* OLD DIAGS */
167
	diag_tagdef **my_diagtab;	/* OLD DIAGS */
138
		/* the diagtab current at the definition */
168
				/* the diagtab current at the definition */
139
     dgtag_struct * * my_dgtab;		/* NEW DIAGS */
169
	dgtag_struct **my_dgtab;	/* NEW DIAGS */
140
		/* the dgtab current at the definition */
170
				/* the dgtab current at the definition */
141
     char * tok_name;	/* the identifier (if any) for the token */
171
	char *tok_name;		/* the identifier (if any) for the token */
142
     struct tokformals_list_t	/* description of formal parameters */
172
	struct tokformals_list_t {	/* description of formal parameters */
143
       {
-
 
144
        sortname * par_sorts;	/* sorts of parameters */
173
		sortname *par_sorts;	/* sorts of parameters */
145
        int * par_names;	/* token index for parameters */
174
		int *par_names;		/* token index for parameters */
146
        int number;		/* total number of parameters */
175
		int number;		/* total number of parameters */
147
       } params;
176
	} params;
148
     sortname tdsort;		/* sort of token result */
177
	sortname tdsort;	/* sort of token result */
149
     place tdplace;		/* place to read definition from */
178
	place tdplace;		/* place to read definition from */
150
     int unit_number;		/* number of unit in which defined */
179
	int unit_number;	/* number of unit in which defined */
151
     union tokval_u tdvalue;	/* preserved value if valpresent */
180
	union tokval_u tdvalue;	/* preserved value if valpresent */
152
     int tok_index;		/* index number of this token */
181
	int tok_index;		/* index number of this token */
153
     int   tdtoken;		/* the token */
182
	int tdtoken;		/* the token */
154
     struct t_context * tok_context;     /* the context at the token definition */
183
	struct context_t *tok_context;	/* context at the token definition */
155
     char * signature; 
184
	char *signature;
156
     unsigned int re_evaluate :1;	/* needs to be reevaluated */
185
	unsigned int re_evaluate:1;	/* needs to be reevaluated */
157
     unsigned int defined : 1;
186
	unsigned int defined:1;
158
         /* for diagnostic purposes, remove later */
187
         /* for diagnostic purposes, remove later */
159
     unsigned int is_capsule_token :1;	/* it is a capsule level token */
188
	unsigned int is_capsule_token:1;/* it is a capsule level token */
160
     unsigned int recursive :1;	/* used to check against recursion */
189
	unsigned int recursive:1;	/* used to check against recursion */
161
     unsigned int valpresent :1;/* the value is constant and has been
190
	unsigned int valpresent:1;	/* the value is constant and has been
162
				   computed already */
191
				   	   computed already */
163
     unsigned int tok_special :1; /* locally defined token */
192
	unsigned int tok_special:1;	/* locally defined token */
164
   };
193
};
165
 
-
 
-
 
194
typedef struct tok_define_t tok_define;
166
 
195
 
167
 /* struct holding a token definition */
-
 
168
typedef struct tok_define_t  tok_define;
196
typedef tok_define *token;
169
 
197
 
170
typedef tok_define * token;
-
 
171
 
-
 
172
typedef struct t_context{
198
struct context_t {
173
        tok_define loctoks[LOCAL_TOKS];    
199
        tok_define loctoks[LOCAL_TOKS];
174
	tok_define * othertoks; /* most tokens have <=LOCAL_TOKS parameters and
200
	tok_define *othertoks; /* most tokens have <=LOCAL_TOKS parameters and
175
				are not recursive so use of local space in
201
				  are not recursive so use of local space in
176
				apply_tok for 'tok_context' to avoid lots of
202
				  apply_tok for 'tok_context' to avoid lots of
177
				mallocs ....*/ 
203
				  mallocs ....*/
178
	short no_toks;
204
	short no_toks;
179
	short recursive;
205
	short recursive;
180
	tag_con * tags;	   /* ... don't know how many tag & labs defined in token
206
	tag_con *tags;		/* ... don't know how many tag & labs defined
181
			      so have to keep list; NB used only if recursive */
207
				   in token so have to keep list; NB used only
-
 
208
				   if recursive */
182
	lab_con * labs;
209
	lab_con *labs;
183
	struct t_context * outer;
210
	struct context_t *outer;
184
} context;
211
};
-
 
212
typedef struct context_t context;
185
 
213
 
186
extern context * crt_context;
214
extern context *crt_context;
187
 
215
 
188
	/* dummy definitions */
216
/* dummy definitions */
189
typedef int taglink;
217
typedef int taglink;
190
typedef int allink;
218
typedef int allink;
191
typedef int toklink;
219
typedef int toklink;
192
 
220
 
193
 
221
 
Line 196... Line 224...
196
typedef int tagextern;
224
typedef int tagextern;
197
typedef int alextern;
225
typedef int alextern;
198
 
226
 
199
typedef int tokdec;
227
typedef int tokdec;
200
 
228
 
201
typedef struct tokformals_t
229
typedef struct tokformals_t {
202
  {sortname sn;
230
	sortname sn;
203
   int tk;
231
	int tk;
204
  } tokformals;	/* formal parameter during reading */
232
} tokformals;	/* formal parameter during reading */
205
 
233
 
206
typedef struct tokformals_list_t  tokformals_list;
234
typedef struct tokformals_list_t tokformals_list;
207
 
235
 
208
typedef int tokdef;
236
typedef int tokdef;
209
 
237
 
210
typedef struct tagdec_t
238
typedef struct tagdec_t {
211
  {tag tg;		/* identifying tag */
239
	tag tg;			/* identifying tag */
212
   shape sha;		/* the shape of the tag */
240
	shape sha;		/* the shape of the tag */
213
   access_option acc;	/* its access_options */
241
	access_option acc;	/* its access_options */
214
   bool is_variable;	/* 1 for variable, 0 for identity */
242
	bool is_variable;	/* 1 for variable, 0 for identity */
215
   bool is_common;	/* 1 for common_tagdec */
243
	bool is_common;		/* 1 for common_tagdec */
216
  } tagdec;
244
} tagdec;
217
 
245
 
218
typedef struct tagdef_t
246
typedef struct tagdef_t {
219
 {
-
 
220
  tag tg;		/* identifying tag */
247
	tag tg;			/* identifying tag */
221
  exp def;		/* the associated exp definition */
248
	exp def;		/* the associated exp definition */
222
  bool var;		/* 1 for variable, 0 for identity */
249
	bool var;		/* 1 for variable, 0 for identity */
223
  bool is_common;	/* 1 for common_tagdef */
250
	bool is_common;		/* 1 for common_tagdef */
224
  } tagdef;
251
} tagdef;
225
 
252
 
226
typedef int al_tagdef;
253
typedef int al_tagdef;
227
 
254
 
228
 
-
 
229
typedef struct tdfstring_list_t
255
typedef struct tdfstring_list_t {
230
  {int number;
256
	int number;
231
   tdfstring * elems;
257
	tdfstring *elems;
232
  } tdfstring_list;	/* number tdfstrings */
258
} tdfstring_list;		/* number tdfstrings */
233
 
259
 
234
typedef tdfstring tdfident;
260
typedef tdfstring tdfident;
235
 
261
 
236
typedef tdfstring_list tdfident_list;
262
typedef tdfstring_list tdfident_list;
237
 
263
 
238
typedef tdfident_list unique;
264
typedef tdfident_list unique;
239
 
265
 
240
union external_u {unique u; tdfstring id;};
266
union external_u {
-
 
267
	unique u;
-
 
268
	tdfstring id;
-
 
269
};
241
 
270
 
242
typedef struct external_t {union external_u ex; bool isstring;} external;
271
typedef struct external_t {
-
 
272
	union external_u ex;
-
 
273
	bool isstring;
-
 
274
} external;
243
 
275
 
244
typedef struct capsule_link_t
276
typedef struct capsule_link_t {
245
  {
-
 
246
    char * id;	/* name */
277
	char *id;	/* name */
247
    tdfint n;	/* index */
278
	tdfint n;	/* index */
248
  } capsule_link;
279
} capsule_link;
249
 
280
 
250
typedef struct capsule_link_list_t 
281
typedef struct capsule_link_list_t {
251
  {
-
 
252
    int number;
282
	int number;
253
    capsule_link * members;
283
	capsule_link *members; 
254
    
-
 
255
  } capsule_link_list;	/* number capsule_links */
284
} capsule_link_list;	/* number capsule_links */
256
 
285
 
257
typedef struct tdfint_list_t 
286
typedef struct tdfint_list_t {
258
  {
-
 
259
    int number;
287
	int number;
260
    tdfint * members;
288
	tdfint *members; 
261
    
-
 
262
  } tdfint_list;	/* number tdfints */
289
} tdfint_list;		/* number tdfints */
263
 
290
 
264
	/* dummy definitions */
291
/* dummy definitions */
265
typedef int group_list;
292
typedef int group_list;
266
typedef int extern_link_list;
293
typedef int extern_link_list;
267
typedef int linkextern_list;
294
typedef int linkextern_list;
268
typedef int extern_link;
295
typedef int extern_link;
269
typedef int group;
296
typedef int group;
Line 278... Line 305...
278
typedef int tagdef_props;
305
typedef int tagdef_props;
279
typedef int al_tagdef_props;
306
typedef int al_tagdef_props;
280
typedef int tokdef_bd;
307
typedef int tokdef_bd;
281
typedef int links_list;
308
typedef int links_list;
282
 
309
 
283
typedef struct capsule_frees_t
310
typedef struct capsule_frees_t {
284
  {void * ptr;
311
	void *ptr;
285
   struct capsule_frees_t * next;
312
	struct capsule_frees_t *next;
286
  } capsule_frees;
313
} capsule_frees;
287
 
-
 
288
 
314
 
289
#endif
315
#endif