Subversion Repositories tendra.SVN

Rev

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

Rev 5 Rev 6
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
Line 123... Line 153...
123
#include "externs.h"
153
#include "externs.h"
124
#include "diag_fns.h"	/* OLD DIAGS */
154
#include "diag_fns.h"	/* OLD DIAGS */
125
#include "dg_fns.h"	/* NEW DIAGS */
155
#include "dg_fns.h"	/* NEW DIAGS */
126
#include "messages_r.h"
156
#include "messages_r.h"
127
#include "natmacs.h"
157
#include "natmacs.h"
128
 
158
 
129
 
159
 
130
/* Some external declarations  */
160
/* Some external declarations  */
131
 
161
 
132
extern diag_type_unit f_make_diagtype_unit PROTO_S ((void));	/* OLD DIAGS */
162
extern diag_type_unit f_make_diagtype_unit(void);	/* OLD DIAGS */
133
extern int f_make_linkinfo_unit PROTO_S ((void));
163
extern int f_make_linkinfo_unit(void);
134
extern void start_make_linkinfo_unit PROTO_S ((int, int, int, int ));
164
extern void start_make_linkinfo_unit(int, int, int, int);
135
extern int machine_toks PROTO_S ((char *));
165
extern int machine_toks(char *);
136
extern void tidy_initial_values PROTO_S ((void));
166
extern void tidy_initial_values(void);
137
 
167
 
138
/* MACROS */
168
/* MACROS */
139
 
169
 
140
    /* codes for the types of unit which are understood here */
170
    /* codes for the types of unit which are understood here */
141
#define UNKNOWN_UNIT 0
171
#define UNKNOWN_UNIT	 0
142
#define TOKDEC_UNIT 1
172
#define TOKDEC_UNIT	 1
143
#define TOKDEF_UNIT 2
173
#define TOKDEF_UNIT	 2
144
#define AL_UNIT 3
174
#define AL_UNIT		 3
145
#define TAGDEC_UNIT 4
175
#define TAGDEC_UNIT	 4
146
#define TAGDEF_UNIT 5
176
#define TAGDEF_UNIT	 5
147
#define DIAGDEF_UNIT 6		/* OLD DIAGS */
177
#define DIAGDEF_UNIT	 6	/* OLD DIAGS */
148
#define DIAGTYPE_UNIT 7		/* OLD DIAGS */
178
#define DIAGTYPE_UNIT	 7	/* OLD DIAGS */
149
#define LINKINFO_UNIT 8
179
#define LINKINFO_UNIT	 8
150
#define VERSIONS_UNIT 9
180
#define VERSIONS_UNIT	 9
151
#define DGCOMP_UNIT 10		/* NEW DIAGS */
181
#define DGCOMP_UNIT	10	/* NEW DIAGS */
152
 
182
 
153
  /* codes for the kinds of linkable variable which are understood here */
183
  /* codes for the kinds of linkable variable which are understood here */
154
#define UNKNOWN_TYPE 0
184
#define UNKNOWN_TYPE	0
155
#define TOK_TYPE 1
185
#define TOK_TYPE	1
156
#define TAG_TYPE 2
186
#define TAG_TYPE	2
157
#define AL_TYPE 3
187
#define AL_TYPE		3
158
#define DIAGTAG_TYPE 4		/* OLD DIAGS */
188
#define DIAGTAG_TYPE	4	/* OLD DIAGS */
159
#define DGTAG_TYPE 5		/* NEW DIAGS */
189
#define DGTAG_TYPE	5	/* NEW DIAGS */
160
 
190
 
161
/* VARIABLES */
191
/* VARIABLES */
162
/* All variables are initialised, jmf */
192
/* All variables are initialised, jmf */
163
 
193
 
164
int crt_group_type;	 /* the code for the current group of units */
194
int crt_group_type;		/* the code for the current group of units */
165
int crt_links_type;/* the code for the current type of linkable variable                      */
195
int crt_links_type;		/* the code for the current type of linkable
-
 
196
				   variable */
166
int crt_extern_link_type;/* the code for the current type of externally
197
int crt_extern_link_type;	/* the code for the current type of externally
167
                             linked variable */
198
				   linked variable */
168
tdfstring * crt_capsule_groups; /* the identifier for the current group
199
tdfstring *crt_capsule_groups;	/* the identifier for the current group
169
                                   of units */
200
				   of units */
170
int crt_capsule_group_no; /* the number in the group */
201
int crt_capsule_group_no;	/* the number in the group */
171
int crt_capsule_link_no;  /* the number of linkable variables
202
int crt_capsule_link_no;	/* the number of linkable variables
172
                               of the current type */
203
				   of the current type */
173
capsule_link_list crt_capsule_linking;
204
capsule_link_list crt_capsule_linking;
174
 
205
 
175
static int no_of_local_tokens;
206
static int no_of_local_tokens;
176
 
207
 
177
 
208
 
178
 
209
 
179
/* PROCEDURES */
210
/* PROCEDURES */
180
 
211
 
181
  /* translates the name of a group of units into  its code */
212
  /* translates the name of a group of units into  its code */
182
int group_type
213
int
183
    PROTO_N ( (s) )
-
 
184
    PROTO_T ( char * s )
214
group_type(char *s)
185
{
215
{
186
  if (!strcmp(s, "tokdec"))
216
  if (!strcmp(s, "tokdec")) {
187
    return TOKDEC_UNIT;
217
    return TOKDEC_UNIT;
-
 
218
  }
188
  if (!strcmp(s, "tokdef"))
219
  if (!strcmp(s, "tokdef")) {
189
    return TOKDEF_UNIT;
220
    return TOKDEF_UNIT;
-
 
221
  }
190
  if (!strcmp(s, "aldef"))
222
  if (!strcmp(s, "aldef")) {
191
    return AL_UNIT;
223
    return AL_UNIT;
-
 
224
  }
192
  if (!strcmp(s, "tagdec"))
225
  if (!strcmp(s, "tagdec")) {
193
    return TAGDEC_UNIT;
226
    return TAGDEC_UNIT;
-
 
227
  }
194
  if (!strcmp(s, "tagdef"))
228
  if (!strcmp(s, "tagdef")) {
195
    return TAGDEF_UNIT;
229
    return TAGDEF_UNIT;
-
 
230
  }
196
  if (!strcmp(s, "diagdef"))		/* OLD DIAGS */
231
  if (!strcmp(s, "diagdef")) {		/* OLD DIAGS */
197
    return DIAGDEF_UNIT;
232
    return DIAGDEF_UNIT;
-
 
233
  }
198
  if (!strcmp(s, "diagtype"))		/* OLD DIAGS */
234
  if (!strcmp(s, "diagtype")) {		/* OLD DIAGS */
199
    return DIAGTYPE_UNIT;
235
    return DIAGTYPE_UNIT;
-
 
236
  }
200
  if (!strcmp(s, "linkinfo"))
237
  if (!strcmp(s, "linkinfo")) {
201
    return LINKINFO_UNIT;
238
    return LINKINFO_UNIT;
-
 
239
  }
202
  if (!strcmp(s, "versions"))
240
  if (!strcmp(s, "versions")) {
203
    return VERSIONS_UNIT;
241
    return VERSIONS_UNIT;
-
 
242
  }
204
  if (!strcmp(s, "dgcompunit"))		/* NEW DIAGS */
243
  if (!strcmp(s, "dgcompunit")) {	/* NEW DIAGS */
205
    return DGCOMP_UNIT;
244
    return DGCOMP_UNIT;
-
 
245
  }
206
  return UNKNOWN_UNIT;
246
  return UNKNOWN_UNIT;
207
}
247
}
208
 
248
 
209
  /* translates the name of a kind of linkable variable into its code */
249
  /* translates the name of a kind of linkable variable into its code */
210
int links_type
250
int
211
    PROTO_N ( (s) )
-
 
212
    PROTO_T ( char * s )
251
links_type(char *s)
213
{
252
{
214
  if (!strcmp(s, "token"))
253
  if (!strcmp(s, "token")) {
215
    return TOK_TYPE;
254
    return TOK_TYPE;
-
 
255
  }
216
  if (!strcmp(s, "tag"))
256
  if (!strcmp(s, "tag")) {
217
    return TAG_TYPE;
257
    return TAG_TYPE;
-
 
258
  }
218
  if (!strcmp(s, "alignment"))
259
  if (!strcmp(s, "alignment")) {
219
    return AL_TYPE;
260
    return AL_TYPE;
-
 
261
  }
220
  if (!strcmp(s, "diagtag"))		/* OLD DIAGS */
262
  if (!strcmp(s, "diagtag")) {		/* OLD DIAGS */
221
    return DIAGTAG_TYPE;
263
    return DIAGTAG_TYPE;
-
 
264
  }
222
  if (!strcmp(s, "dgtag"))		/* NEW DIAGS */
265
  if (!strcmp(s, "dgtag")) {		/* NEW DIAGS */
223
    return DGTAG_TYPE;
266
    return DGTAG_TYPE;
-
 
267
  }
224
  return UNKNOWN_TYPE;
268
  return UNKNOWN_TYPE;
225
}
269
}
226
 
270
 
227
char * external_to_string
271
char *
228
    PROTO_N ( (ext) )
-
 
229
    PROTO_T ( external ext )
272
external_to_string(external ext)
230
{
273
{
231
	char * res;
274
	char *res;
232
	int n, i, l;
275
	int n, i, l;
233
	tdfstring * t;
276
	tdfstring *t;
234
	if (ext.isstring) {
277
	if (ext.isstring) {
235
		return (char*)ext.ex.id.ints.chars;
278
		return (char *)ext.ex.id.ints.chars;
236
	}
279
	}
237
	else {
280
	else {
238
		n = ext.ex.u.number;
281
		n = ext.ex.u.number;
239
		t = ext.ex.u.elems;
282
		t = ext.ex.u.elems;
240
		l=n;
283
		l=n;
-
 
284
		for (i = 0; i < n; i++) {
241
		for(i=0; i<n; i++) l += t[i].number * (t[i].size / 8);
285
			l += t[i].number *(t[i].size / 8);
-
 
286
		}
242
		res = (char*)xcalloc(l+1, sizeof(char));
287
		res = (char *)xcalloc(l + 1, sizeof(char));
243
		l = 0;
288
		l = 0;
244
		for(i=0; i<n; i++) {
289
		for (i = 0; i < n; i++) {
245
			IGNORE(strcpy(res+l, t[i].ints.chars));
290
			IGNORE(strcpy(res + l, t[i].ints.chars));
246
			l+= t[i].number * (t[i].size / 8);
291
			l += t[i].number * (t[i].size / 8);
247
			res[l++] = 'U';
292
			res[l++] = 'U';
248
		}
293
		}
249
		return res;
294
		return res;
250
	}
295
	}
251
}
296
}
252
 
297
 
253
 
298
 
254
char * make_local_name
299
char *
255
    PROTO_Z ()
300
make_local_name(void)
256
{
301
{
257
      /* invent a local label identifier */
302
  /* invent a local label identifier */
258
  char *id;
303
  char *id;
259
  char *st = intchars (next_lab ());
304
  char *st = intchars(next_lab());
260
  int   l = (int)strlen (st);
305
  int   l = (int)strlen(st);
261
  int lpl = (int)strlen(local_prefix);
306
  int lpl = (int)strlen(local_prefix);
262
  id = (char *) xcalloc (l + lpl + 1, sizeof (char));
307
  id = (char *)xcalloc(l + lpl + 1, sizeof(char));
263
  IGNORE strcpy(id, local_prefix);
308
  IGNORE strcpy(id, local_prefix);
264
  IGNORE strcpy(&id[lpl], st);
309
  IGNORE strcpy(&id[lpl], st);
265
  return id;
310
  return id;
266
}
311
}
267
 
312
 
268
static void check_tok_sig
313
static void
269
    PROTO_N ( (t, sig) )
-
 
270
    PROTO_T ( tok_define * t X string sig )
314
check_tok_sig(tok_define *t, string sig)
271
{
315
{
272
	char * sid = sig.ints.chars;
316
	char *sid = sig.ints.chars;
273
	int s = (sig.size*sig.number)/8;
317
	int s = (sig.size * sig.number) / 8;
274
	if (t->signature != (char*)0) {
318
	if (t->signature != (char*)0) {
275
		char * id = t->signature;
319
		char *id = t->signature;
276
			    	int i;
320
		int i;
277
		for(i=0; i<s; i++) {
321
		for (i = 0; i < s; i++) {
278
			if (id[i]!=sid[i]) break;
322
			if (id[i] != sid[i])break;
279
		}
323
		}
280
		if (i!=s || id[s] !=0) {
324
		if (i !=s || id[s] != 0) {
281
			   IGNORE fprintf(stderr, "%s\n%s\n", id, sid);
325
			IGNORE fprintf(stderr, "%s\n%s\n", id, sid);
282
			   failer("Token signatures should be equal");
326
			failer("Token signatures should be equal");
283
		}
327
		}
284
	}
-
 
285
	else {
328
	} else {
286
		t->signature = sid;
329
		t->signature = sid;
287
	}
330
	}
288
}
331
}
289
 
332
 
290
  /* all the _apply_token functions follow this pattern */
333
/* all the _apply_token functions follow this pattern */
291
procprops f_procprops_apply_token
334
procprops
292
    PROTO_N ( (token_value, token_args) )
-
 
293
    PROTO_T ( token token_value X bitstream token_args )
335
f_procprops_apply_token(token token_value, bitstream token_args)
294
{
336
{
295
   tokval v;
337
   tokval v;
296
   v = apply_tok(token_value, token_args, PROCPROPS, (tokval*)0);
338
   v = apply_tok(token_value, token_args, PROCPROPS,(tokval *)0);
297
   return v.tk_procprops;
339
   return v.tk_procprops;
298
}
340
}
299
 
341
 
300
  /* all the _cond functions follow this pattern */
342
/* all the _cond functions follow this pattern */
301
procprops f_procprops_cond
343
procprops
302
    PROTO_N ( (control, e1, e2) )
-
 
303
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
344
f_procprops_cond(exp control, bitstream e1, bitstream e2)
304
{
345
{
305
  bitstream bs;
346
  bitstream bs;
306
  procprops res;
347
  procprops res;
307
  int n;
348
  int n;
308
  bs = keep_place();
349
  bs = keep_place();
309
 
350
 
310
    /* the control must evaluate to a constant */
351
  /* the control must evaluate to a constant */
311
  if (name(control) != val_tag)
352
  if (name(control) != val_tag) {
312
    failer(CONTROL_EXP);
353
    failer(CONTROL_EXP);
-
 
354
  }
313
  n = no(control);
355
  n = no(control);
314
  retcell(control);
356
  retcell(control);
315
  if (n==0)
357
  if (n == 0) {
316
   {
-
 
317
      /* use the second bitstream */
358
     /* use the second bitstream */
318
     set_place(e2);
359
     set_place(e2);
319
     res = d_procprops();
360
     res = d_procprops();
320
   }
-
 
321
  else
361
  } else {
322
   {
-
 
323
      /* use the first bitstream */
362
     /* use the first bitstream */
324
     set_place(e1);
363
     set_place(e1);
325
     res = d_procprops();
364
     res = d_procprops();
326
   };
365
  }
327
 set_place(bs);
366
 set_place(bs);
328
 return res;
367
 return res;
329
}
368
}
330
 
369
 
331
string f_string_apply_token
370
string
332
    PROTO_N ( (token_value, token_args) )
-
 
333
    PROTO_T ( token token_value X bitstream token_args )
371
f_string_apply_token(token token_value, bitstream token_args)
334
{
372
{
335
   tokval v;
373
   tokval v;
336
   v = apply_tok(token_value, token_args, STRING, (tokval*)0);
374
   v = apply_tok(token_value, token_args, STRING,(tokval *)0);
337
   return v.tk_string;
375
   return v.tk_string;
338
}
376
}
339
 
377
 
340
  /* all the _cond functions follow this pattern */
378
/* all the _cond functions follow this pattern */
341
string f_string_cond
379
string
342
    PROTO_N ( (control, e1, e2) )
-
 
343
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
380
f_string_cond(exp control, bitstream e1, bitstream e2)
344
{
381
{
345
  bitstream bs;
382
  bitstream bs;
346
  string res;
383
  string res;
347
  int n;
384
  int n;
348
  bs = keep_place();
385
  bs = keep_place();
349
 
386
 
350
    /* the control must evaluate to a constant */
387
  /* the control must evaluate to a constant */
351
  if (name(control) != val_tag)
388
  if (name(control) != val_tag) {
352
    failer(CONTROL_EXP);
389
    failer(CONTROL_EXP);
-
 
390
  }
353
  n = no(control);
391
  n = no(control);
354
  retcell(control);
392
  retcell(control);
355
  if (n==0)
393
  if (n == 0) {
356
   {
-
 
357
      /* use the second bitstream */
394
    /* use the second bitstream */
358
     set_place(e2);
395
    set_place(e2);
359
     res = d_string();
396
    res = d_string();
360
   }
-
 
361
  else
397
  } else {
362
   {
-
 
363
      /* use the first bitstream */
398
    /* use the first bitstream */
364
     set_place(e1);
399
    set_place(e1);
365
     res = d_string();
400
    res = d_string();
366
   };
401
  }
367
 set_place(bs);
402
  set_place(bs);
368
 return res;
403
  return res;
369
}
404
}
370
 
405
 
371
 
406
 
372
alignment f_alignment_apply_token
407
alignment
373
    PROTO_N ( (token_value, token_args) )
-
 
374
    PROTO_T ( token token_value X bitstream token_args )
408
f_alignment_apply_token(token token_value, bitstream token_args)
375
{
409
{
376
   tokval v;
410
  tokval v;
377
   v = apply_tok(token_value, token_args, ALIGNMENT_SORT, (tokval*)0);
411
  v = apply_tok(token_value, token_args, ALIGNMENT_SORT,(tokval *)0);
378
   return v.tk_alignment;
412
  return v.tk_alignment;
379
}
413
}
380
 
414
 
381
  /* all the _cond functions follow this pattern */
415
/* all the _cond functions follow this pattern */
382
alignment f_alignment_cond
416
alignment
383
    PROTO_N ( (control, e1, e2) )
-
 
384
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
417
f_alignment_cond(exp control, bitstream e1, bitstream e2)
385
{
418
{
386
  bitstream bs;
419
  bitstream bs;
387
  alignment res;
420
  alignment res;
388
  int n;
421
  int n;
389
  bs = keep_place();
422
  bs = keep_place();
390
 
423
 
391
    /* the control must evaluate to a constant */
424
  /* the control must evaluate to a constant */
392
  if (name(control) != val_tag)
425
  if (name(control) != val_tag) {
393
    failer(CONTROL_EXP);
426
    failer(CONTROL_EXP);
-
 
427
  }
394
  n = no(control);
428
  n = no(control);
395
  retcell(control);
429
  retcell(control);
396
  if (n==0)
430
  if (n == 0) {
397
   {
-
 
398
      /* use the second bitstream */
431
    /* use the second bitstream */
399
     set_place(e2);
432
    set_place(e2);
400
     res = d_alignment();
433
    res = d_alignment();
401
   }
-
 
402
  else
434
  } else {
403
   {
-
 
404
      /* use the first bitstream */
435
    /* use the first bitstream */
405
     set_place(e1);
436
    set_place(e1);
406
     res = d_alignment();
437
    res = d_alignment();
407
   };
438
  }
408
 set_place(bs);
439
  set_place(bs);
409
 return res;
440
  return res;
410
}
441
}
411
 
442
 
412
access f_access_apply_token
443
access
413
    PROTO_N ( (token_value, token_args) )
-
 
414
    PROTO_T ( token token_value X bitstream token_args )
444
f_access_apply_token(token token_value, bitstream token_args)
415
{
445
{
416
   tokval v;
446
  tokval v;
417
   v = apply_tok(token_value, token_args, ACCESS_SORT, (tokval*)0);
447
  v = apply_tok(token_value, token_args, ACCESS_SORT,(tokval *)0);
418
   return v.tk_access;
448
  return v.tk_access;
419
}
449
}
420
 
450
 
421
 
451
 
422
access f_access_cond
452
access
423
    PROTO_N ( (control, e1, e2) )
-
 
424
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
453
f_access_cond(exp control, bitstream e1, bitstream e2)
425
{
454
{
426
  bitstream bs;
455
  bitstream bs;
427
  access res;
456
  access res;
428
  int n;
457
  int n;
429
  bs = keep_place();
458
  bs = keep_place();
430
 
459
 
431
    /* the control must evaluate to a constant */
460
  /* the control must evaluate to a constant */
432
  if (name(control) != val_tag)
461
  if (name(control) != val_tag) {
433
    failer(CONTROL_EXP);
462
    failer(CONTROL_EXP);
-
 
463
  }
434
  n = no(control);
464
  n = no(control);
435
  retcell(control);
465
  retcell(control);
436
  if (n==0)
466
  if (n == 0) {
437
   {
-
 
438
      /* use the second bitstream */
467
    /* use the second bitstream */
439
     set_place(e2);
468
    set_place(e2);
440
     res = d_access();
469
    res = d_access();
441
   }
-
 
442
  else
470
  } else {
443
   {
-
 
444
      /* use the first bitstream */
471
    /* use the first bitstream */
445
     set_place(e1);
472
    set_place(e1);
446
     res = d_access();
473
    res = d_access();
447
   };
474
  }
448
 set_place(bs);
475
  set_place(bs);
449
 return res;
476
  return res;
450
}
477
}
451
 
478
 
452
transfer_mode f_transfer_mode_apply_token
479
transfer_mode
453
    PROTO_N ( (token_value, token_args) )
-
 
454
    PROTO_T ( token token_value X bitstream token_args )
480
f_transfer_mode_apply_token(token token_value, bitstream token_args)
455
{
481
{
456
   tokval v;
482
   tokval v;
457
   v = apply_tok(token_value, token_args, TRANSFER_MODE_SORT, (tokval*)0);
483
   v = apply_tok(token_value, token_args, TRANSFER_MODE_SORT,(tokval *)0);
458
   return v.tk_transfer_mode;
484
   return v.tk_transfer_mode;
459
}
485
}
460
 
486
 
461
 
487
 
462
transfer_mode f_transfer_mode_cond
488
transfer_mode
463
    PROTO_N ( (control, e1, e2) )
-
 
464
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
489
f_transfer_mode_cond(exp control, bitstream e1, bitstream e2)
465
{
490
{
466
  bitstream bs;
491
  bitstream bs;
467
  transfer_mode res;
492
  transfer_mode res;
468
  int n;
493
  int n;
469
  bs = keep_place();
494
  bs = keep_place();
470
 
495
 
471
    /* the control must evaluate to a constant */
496
  /* the control must evaluate to a constant */
472
  if (name(control) != val_tag)
497
  if (name(control) != val_tag) {
473
    failer(CONTROL_EXP);
498
    failer(CONTROL_EXP);
-
 
499
  }
474
  n = no(control);
500
  n = no(control);
475
  retcell(control);
501
  retcell(control);
476
  if (n==0)
502
  if (n == 0) {
477
   {
-
 
478
      /* use the second bitstream */
503
    /* use the second bitstream */
479
     set_place(e2);
504
    set_place(e2);
480
     res = d_transfer_mode();
505
    res = d_transfer_mode();
481
   }
-
 
482
  else
506
  } else {
483
   {
-
 
484
      /* use the first bitstream */
507
    /* use the first bitstream */
485
     set_place(e1);
508
    set_place(e1);
486
     res = d_transfer_mode();
509
    res = d_transfer_mode();
487
   };
510
  }
488
 set_place(bs);
511
  set_place(bs);
489
 return res;
512
  return res;
490
}
513
}
491
 
514
 
492
 
515
 
493
bitfield_variety f_bfvar_apply_token
516
bitfield_variety
494
    PROTO_N ( (token_value, token_args) )
-
 
495
    PROTO_T ( token token_value X bitstream token_args )
517
f_bfvar_apply_token(token token_value, bitstream token_args)
496
{
518
{
497
   tokval v;
519
   tokval v;
498
   v = apply_tok(token_value, token_args, BITFIELD_VARIETY, (tokval*)0);
520
   v = apply_tok(token_value, token_args, BITFIELD_VARIETY,(tokval*)0);
499
   return v.tk_bitfield_variety;
521
   return v.tk_bitfield_variety;
500
}
522
}
501
 
523
 
502
bitfield_variety f_bfvar_cond
524
bitfield_variety
503
    PROTO_N ( (control, e1, e2) )
-
 
504
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
525
f_bfvar_cond(exp control, bitstream e1, bitstream e2)
505
{
526
{
506
  bitstream bs;
527
  bitstream bs;
507
  bitfield_variety res;
528
  bitfield_variety res;
508
  int n;
529
  int n;
509
  bs = keep_place();
530
  bs = keep_place();
510
  if (name(control) != val_tag)
531
  if (name(control) != val_tag) {
511
    failer(CONTROL_EXP);
532
    failer(CONTROL_EXP);
-
 
533
  }
512
  n = no(control);
534
  n = no(control);
513
  retcell(control);
535
  retcell(control);
514
  if (n==0)
536
  if (n == 0) {
515
   {
-
 
516
     set_place(e2);
537
    set_place(e2);
517
     res = d_bitfield_variety();
538
    res = d_bitfield_variety();
518
   }
-
 
519
  else
539
  } else {
520
   {
-
 
521
     set_place(e1);
540
    set_place(e1);
522
     res = d_bitfield_variety();
541
    res = d_bitfield_variety();
523
   };
542
  }
524
 set_place(bs);
543
  set_place(bs);
525
 return res;
544
  return res;
526
}
545
}
527
 
546
 
-
 
547
bool
528
bool f_bool_apply_token
548
f_bool_apply_token
529
    PROTO_N ( (token_value, token_args) )
-
 
530
    PROTO_T ( token token_value X bitstream token_args )
549
(token token_value, bitstream token_args)
531
{
550
{
532
   tokval v;
551
   tokval v;
533
   v = apply_tok(token_value, token_args, BOOL, (tokval*)0);
552
   v = apply_tok(token_value, token_args, BOOL,(tokval *)0);
534
   return v.tk_bool;
553
   return v.tk_bool;
535
}
554
}
536
 
555
 
537
bool f_bool_cond
556
bool
538
    PROTO_N ( (control, e1, e2) )
-
 
539
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
557
f_bool_cond(exp control, bitstream e1, bitstream e2)
540
{
558
{
541
  bitstream bs;
559
  bitstream bs;
542
  bool res;
560
  bool res;
543
  int n;
561
  int n;
544
  bs = keep_place();
562
  bs = keep_place();
545
  if (name(control) != val_tag)
563
  if (name(control) != val_tag) {
546
    failer(CONTROL_EXP);
564
    failer(CONTROL_EXP);
-
 
565
  }
547
  n = no(control);
566
  n = no(control);
548
  retcell(control);
567
  retcell(control);
549
  if (n==0)
568
  if (n == 0) {
550
   {
-
 
551
     set_place(e2);
569
    set_place(e2);
552
     res = d_bool();
570
    res = d_bool();
553
   }
-
 
554
  else
571
  } else {
555
   {
-
 
556
     set_place(e1);
572
    set_place(e1);
557
     res = d_bool();
573
    res = d_bool();
558
   };
574
  }
559
 set_place(bs);
575
  set_place(bs);
560
 return res;
576
  return res;
561
}
577
}
562
 
578
 
563
 
579
 
564
  /* locate the index number of the linkable variable */
580
/* locate the index number of the linkable variable */
-
 
581
int
565
int find_index
582
find_index
566
    PROTO_N ( (nm) )
-
 
567
    PROTO_T ( char * nm )
583
(char *nm)
568
{
584
{
569
  int i;
585
  int i;
570
  for (i=0; i < crt_capsule_linking.number; ++i)
586
  for (i = 0; i < crt_capsule_linking.number; ++i) {
571
   {
-
 
572
     if (!strcmp((crt_capsule_linking.members[i]).id, nm))
587
    if (!strcmp((crt_capsule_linking.members[i]).id, nm)) {
573
        return i;
588
      return i;
574
   };
589
    }
-
 
590
  }
575
  return -1;
591
  return -1;
576
}
592
}
577
 
593
 
578
 
594
 
-
 
595
void
579
void start_make_capsule
596
start_make_capsule
580
    PROTO_N ( (prop_names, capsule_linking) )
-
 
581
    PROTO_T ( tdfstring_list prop_names X capsule_link_list capsule_linking )
597
(tdfstring_list prop_names, capsule_link_list capsule_linking)
582
{
598
{
583
  int i;
599
  int i;
584
 
600
 
585
  while (capsule_freelist) {
601
  while (capsule_freelist) {
586
    capsule_frees * cf = capsule_freelist -> next;
602
    capsule_frees * cf = capsule_freelist -> next;
587
    xfree((void*)capsule_freelist->ptr);
603
    xfree((void*)capsule_freelist->ptr);
588
    xfree((void*)capsule_freelist);
604
    xfree((void*)capsule_freelist);
589
    capsule_freelist = cf;
605
    capsule_freelist = cf;
590
  };
606
  }
591
 
607
 
592
  crt_tagdef_unit_no = -1;
608
  crt_tagdef_unit_no = -1;
593
  unit_index = 0;
609
  unit_index = 0;
594
  top_aldef = (aldef *)0;
610
  top_aldef = (aldef *)0;
595
  doing_aldefs = 0;
611
  doing_aldefs = 0;
Line 599... Line 615...
599
 
615
 
600
  crt_capsule_linking = capsule_linking;
616
  crt_capsule_linking = capsule_linking;
601
  crt_capsule_link_no = capsule_linking.number;
617
  crt_capsule_link_no = capsule_linking.number;
602
 
618
 
603
  i = find_index("token");
619
  i = find_index("token");
604
  capsule_no_of_tokens = (i == -1) ? 0 :
-
 
605
               natint((capsule_linking.members[i]).n);
620
  capsule_no_of_tokens = (i == -1) ? 0 : natint((capsule_linking.members[i]).n);
606
 
621
 
607
  i = find_index("tag");
622
  i = find_index("tag");
608
  capsule_no_of_tags = (i == -1) ? 0 :
-
 
609
               natint((capsule_linking.members[i]).n);
623
  capsule_no_of_tags = (i == -1) ? 0 : natint((capsule_linking.members[i]).n);
610
 
624
 
611
  i = find_index("alignment");
625
  i = find_index("alignment");
612
  capsule_no_of_als = (i == -1) ? 0 :
-
 
613
               natint((capsule_linking.members[i]).n);
626
  capsule_no_of_als = (i == -1) ? 0 : natint((capsule_linking.members[i]).n);
614
 
627
 
615
  i = find_index("diagtag");		/* OLD DIAGS */
628
  i = find_index("diagtag");		/* OLD DIAGS */
616
  capsule_no_of_diagtags = (i == -1) ? 0 :
629
  capsule_no_of_diagtags = (i == -1) ? 0 :
617
               natint((capsule_linking.members[i]).n);
630
      natint((capsule_linking.members[i]).n);
618
 
631
 
619
  i = find_index("dgtag");		/* NEW DIAGS */
632
  i = find_index("dgtag");		/* NEW DIAGS */
620
  capsule_no_of_dgtags = (i == -1) ? 0 :
-
 
621
               natint((capsule_linking.members[i]).n);
633
  capsule_no_of_dgtags = (i == -1) ? 0 : natint((capsule_linking.members[i]).n);
622
 
634
 
623
  capsule_toktab = (tok_define*)xcalloc(capsule_no_of_tokens,
635
  capsule_toktab = (tok_define *)xcalloc(capsule_no_of_tokens,
624
                          sizeof(tok_define));
636
					 sizeof(tok_define));
625
  capsule_tagtab = (dec*)xcalloc(capsule_no_of_tags, sizeof(dec));
637
  capsule_tagtab = (dec *)xcalloc(capsule_no_of_tags, sizeof(dec));
626
  capsule_altab = (aldef*)xcalloc(capsule_no_of_als, sizeof(aldef));
638
  capsule_altab = (aldef *)xcalloc(capsule_no_of_als, sizeof(aldef));
627
  capsule_diag_tagtab = (diag_tagdef*)xcalloc(capsule_no_of_diagtags,
639
  capsule_diag_tagtab = (diag_tagdef *)xcalloc(capsule_no_of_diagtags,
628
                                         sizeof(diag_tagdef));	/* OLD DIAGS */
640
					       sizeof(diag_tagdef));	 
-
 
641
  /* OLD DIAGS */
629
  capsule_dgtab = (dgtag_struct*)xcalloc(capsule_no_of_dgtags,
642
  capsule_dgtab = (dgtag_struct *)xcalloc(capsule_no_of_dgtags,
630
                                         sizeof(dgtag_struct));	/* NEW DIAGS */
643
					 sizeof(dgtag_struct));	/* NEW DIAGS */
631
 
644
 
632
  for (i = 0; i < capsule_no_of_tokens; ++i) {
645
  for (i = 0; i < capsule_no_of_tokens; ++i) {
633
        /* initialise the table of tokens */
646
     /* initialise the table of tokens */
634
    tok_define * tp = &capsule_toktab[i];
647
    tok_define *tp = &capsule_toktab[i];
635
    tp -> tok_special = 0;
648
    tp->tok_special = 0;
636
    tp -> valpresent = 0;
649
    tp->valpresent = 0;
637
    tp -> unit_number = crt_tagdef_unit_no;
650
    tp->unit_number = crt_tagdef_unit_no;
638
    tp -> defined = 0;
651
    tp->defined = 0;
639
    tp -> tok_index = i;
652
    tp->tok_index = i;
640
    tp -> is_capsule_token = 1;
653
    tp->is_capsule_token = 1;
641
    tp -> recursive = 0;
654
    tp->recursive = 0;
642
  };
655
  }
643
 
656
 
644
  for (i = 0; i < capsule_no_of_tags; ++i) {
657
  for (i = 0; i < capsule_no_of_tags; ++i) {
645
        /* initialise the table of tags */
658
    /* initialise the table of tags */
646
    dec * dp = &capsule_tagtab[i];
659
    dec *dp = &capsule_tagtab[i];
647
    dp -> dec_u.dec_val.dec_outermost = 0;
660
    dp->dec_u.dec_val.dec_outermost = 0;
648
    dp -> dec_u.dec_val.dec_id = (char *) 0;
661
    dp->dec_u.dec_val.dec_id = (char *)0;
649
    dp -> dec_u.dec_val.extnamed = 0;
662
    dp->dec_u.dec_val.extnamed = 0;
650
    dp -> dec_u.dec_val.diag_info = (diag_global *)0;
663
    dp->dec_u.dec_val.diag_info = (diag_global *)0;
651
    dp -> dec_u.dec_val.have_def = 0;
664
    dp->dec_u.dec_val.have_def = 0;
652
    dp -> dec_u.dec_val.dec_shape = nilexp;
665
    dp->dec_u.dec_val.dec_shape = nilexp;
653
    dp -> dec_u.dec_val.processed = 0;
666
    dp->dec_u.dec_val.processed = 0;
654
    dp -> dec_u.dec_val.isweak = 0;
667
    dp->dec_u.dec_val.isweak = 0;
655
  };
668
  }
656
 
669
 
657
  for (i = 0; i < capsule_no_of_als; ++i) {
670
  for (i = 0; i < capsule_no_of_als; ++i) {
658
        /* initialise the table of alignment tags */
671
    /* initialise the table of alignment tags */
659
    aldef * ap = &capsule_altab[i];
672
    aldef *ap = &capsule_altab[i];
660
    ap -> al.al_n = 0;
673
    ap->al.al_n = 0;
661
  };
674
  }
662
 
675
 
663
  init_capsule_diagtags();	/* OLD DIAGS */
676
  init_capsule_diagtags();	/* OLD DIAGS */
664
  init_capsule_dgtags();	/* NEW DIAGS */
677
  init_capsule_dgtags();	/* NEW DIAGS */
665
 
678
 
666
  return;
679
  return;
667
}
680
}
668
 
681
 
669
capsule f_make_capsule
682
capsule
670
    PROTO_N ( (prop_names, capsule_linking, external_linkage, units) )
-
 
671
    PROTO_T ( tdfstring_list prop_names X capsule_link_list capsule_linking X
683
f_make_capsule(tdfstring_list prop_names, capsule_link_list capsule_linking,
672
	      extern_link_list external_linkage X unit_list units )
684
	       extern_link_list external_linkage, unit_list units)
673
{
685
{
-
 
686
  UNUSED(prop_names);
674
  UNUSED(prop_names); UNUSED(capsule_linking);
687
  UNUSED(capsule_linking);
675
  UNUSED(external_linkage);UNUSED(units);
688
  UNUSED(external_linkage);
-
 
689
  UNUSED(units);
676
 
690
 
677
  translate_capsule();
691
  translate_capsule();
678
  return 0;
692
  return 0;
679
}
693
}
680
 
694
 
681
void init_capsule
695
void
682
    PROTO_Z ()
696
init_capsule(void)
683
{
697
{
684
  return;
698
  return;
685
}
699
}
686
 
700
 
687
capsule_link f_make_capsule_link
701
capsule_link
688
    PROTO_N ( (sn, n) )
-
 
689
    PROTO_T ( tdfstring sn X tdfint n )
702
f_make_capsule_link(tdfstring sn, tdfint n)
690
{
703
{
691
  capsule_link res;
704
  capsule_link res;
692
  res.n = n;
705
  res.n = n;
693
  res.id = (char*)sn.ints.chars;
706
  res.id = (char *)sn.ints.chars;
694
  return res;
707
  return res;
695
}
708
}
696
 
709
 
697
error_treatment f_errt_apply_token
710
error_treatment
698
    PROTO_N ( (token_value, token_args) )
-
 
699
    PROTO_T ( token token_value X bitstream token_args )
711
f_errt_apply_token(token token_value, bitstream token_args)
700
{
712
{
701
   tokval v;
713
   tokval v;
702
   v = apply_tok(token_value, token_args, ERROR_TREATMENT, (tokval*)0);
714
   v = apply_tok(token_value, token_args, ERROR_TREATMENT,(tokval *)0);
703
   return v.tk_error_treatment;
715
   return v.tk_error_treatment;
704
}
716
}
705
 
717
 
706
error_treatment f_errt_cond
718
error_treatment
707
    PROTO_N ( (control, e1, e2) )
-
 
708
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
719
f_errt_cond(exp control, bitstream e1, bitstream e2)
709
{
720
{
710
  bitstream bs;
721
  bitstream bs;
711
  error_treatment res;
722
  error_treatment res;
712
  int n;
723
  int n;
713
  bs = keep_place();
724
  bs = keep_place();
714
  if (name(control) != val_tag)
725
  if (name(control) != val_tag) {
715
    failer(CONTROL_EXP);
726
    failer(CONTROL_EXP);
-
 
727
  }
716
  n = no(control);
728
  n = no(control);
717
  retcell(control);
729
  retcell(control);
718
  if (n==0)
730
  if (n==0) {
719
   {
-
 
720
     set_place(e2);
731
     set_place(e2);
721
     res = d_error_treatment();
732
     res = d_error_treatment();
722
   }
-
 
723
  else
733
  } else {
724
   {
-
 
725
     set_place(e1);
734
     set_place(e1);
726
     res = d_error_treatment();
735
     res = d_error_treatment();
727
   };
736
  }
728
 set_place(bs);
737
  set_place(bs);
729
 return res;
738
  return res;
730
}
739
}
731
 
740
 
732
 
741
 
733
exp f_exp_apply_token
742
exp
734
    PROTO_N ( (token_value, token_args) )
-
 
735
    PROTO_T ( token token_value X bitstream token_args )
743
f_exp_apply_token(token token_value, bitstream token_args)
736
{
744
{
737
   tokval v;
745
   tokval v;
738
   v = apply_tok(token_value, token_args, EXP_S, (tokval*)0);
746
   v = apply_tok(token_value, token_args, EXP_S,(tokval *)0);
739
   return v.tk_exp;
747
   return v.tk_exp;
740
}
748
}
741
 
749
 
742
exp f_exp_cond
750
exp
743
    PROTO_N ( (control, e1, e2) )
-
 
744
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
751
f_exp_cond(exp control, bitstream e1, bitstream e2)
745
{
752
{
746
  bitstream bs;
753
  bitstream bs;
747
  exp res;
754
  exp res;
748
  int n;
755
  int n;
749
  bs = keep_place();
756
  bs = keep_place();
750
  if (name(control) != val_tag)
757
  if (name(control) != val_tag) {
751
    failer(CONTROL_EXP);
758
    failer(CONTROL_EXP);
-
 
759
  }
752
  n = no(control);
760
  n = no(control);
753
  retcell(control);
761
  retcell(control);
754
  if (n==0)
762
  if (n==0) {
755
   {
-
 
756
     set_place(e2);
763
     set_place(e2);
757
     res = d_exp();
764
     res = d_exp();
758
   }
-
 
759
  else
765
  } else {
760
   {
-
 
761
     set_place(e1);
766
     set_place(e1);
762
     res = d_exp();
767
     res = d_exp();
763
   };
768
  }
764
 set_place(bs);
769
  set_place(bs);
765
 return res;
770
  return res;
766
}
771
}
767
 
772
 
768
external f_string_extern
773
external
769
    PROTO_N ( (s) )
-
 
770
    PROTO_T ( tdfstring s )
774
f_string_extern(tdfstring s)
771
{
775
{
772
  external e;
776
  external e;
773
  e.isstring = 1;
777
  e.isstring = 1;
774
  e.ex.id = s;
778
  e.ex.id = s;
775
  return e;
779
  return e;
776
}
780
}
777
 
781
 
778
external f_unique_extern
782
external
779
    PROTO_N ( (u) )
-
 
780
    PROTO_T ( unique u )
783
f_unique_extern(unique u)
781
{
784
{
782
  external e;
785
  external e;
783
  e.isstring = 0;
786
  e.isstring = 0;
784
  e.ex.u = u;
787
  e.ex.u = u;
785
  return e;
788
  return e;
786
}
789
}
787
 
790
 
788
external f_chain_extern
791
external
789
    PROTO_N ( (s, i) )
-
 
790
    PROTO_T ( tdfstring s X tdfint i )
792
f_chain_extern(tdfstring s, tdfint i)
791
{
793
{
792
	UNUSED (s);
794
	UNUSED(s);
793
	UNUSED (i);
795
	UNUSED(i);
794
	failer("chain_extern not yet done");
796
	failer("chain_extern not yet done");
795
	return f_dummy_external;
797
	return f_dummy_external;
796
}
798
}
797
 
799
 
798
void init_external
800
void
799
    PROTO_Z ()
801
init_external(void)
800
{
802
{
801
  return;
803
  return;
802
}
804
}
803
 
805
 
804
external f_dummy_external;
806
external f_dummy_external;
805
 
807
 
806
floating_variety f_flvar_apply_token
808
floating_variety
807
    PROTO_N ( (token_value, token_args) )
-
 
808
    PROTO_T ( token token_value X bitstream token_args )
809
f_flvar_apply_token(token token_value, bitstream token_args)
809
{
810
{
810
   tokval v;
811
   tokval v;
811
   v = apply_tok(token_value, token_args, FLOATING_VARIETY, (tokval*)0);
812
   v = apply_tok(token_value, token_args, FLOATING_VARIETY,(tokval *)0);
812
   return v.tk_floating_variety;
813
   return v.tk_floating_variety;
813
}
814
}
814
 
815
 
815
floating_variety f_flvar_cond
816
floating_variety
816
    PROTO_N ( (control, e1, e2) )
-
 
817
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
817
f_flvar_cond(exp control, bitstream e1, bitstream e2)
818
{
818
{
819
  bitstream bs;
819
  bitstream bs;
820
  floating_variety res;
820
  floating_variety res;
821
  int n;
821
  int n;
822
  bs = keep_place();
822
  bs = keep_place();
823
  if (name(control) != val_tag)
823
  if (name(control) != val_tag) {
824
    failer(CONTROL_EXP);
824
    failer(CONTROL_EXP);
-
 
825
  }
825
  n = no(control);
826
  n = no(control);
826
  retcell(control);
827
  retcell(control);
827
  if (n==0)
828
  if (n == 0) {
828
   {
-
 
829
     set_place(e2);
829
     set_place(e2);
830
     res = d_floating_variety();
830
     res = d_floating_variety();
831
   }
-
 
832
  else
831
  } else {
833
   {
-
 
834
     set_place(e1);
832
     set_place(e1);
835
     res = d_floating_variety();
833
     res = d_floating_variety();
836
   };
834
  }
837
 set_place(bs);
835
  set_place(bs);
838
 return res;
836
  return res;
839
}
837
}
840
 
838
 
841
 
839
 
842
label f_label_apply_token
840
label
843
    PROTO_N ( (token_value, token_args) )
-
 
844
    PROTO_T ( token token_value X bitstream token_args )
841
f_label_apply_token(token token_value, bitstream token_args)
845
{
842
{
846
   tokval v;
843
   tokval v;
847
   v = apply_tok(token_value, token_args, LABEL, (tokval*)0);
844
   v = apply_tok(token_value, token_args, LABEL,(tokval *)0);
848
   return v.tk_label;
845
   return v.tk_label;
849
}
846
}
850
 
847
 
851
label f_make_label
848
label
852
    PROTO_N ( (labelno) )
-
 
853
    PROTO_T ( tdfint labelno )
849
f_make_label(tdfint labelno)
854
{
850
{
855
  return &unit_labtab[natint(labelno)];
851
  return &unit_labtab[natint(labelno)];
856
}
852
}
857
 
853
 
858
void init_label
854
void
859
    PROTO_Z ()
855
init_label(void)
860
{
856
{
861
  return;
857
  return;
862
}
858
}
863
 
859
 
864
label f_dummy_label;
860
label f_dummy_label;
865
 
861
 
866
nat f_nat_apply_token
862
nat
867
    PROTO_N ( (token_value, token_args) )
-
 
868
    PROTO_T ( token token_value X bitstream token_args )
863
f_nat_apply_token(token token_value, bitstream token_args)
869
{
864
{
870
   tokval v;
865
   tokval v;
871
   v = apply_tok(token_value, token_args, NAT, (tokval*)0);
866
   v = apply_tok(token_value, token_args, NAT, (tokval *)0);
872
   return v.tk_nat;
867
   return v.tk_nat;
873
}
868
}
874
 
869
 
875
nat f_nat_cond
870
nat
876
    PROTO_N ( (control, e1, e2) )
-
 
877
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
871
f_nat_cond(exp control, bitstream e1, bitstream e2)
878
{
872
{
879
  bitstream bs;
873
  bitstream bs;
880
  nat res;
874
  nat res;
881
  int n;
875
  int n;
882
  bs = keep_place();
876
  bs = keep_place();
883
  if (name(control) != val_tag)
877
  if (name(control) != val_tag) {
884
    failer(CONTROL_EXP);
878
    failer(CONTROL_EXP);
-
 
879
  }
885
  n = no(control);
880
  n = no(control);
886
  retcell(control);
881
  retcell(control);
887
  if (n==0)
882
  if (n == 0) {
888
   {
-
 
889
     set_place(e2);
883
     set_place(e2);
890
     res = d_nat();
884
     res = d_nat();
891
   }
-
 
892
  else
885
  } else {
893
   {
-
 
894
     set_place(e1);
886
     set_place(e1);
895
     res = d_nat();
887
     res = d_nat();
896
   };
888
  }
897
 set_place(bs);
889
  set_place(bs);
898
 return res;
890
  return res;
899
}
891
}
900
 
892
 
901
ntest f_ntest_apply_token
893
ntest
902
    PROTO_N ( (token_value, token_args) )
-
 
903
    PROTO_T ( token token_value X bitstream token_args )
894
f_ntest_apply_token(token token_value, bitstream token_args)
904
{
895
{
905
   tokval v;
896
   tokval v;
906
   v = apply_tok(token_value, token_args, NTEST, (tokval*)0);
897
   v = apply_tok(token_value, token_args, NTEST, (tokval *)0);
907
   return v.tk_ntest;
898
   return v.tk_ntest;
908
}
899
}
909
 
900
 
910
ntest f_ntest_cond
901
ntest
911
    PROTO_N ( (control, e1, e2) )
-
 
912
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
902
f_ntest_cond(exp control, bitstream e1, bitstream e2)
913
{
903
{
914
  bitstream bs;
904
  bitstream bs;
915
  ntest res;
905
  ntest res;
916
  int n;
906
  int n;
917
  bs = keep_place();
907
  bs = keep_place();
918
  if (name(control) != val_tag)
908
  if (name(control) != val_tag) {
919
    failer(CONTROL_EXP);
909
    failer(CONTROL_EXP);
-
 
910
  }
920
  n = no(control);
911
  n = no(control);
921
  retcell(control);
912
  retcell(control);
922
  if (n==0)
913
  if (n == 0) {
923
   {
-
 
924
     set_place(e2);
914
     set_place(e2);
925
     res = d_ntest();
915
     res = d_ntest();
926
   }
-
 
927
  else
916
  } else {
928
   {
-
 
929
     set_place(e1);
917
     set_place(e1);
930
     res = d_ntest();
918
     res = d_ntest();
931
   };
919
  }
932
 set_place(bs);
920
  set_place(bs);
933
 return res;
921
  return res;
934
}
922
}
935
 
923
 
936
rounding_mode f_rounding_mode_apply_token
924
rounding_mode
937
    PROTO_N ( (token_value, token_args) )
-
 
938
    PROTO_T ( token token_value X bitstream token_args )
925
f_rounding_mode_apply_token(token token_value, bitstream token_args)
939
{
926
{
940
   tokval v;
927
   tokval v;
941
   v = apply_tok(token_value, token_args, ROUNDING_MODE, (tokval*)0);
928
   v = apply_tok(token_value, token_args, ROUNDING_MODE, (tokval *)0);
942
   return v.tk_rounding_mode;
929
   return v.tk_rounding_mode;
943
}
930
}
944
 
931
 
945
rounding_mode f_rounding_mode_cond
932
rounding_mode
946
    PROTO_N ( (control, e1, e2) )
-
 
947
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
933
f_rounding_mode_cond(exp control, bitstream e1, bitstream e2)
948
{
934
{
949
  bitstream bs;
935
  bitstream bs;
950
  rounding_mode res;
936
  rounding_mode res;
951
  int n;
937
  int n;
952
  bs = keep_place();
938
  bs = keep_place();
953
  if (name(control) != val_tag)
939
  if (name(control) != val_tag)
954
    failer(CONTROL_EXP);
940
    failer(CONTROL_EXP);
955
  n = no(control);
941
  n = no(control);
956
  retcell(control);
942
  retcell(control);
957
  if (n==0)
943
  if (n == 0) {
958
   {
-
 
959
     set_place(e2);
944
     set_place(e2);
960
     res = d_rounding_mode();
945
     res = d_rounding_mode();
961
   }
-
 
962
  else
946
  } else {
963
   {
-
 
964
     set_place(e1);
947
     set_place(e1);
965
     res = d_rounding_mode();
948
     res = d_rounding_mode();
966
   };
949
  }
967
 set_place(bs);
950
  set_place(bs);
968
 return res;
951
  return res;
969
}
952
}
970
 
953
 
971
shape f_shape_apply_token
954
shape
972
    PROTO_N ( (token_value, token_args) )
-
 
973
    PROTO_T ( token token_value X bitstream token_args )
955
f_shape_apply_token(token token_value, bitstream token_args)
974
{
956
{
975
   tokval v;
957
   tokval v;
976
   v = apply_tok(token_value, token_args, SHAPE, (tokval*)0);
958
   v = apply_tok(token_value, token_args, SHAPE, (tokval *)0);
977
   return v.tk_shape;
959
   return v.tk_shape;
978
}
960
}
979
 
961
 
980
shape f_shape_cond
962
shape
981
    PROTO_N ( (control, e1, e2) )
-
 
982
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
963
f_shape_cond(exp control, bitstream e1, bitstream e2)
983
{
964
{
984
  bitstream bs;
965
  bitstream bs;
985
  shape res;
966
  shape res;
986
  int n;
967
  int n;
987
  bs = keep_place();
968
  bs = keep_place();
988
  if (name(control) != val_tag)
969
  if (name(control) != val_tag) {
989
    failer(CONTROL_EXP);
970
    failer(CONTROL_EXP);
-
 
971
  }
990
  n = no(control);
972
  n = no(control);
991
  retcell(control);
973
  retcell(control);
992
  if (n==0)
974
  if (n == 0) {
993
   {
-
 
994
     set_place(e2);
975
     set_place(e2);
995
     res = d_shape();
976
     res = d_shape();
996
   }
-
 
997
  else
977
  } else {
998
   {
-
 
999
     set_place(e1);
978
     set_place(e1);
1000
     res = d_shape();
979
     res = d_shape();
1001
   };
980
  }
1002
 set_place(bs);
981
  set_place(bs);
1003
 return res;
982
  return res;
1004
}
983
}
1005
 
984
 
1006
signed_nat f_signed_nat_apply_token
985
signed_nat
1007
    PROTO_N ( (token_value, token_args) )
-
 
1008
    PROTO_T ( token token_value X bitstream token_args )
986
f_signed_nat_apply_token(token token_value, bitstream token_args)
1009
{
987
{
1010
   tokval v;
988
   tokval v;
1011
   v = apply_tok(token_value, token_args, SIGNED_NAT, (tokval*)0);
989
   v = apply_tok(token_value, token_args, SIGNED_NAT, (tokval *)0);
1012
   return v.tk_signed_nat;
990
   return v.tk_signed_nat;
1013
}
991
}
1014
 
992
 
1015
signed_nat f_signed_nat_cond
993
signed_nat
1016
    PROTO_N ( (control, e1, e2) )
-
 
1017
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
994
f_signed_nat_cond(exp control, bitstream e1, bitstream e2)
1018
{
995
{
1019
  bitstream bs;
996
  bitstream bs;
1020
  signed_nat res;
997
  signed_nat res;
1021
  int n;
998
  int n;
1022
  bs = keep_place();
999
  bs = keep_place();
1023
  if (name(control) != val_tag)
1000
  if (name(control) != val_tag) {
1024
    failer(CONTROL_EXP);
1001
    failer(CONTROL_EXP);
-
 
1002
  }
1025
  n = no(control);
1003
  n = no(control);
1026
  retcell(control);
1004
  retcell(control);
1027
  if (n==0)
1005
  if (n == 0) {
1028
   {
-
 
1029
     set_place(e2);
1006
     set_place(e2);
1030
     res = d_signed_nat();
1007
     res = d_signed_nat();
1031
   }
-
 
1032
  else
1008
  } else {
1033
   {
-
 
1034
     set_place(e1);
1009
     set_place(e1);
1035
     res = d_signed_nat();
1010
     res = d_signed_nat();
1036
   };
1011
  }
1037
 set_place(bs);
1012
  set_place(bs);
1038
 return res;
1013
  return res;
1039
 
1014
 
1040
}
1015
}
1041
 
1016
 
1042
 
1017
 
1043
sortname f_alignment_sort;
1018
sortname f_alignment_sort;
Line 1066... Line 1041...
1066
sortname f_dg_filename;		/* NEW DIAGS */
1041
sortname f_dg_filename;		/* NEW DIAGS */
1067
sortname f_dg_idname;		/* NEW DIAGS */
1042
sortname f_dg_idname;		/* NEW DIAGS */
1068
sortname f_dg_name;		/* NEW DIAGS */
1043
sortname f_dg_name;		/* NEW DIAGS */
1069
sortname f_dg_type;		/* NEW DIAGS */
1044
sortname f_dg_type;		/* NEW DIAGS */
1070
 
1045
 
1071
sortname f_foreign_sort
1046
sortname
1072
    PROTO_N ( (foreign_name) )
-
 
1073
    PROTO_T ( tdfstring foreign_name )
1047
f_foreign_sort(tdfstring foreign_name)
1074
{
1048
{
1075
  if (!strcmp(foreign_name.ints.chars, "~diag_file"))	/* OLD DIAGS */
1049
  if (!strcmp(foreign_name.ints.chars, "~diag_file")) {	/* OLD DIAGS */
1076
    return f_diag_filename;
1050
    return f_diag_filename;
-
 
1051
  }
1077
  if (!strcmp(foreign_name.ints.chars, "~diag_type"))	/* OLD DIAGS */
1052
  if (!strcmp(foreign_name.ints.chars, "~diag_type")) {	/* OLD DIAGS */
1078
    return f_diag_type;
1053
    return f_diag_type;
-
 
1054
  }
1079
  if (!strcmp(foreign_name.ints.chars, "DG"))		/* NEW DIAGS */
1055
  if (!strcmp(foreign_name.ints.chars, "DG")) {		/* NEW DIAGS */
1080
    return f_dg;
1056
    return f_dg;
-
 
1057
  }
1081
  if (!strcmp(foreign_name.ints.chars, "DG_DIM"))	/* NEW DIAGS */
1058
  if (!strcmp(foreign_name.ints.chars, "DG_DIM")) {	/* NEW DIAGS */
1082
    return f_dg_dim;
1059
    return f_dg_dim;
-
 
1060
  }
1083
  if (!strcmp(foreign_name.ints.chars, "DG_FILENAME"))	/* NEW DIAGS */
1061
  if (!strcmp(foreign_name.ints.chars, "DG_FILENAME")) {/* NEW DIAGS */
1084
    return f_dg_filename;
1062
    return f_dg_filename;
-
 
1063
  }
1085
  if (!strcmp(foreign_name.ints.chars, "DG_IDNAME"))	/* NEW DIAGS */
1064
  if (!strcmp(foreign_name.ints.chars, "DG_IDNAME")) {	/* NEW DIAGS */
1086
    return f_dg_idname;
1065
    return f_dg_idname;
-
 
1066
  }
1087
  if (!strcmp(foreign_name.ints.chars, "DG_NAME"))	/* NEW DIAGS */
1067
  if (!strcmp(foreign_name.ints.chars, "DG_NAME")) {	/* NEW DIAGS */
1088
    return f_dg_name;
1068
    return f_dg_name;
-
 
1069
  }
1089
  if (!strcmp(foreign_name.ints.chars, "DG_TYPE"))	/* NEW DIAGS */
1070
  if (!strcmp(foreign_name.ints.chars, "DG_TYPE")) {	/* NEW DIAGS */
1090
    return f_dg_type;
1071
    return f_dg_type;
-
 
1072
  }
1091
  return f_foreign;
1073
  return f_foreign;
1092
}
1074
}
1093
 
1075
 
1094
sortname f_token
1076
sortname
1095
    PROTO_N ( (result, params) )
-
 
1096
    PROTO_T ( sortname result X sortname_list params )
1077
f_token(sortname result, sortname_list params)
1097
{
1078
{
1098
   sortname res;
1079
   sortname res;
1099
   res.code = TOKEN;
1080
   res.code = TOKEN;
1100
   res.result = result.code;
1081
   res.result = result.code;
1101
   res.pars = params;
1082
   res.pars = params;
1102
   return res;
1083
   return res;
1103
}
1084
}
1104
 
1085
 
1105
sortname f_variety;
1086
sortname f_variety;
1106
void init_sortname
1087
void
1107
    PROTO_Z ()
1088
init_sortname(void)
1108
{
1089
{
1109
   f_alignment_sort.code = ALIGNMENT_SORT;
1090
   f_alignment_sort.code = ALIGNMENT_SORT;
1110
   f_bitfield_variety.code =   BITFIELD_VARIETY;
1091
   f_bitfield_variety.code = BITFIELD_VARIETY;
1111
   f_bool.code =   BOOL;
1092
   f_bool.code = BOOL;
1112
   f_error_treatment.code =   ERROR_TREATMENT;
1093
   f_error_treatment.code = ERROR_TREATMENT;
1113
   f_exp.code =   EXP_S;
1094
   f_exp.code = EXP_S;
1114
   f_floating_variety.code =   FLOATING_VARIETY;
1095
   f_floating_variety.code = FLOATING_VARIETY;
1115
   f_label.code = LABEL;
1096
   f_label.code = LABEL;
1116
   f_nat.code =   NAT;
1097
   f_nat.code = NAT;
1117
   f_ntest.code =   NTEST;
1098
   f_ntest.code = NTEST;
1118
   f_rounding_mode.code =   ROUNDING_MODE;
1099
   f_rounding_mode.code = ROUNDING_MODE;
1119
   f_shape.code =   SHAPE;
1100
   f_shape.code = SHAPE;
1120
   f_signed_nat.code =   SIGNED_NAT;
1101
   f_signed_nat.code = SIGNED_NAT;
1121
   f_tag.code = TAG;
1102
   f_tag.code = TAG;
1122
   f_al_tag.code = AL_TAG;
1103
   f_al_tag.code = AL_TAG;
1123
   f_variety.code = VARIETY;
1104
   f_variety.code = VARIETY;
1124
   f_diag_filename.code = DIAG_FILENAME;	/* OLD DIAGS */
1105
   f_diag_filename.code = DIAG_FILENAME;	/* OLD DIAGS */
1125
   f_diag_type.code = DIAG_TYPE_SORT;		/* OLD DIAGS */
1106
   f_diag_type.code = DIAG_TYPE_SORT;		/* OLD DIAGS */
Line 1138... Line 1119...
1138
   return;
1119
   return;
1139
}
1120
}
1140
 
1121
 
1141
sortname f_dummy_sortname;
1122
sortname f_dummy_sortname;
1142
 
1123
 
1143
tag f_tag_apply_token
1124
tag
1144
    PROTO_N ( (token_value, token_args) )
-
 
1145
    PROTO_T ( token token_value X bitstream token_args )
1125
f_tag_apply_token(token token_value, bitstream token_args)
1146
{
1126
{
1147
   tokval v;
1127
   tokval v;
1148
   v = apply_tok(token_value, token_args, TAG, (tokval*)0);
1128
   v = apply_tok(token_value, token_args, TAG, (tokval *)0);
1149
   return v.tk_tag;
1129
   return v.tk_tag;
1150
}
1130
}
1151
 
1131
 
1152
al_tag f_al_tag_apply_token
1132
al_tag
1153
    PROTO_N ( (token_value, token_args) )
-
 
1154
    PROTO_T ( token token_value X bitstream token_args )
1133
f_al_tag_apply_token(token token_value, bitstream token_args)
1155
{
1134
{
1156
   tokval v;
1135
   tokval v;
1157
   v = apply_tok(token_value, token_args, AL_TAG, (tokval*)0);
1136
   v = apply_tok(token_value, token_args, AL_TAG, (tokval *)0);
1158
   return v.tk_al_tag;
1137
   return v.tk_al_tag;
1159
}
1138
}
1160
 
1139
 
1161
tag f_make_tag
1140
tag
1162
    PROTO_N ( (tagno) )
-
 
1163
    PROTO_T ( tdfint tagno )
1141
f_make_tag(tdfint tagno)
1164
{
1142
{
1165
  return get_dec(natint(tagno));
1143
  return get_dec(natint(tagno));
1166
}
1144
}
1167
 
1145
 
1168
void init_tag
1146
void
1169
    PROTO_Z ()
1147
init_tag(void)
1170
{
1148
{
1171
  return;
1149
  return;
1172
}
1150
}
1173
 
1151
 
1174
al_tag f_make_al_tag
1152
al_tag
1175
    PROTO_N ( (tagno) )
-
 
1176
    PROTO_T ( tdfint tagno )
1153
f_make_al_tag(tdfint tagno)
1177
{
1154
{
1178
  return get_aldef(natint(tagno));
1155
  return get_aldef(natint(tagno));
1179
}
1156
}
1180
 
1157
 
1181
void init_al_tag
1158
void
1182
    PROTO_Z ()
1159
init_al_tag(void)
1183
{
1160
{
1184
  return;
1161
  return;
1185
}
1162
}
1186
 
1163
 
1187
tag f_dummy_tag;
1164
tag f_dummy_tag;
1188
al_tag f_dummy_al_tag;
1165
al_tag f_dummy_al_tag;
1189
 
1166
 
1190
void check_sig
1167
void
1191
    PROTO_N ( (tg, sig) )
-
 
1192
    PROTO_T ( tag tg X string sig )
1168
check_sig(tag tg, string sig)
1193
{
1169
{
1194
	char * sid = sig.ints.chars;
1170
	char *sid = sig.ints.chars;
1195
	int s = (sig.size*sig.number)/8;
1171
	int s = (sig.size * sig.number) / 8;
1196
	if (tg->dec_u.dec_val.has_signature) {
1172
	if (tg->dec_u.dec_val.has_signature) {
1197
		char * id = tg->dec_u.dec_val.dec_id;
1173
		char *id = tg->dec_u.dec_val.dec_id;
1198
	    	int i;
1174
	    	int i;
1199
		for(i=0; i<s; i++) {
1175
		for (i = 0; i < s; i++) {
1200
			if (id[i]!=sid[i]) break;
1176
			if (id[i] != sid[i]) {
-
 
1177
				break;
-
 
1178
			}
1201
		}
1179
		}
1202
		if (i!=s || id[s] !=0) {
1180
		if (i != s || id[s] != 0) {
1203
			   IGNORE fprintf(stderr, "%s\n%s\n", id, sid);
1181
			   IGNORE fprintf(stderr, "%s\n%s\n", id, sid);
1204
			   failer("Signatures should be equal");
1182
			   failer("Signatures should be equal");
1205
		}
1183
		}
1206
	}
-
 
1207
	else {
1184
	} else {
1208
		tg->dec_u.dec_val.dec_id = sid;
1185
		tg->dec_u.dec_val.dec_id = sid;
1209
		tg->dec_u.dec_val.has_signature = 1;
1186
		tg->dec_u.dec_val.has_signature = 1;
1210
	}
1187
	}
1211
}
1188
}
1212
 
1189
 
1213
 
1190
 
1214
 
1191
 
1215
 
1192
 
1216
 
1193
 
1217
tagdec f_make_id_tagdec
1194
tagdec
1218
    PROTO_N ( (t_intro, acc, sig, x) )
-
 
1219
    PROTO_T ( tdfint t_intro X access_option acc X string_option sig X shape x )
1195
f_make_id_tagdec(tdfint t_intro, access_option acc, string_option sig, shape x)
1220
{
1196
{
1221
  tagdec res;
1197
  tagdec res;
1222
  res.tg = get_dec(natint(t_intro));
1198
  res.tg = get_dec(natint(t_intro));
1223
  res.sha = x;
1199
  res.sha = x;
1224
  res.acc = acc;
1200
  res.acc = acc;
1225
  res.is_variable = 0;
1201
  res.is_variable = 0;
1226
  res.is_common = 0;
1202
  res.is_common = 0;
1227
  res.tg -> dec_u.dec_val.is_common = 0;
1203
  res.tg->dec_u.dec_val.is_common = 0;
-
 
1204
  if (sig.present) {
1228
  if (sig.present) check_sig(res.tg, sig.val);
1205
    check_sig(res.tg, sig.val);
-
 
1206
  }
1229
  return res;
1207
  return res;
1230
}
1208
}
1231
 
1209
 
1232
tagdec f_make_var_tagdec
1210
tagdec
1233
    PROTO_N ( (t_intro, acc, sig, x) )
-
 
1234
    PROTO_T ( tdfint t_intro X access_option acc X string_option sig X shape x )
1211
f_make_var_tagdec(tdfint t_intro, access_option acc, string_option sig, shape x)
1235
{
1212
{
1236
  tagdec res;
1213
  tagdec res;
1237
  res.tg = get_dec(natint(t_intro));
1214
  res.tg = get_dec(natint(t_intro));
1238
  res.sha = x;
1215
  res.sha = x;
1239
  res.acc = acc;
1216
  res.acc = acc;
1240
  res.is_variable = 1;
1217
  res.is_variable = 1;
1241
  res.is_common = 0;
1218
  res.is_common = 0;
1242
  res.tg -> dec_u.dec_val.is_common = 0;
1219
  res.tg->dec_u.dec_val.is_common = 0;
-
 
1220
  if (sig.present) {
1243
  if (sig.present) check_sig(res.tg, sig.val);
1221
    check_sig(res.tg, sig.val);
-
 
1222
  }
1244
  return res;
1223
  return res;
1245
}
1224
}
1246
 
1225
 
1247
tagdec f_common_tagdec
1226
tagdec
1248
    PROTO_N ( (t_intro, acc, sig, x) )
-
 
1249
    PROTO_T ( tdfint t_intro X access_option acc X string_option sig X shape x )
1227
f_common_tagdec(tdfint t_intro, access_option acc, string_option sig, shape x)
1250
{
1228
{
1251
  tagdec res;
1229
  tagdec res;
1252
  res.tg = get_dec(natint(t_intro));
1230
  res.tg = get_dec(natint(t_intro));
1253
  res.sha = x;
1231
  res.sha = x;
1254
  res.acc = acc;
1232
  res.acc = acc;
1255
  res.is_variable = 1;
1233
  res.is_variable = 1;
1256
  res.is_common = 1;
1234
  res.is_common = 1;
1257
  res.tg -> dec_u.dec_val.is_common = 0;
1235
  res.tg->dec_u.dec_val.is_common = 0;
-
 
1236
  if (sig.present) {
1258
  if (sig.present) check_sig(res.tg, sig.val);
1237
    check_sig(res.tg, sig.val);
-
 
1238
  }
1259
  return res;
1239
  return res;
1260
}
1240
}
1261
 
1241
 
1262
void init_tagdec
1242
void
1263
    PROTO_Z ()
1243
init_tagdec(void)
1264
{
1244
{
1265
  return;
1245
  return;
1266
}
1246
}
1267
 
1247
 
1268
tagdec f_dummy_tagdec;
1248
tagdec f_dummy_tagdec;
1269
 
1249
 
1270
 
1250
 
1271
void start_make_id_tagdef
1251
void
1272
    PROTO_N ( (t) )
-
 
1273
    PROTO_T ( tdfint t )
1252
start_make_id_tagdef(tdfint t)
1274
{
1253
{
1275
  UNUSED(t);
1254
  UNUSED(t);
1276
  rep_make_proc = 0;
1255
  rep_make_proc = 0;
1277
  return;
1256
  return;
1278
}
1257
}
1279
 
1258
 
1280
tagdef f_make_id_tagdef
1259
tagdef
1281
    PROTO_N ( (t, sig, e) )
-
 
1282
    PROTO_T ( tdfint t X string_option sig X exp e )
1260
f_make_id_tagdef(tdfint t, string_option sig, exp e)
1283
{
1261
{
1284
  dec * dp = get_dec(natint(t));
1262
  dec *dp = get_dec(natint(t));
1285
  tagdef res;
1263
  tagdef res;
1286
  res.tg = dp;
1264
  res.tg = dp;
1287
  if (dp -> dec_u.dec_val.processed ||
1265
  if (dp->dec_u.dec_val.processed ||
1288
        son(dp -> dec_u.dec_val.dec_exp) != nilexp)
1266
      son(dp->dec_u.dec_val.dec_exp) != nilexp) {
1289
    res.def = nilexp; /* set to nilexp if already output */
1267
    res.def = nilexp; /* set to nilexp if already output */
1290
  else
1268
  } else {
1291
    res.def = e;
1269
    res.def = e;
-
 
1270
  }
1292
  res.var = 0;
1271
  res.var = 0;
1293
  res.is_common = 0;
1272
  res.is_common = 0;
-
 
1273
  if (sig.present) {
1294
  if (sig.present) check_sig(dp, sig.val);
1274
    check_sig(dp, sig.val);
-
 
1275
  }
1295
  rep_make_proc = 1;
1276
  rep_make_proc = 1;
1296
  return res;
1277
  return res;
1297
}
1278
}
1298
 
1279
 
1299
void start_make_var_tagdef
1280
void
1300
    PROTO_N ( (t) )
-
 
1301
    PROTO_T ( tdfint t )
1281
start_make_var_tagdef(tdfint t)
1302
{
1282
{
1303
  UNUSED(t);
1283
  UNUSED(t);
1304
 
1284
 
1305
  return;
1285
  return;
1306
}
1286
}
1307
 
1287
 
1308
tagdef f_make_var_tagdef
1288
tagdef
1309
    PROTO_N ( (t, opt_access, sig, e) )
-
 
1310
    PROTO_T ( tdfint t X access_option opt_access X string_option sig X exp e )
1289
f_make_var_tagdef(tdfint t, access_option opt_access, string_option sig, exp e)
1311
{
1290
{
1312
  dec * dp = get_dec(natint(t));
1291
  dec *dp = get_dec(natint(t));
1313
  tagdef res;
1292
  tagdef res;
1314
  UNUSED(opt_access);
1293
  UNUSED(opt_access);
1315
  res.tg = dp;
1294
  res.tg = dp;
1316
  if (dp -> dec_u.dec_val.processed ||
1295
  if (dp->dec_u.dec_val.processed ||
1317
        son(dp -> dec_u.dec_val.dec_exp) != nilexp)
1296
      son(dp->dec_u.dec_val.dec_exp) != nilexp) {
1318
    res.def = nilexp; /* set to nilexp if already output */
1297
    res.def = nilexp; /* set to nilexp if already output */
1319
  else
1298
  } else {
1320
    res.def = e;
1299
    res.def = e;
-
 
1300
  }
1321
  res.var = 1;
1301
  res.var = 1;
1322
  res.is_common = 0;
1302
  res.is_common = 0;
-
 
1303
  if (sig.present) {
1323
  if (sig.present) check_sig(dp, sig.val);
1304
    check_sig(dp, sig.val);
-
 
1305
  }
1324
  return res;
1306
  return res;
1325
}
1307
}
1326
 
1308
 
1327
void start_common_tagdef
1309
void
1328
    PROTO_N ( (t) )
-
 
1329
    PROTO_T ( tdfint t )
1310
start_common_tagdef(tdfint t)
1330
{
1311
{
1331
  UNUSED(t);
1312
  UNUSED(t);
1332
  return;
1313
  return;
1333
}
1314
}
1334
 
1315
 
1335
tagdef f_common_tagdef
1316
tagdef
1336
    PROTO_N ( (t, opt_access, sig, e) )
-
 
1337
    PROTO_T ( tdfint t X access_option opt_access X string_option sig X exp e )
1317
f_common_tagdef(tdfint t, access_option opt_access, string_option sig, exp e)
1338
{
1318
{
1339
  dec * dp = get_dec(natint(t));
1319
  dec *dp = get_dec(natint(t));
1340
  tagdef res;
1320
  tagdef res;
1341
  UNUSED(opt_access);
1321
  UNUSED(opt_access);
1342
  res.tg = dp;
1322
  res.tg = dp;
1343
  res.def = e;
1323
  res.def = e;
1344
  res.var = 1;
1324
  res.var = 1;
1345
  res.is_common = 1;
1325
  res.is_common = 1;
-
 
1326
  if (sig.present) {
1346
  if (sig.present) check_sig(dp, sig.val);
1327
    check_sig(dp, sig.val);
-
 
1328
  }
1347
  return res;
1329
  return res;
1348
}
1330
}
1349
 
1331
 
1350
void init_tagdef
1332
void
1351
    PROTO_Z ()
1333
init_tagdef(void)
1352
{
1334
{
1353
  return;
1335
  return;
1354
}
1336
}
1355
 
1337
 
1356
void init_al_tagdef
1338
void
1357
    PROTO_Z ()
1339
init_al_tagdef(void)
1358
{
1340
{
1359
  return;
1341
  return;
1360
}
1342
}
1361
 
1343
 
1362
tagdef f_dummy_tagdef;
1344
tagdef f_dummy_tagdef;
1363
al_tagdef f_dummy_al_tagdef;
1345
al_tagdef f_dummy_al_tagdef;
1364
 
1346
 
1365
char* add_prefix
1347
char *
1366
    PROTO_N ( (nm) )
-
 
1367
    PROTO_T ( char * nm )
1348
add_prefix(char *nm)
1368
{
1349
{
1369
  char * id;
1350
  char *id;
1370
  int idl = (int)strlen(nm);
1351
  int idl = (int)strlen(nm);
1371
  int   j;
1352
  int j;
1372
  int npl = (int)strlen(name_prefix);
1353
  int npl = (int)strlen(name_prefix);
1373
  if (npl == 0) return nm;
1354
  if (npl == 0) {
-
 
1355
    return nm;
-
 
1356
  }
1374
  id = (char *) xcalloc ( (idl + npl + 1), sizeof (char));
1357
  id = (char *)xcalloc((idl + npl + 1), sizeof(char));
1375
  id[idl + npl] = 0;
1358
  id[idl + npl] = 0;
1376
  for (j = npl; j < (idl+npl); ++j)
1359
  for (j = npl; j < (idl + npl); ++j) {
1377
    id[j] = nm[j-npl];
1360
    id[j] = nm[j - npl];
-
 
1361
  }
1378
  for (j = 0; j < npl; ++j)
1362
  for (j = 0; j < npl; ++j) {
1379
    id[j] = name_prefix[j];
1363
    id[j] = name_prefix[j];
-
 
1364
  }
1380
  return id;
1365
  return id;
1381
}
1366
}
1382
 
1367
 
1383
tagextern f_make_tagextern
1368
tagextern
1384
    PROTO_N ( (internal, ext) )
-
 
1385
    PROTO_T ( tdfint internal X external ext )
1369
f_make_tagextern(tdfint internal, external ext)
1386
{
1370
{
1387
  dec * dp = &capsule_tagtab[natint(internal)];
1371
  dec *dp = &capsule_tagtab[natint(internal)];
1388
  char *nm = external_to_string(ext);
1372
  char *nm = external_to_string(ext);
1389
  char * id = add_prefix(nm);
1373
  char *id = add_prefix(nm);
1390
  dp -> dec_u.dec_val.dec_id = id;
1374
  dp->dec_u.dec_val.dec_id = id;
1391
  dp -> dec_u.dec_val.dec_outermost = 1;
1375
  dp->dec_u.dec_val.dec_outermost = 1;
1392
  dp -> dec_u.dec_val.extnamed = 1;
1376
  dp->dec_u.dec_val.extnamed = 1;
1393
 
1377
 
1394
  return 0;
1378
  return 0;
1395
}
1379
}
1396
 
1380
 
1397
taglink f_make_taglink
1381
taglink
1398
    PROTO_N ( (internal, ext) )
-
 
1399
    PROTO_T ( tdfint internal X tdfint ext )
1382
f_make_taglink(tdfint internal, tdfint ext)
1400
{
1383
{
1401
  unit_ind_tags[natint(internal)] =
1384
  unit_ind_tags[natint(internal)] = &capsule_tagtab[natint(ext)];
1402
      &capsule_tagtab[natint(ext)];
-
 
1403
  return 0;
1385
  return 0;
1404
}
1386
}
1405
 
1387
 
1406
 
1388
 
1407
allink f_make_allink
1389
allink
1408
    PROTO_N ( (internal, ext) )
-
 
1409
    PROTO_T ( tdfint internal X tdfint ext )
1390
f_make_allink(tdfint internal, tdfint ext)
1410
{
1391
{
1411
  unit_ind_als[natint(internal)] =
1392
  unit_ind_als[natint(internal)] = &capsule_altab[natint(ext)];
1412
      &capsule_altab[natint(ext)];
-
 
1413
  return 0;
1393
  return 0;
1414
}
1394
}
1415
 
1395
 
1416
 
1396
 
1417
tokdec f_make_tokdec
1397
tokdec
1418
    PROTO_N ( (tok, sig, s) )
-
 
1419
    PROTO_T ( tdfint tok X string_option sig X sortname s )
1398
f_make_tokdec(tdfint tok, string_option sig, sortname s)
1420
{
1399
{
1421
  tok_define * tok_d = get_tok(natint(tok));
1400
  tok_define *tok_d = get_tok(natint(tok));
-
 
1401
  if (sig.present) {
1422
  if (sig.present) check_tok_sig(tok_d, sig.val);
1402
    check_tok_sig(tok_d, sig.val);
-
 
1403
  }
1423
  UNUSED(s);
1404
  UNUSED(s);
1424
  return 0;
1405
  return 0;
1425
}
1406
}
1426
 
1407
 
1427
void init_tokdec
1408
void
1428
    PROTO_Z ()
1409
init_tokdec(void)
1429
{
1410
{
1430
  return;
1411
  return;
1431
}
1412
}
1432
 
1413
 
1433
tokdec f_dummy_tokdec;
1414
tokdec f_dummy_tokdec;
1434
 
1415
 
1435
tokdef f_make_tokdef
1416
tokdef
1436
    PROTO_N ( (tokn, sig,def) )
-
 
1437
    PROTO_T ( tdfint tokn X string_option sig X bitstream def )
1417
f_make_tokdef(tdfint tokn, string_option sig, bitstream def)
1438
{
1418
{
1439
  sortname result_sort;
1419
  sortname result_sort;
1440
  tokformals_list params;
1420
  tokformals_list params;
1441
  place old_place;
1421
  place old_place;
1442
  tok_define * tok = get_tok(natint(tokn));
1422
  tok_define *tok = get_tok(natint(tokn));
-
 
1423
  if (sig.present) {
1443
  if (sig.present) check_tok_sig(tok, sig.val);
1424
    check_tok_sig(tok, sig.val);
-
 
1425
  }
1444
  old_place = keep_place();
1426
  old_place = keep_place();
1445
  set_place(def);
1427
  set_place(def);
1446
  IGNORE getcode(1);
1428
  IGNORE getcode(1);
1447
  result_sort = d_sortname();
1429
  result_sort = d_sortname();
1448
  params = d_tokformals_list();
1430
  params = d_tokformals_list();
1449
  tok -> tdsort = result_sort;
1431
  tok->tdsort = result_sort;
1450
  tok -> params = params;
1432
  tok->params = params;
1451
  tok -> tdplace = keep_place();
1433
  tok->tdplace = keep_place();
1452
  tok -> defined = 1;
1434
  tok->defined = 1;
1453
  tok->tok_context = (context*)0;
1435
  tok->tok_context = (context *)0;
1454
 
1436
 
1455
    /* record the tables which are current so that they can be
1437
    /* record the tables which are current so that they can be
1456
       used when the token is applied */
1438
       used when the token is applied */
1457
  tok -> my_labtab = unit_labtab;
1439
  tok->my_labtab = unit_labtab;
1458
  tok -> my_tagtab = unit_ind_tags;
1440
  tok->my_tagtab = unit_ind_tags;
1459
  tok -> my_toktab = unit_ind_tokens;
1441
  tok->my_toktab = unit_ind_tokens;
1460
  tok -> my_altab = unit_ind_als;
1442
  tok->my_altab = unit_ind_als;
1461
  tok -> my_diagtab = unit_ind_diagtags;	/* OLD DIAGS */
1443
  tok->my_diagtab = unit_ind_diagtags;	/* OLD DIAGS */
1462
  tok -> my_dgtab = unit_ind_dgtags;		/* NEW DIAGS */
1444
  tok->my_dgtab = unit_ind_dgtags;	/* NEW DIAGS */
1463
  if (params.number == 0)
1445
  if (params.number == 0) {
1464
    tok -> re_evaluate = 0;
1446
    tok -> re_evaluate = 0;
1465
  else
1447
  } else {
1466
    tok -> re_evaluate = 1;
1448
    tok -> re_evaluate = 1;
-
 
1449
  }
1467
 
1450
 
1468
  set_place(old_place);
1451
  set_place(old_place);
1469
  return 0;
1452
  return 0;
1470
}
1453
}
1471
 
1454
 
1472
token f_use_tokdef
1455
token
1473
    PROTO_N ( (def) )
-
 
1474
    PROTO_T ( bitstream def )
1456
f_use_tokdef(bitstream def)
1475
{
1457
{
1476
  token tok = (token)xcalloc(1, sizeof(tok_define)) /* space thief ?*/;
1458
  token tok = (token)xcalloc(1, sizeof(tok_define)) /* space thief ?*/;
1477
  sortname result_sort;
1459
  sortname result_sort;
1478
  tokformals_list params;
1460
  tokformals_list params;
1479
  place old_place;
1461
  place old_place;
Line 1481... Line 1463...
1481
  old_place = keep_place();
1463
  old_place = keep_place();
1482
  set_place(def);
1464
  set_place(def);
1483
  IGNORE getcode(1);
1465
  IGNORE getcode(1);
1484
  result_sort = d_sortname();
1466
  result_sort = d_sortname();
1485
  params = d_tokformals_list();
1467
  params = d_tokformals_list();
1486
  tok -> tok_special = 0;
1468
  tok->tok_special = 0;
1487
  tok -> valpresent = 0;
1469
  tok->valpresent = 0;
1488
  tok -> unit_number = crt_tagdef_unit_no;
1470
  tok->unit_number = crt_tagdef_unit_no;
1489
  tok -> defined = 0;
1471
  tok->defined = 0;
1490
  tok -> is_capsule_token = 0;
1472
  tok->is_capsule_token = 0;
1491
  tok -> recursive = 0;
1473
  tok->recursive = 0;
1492
  tok -> tdsort = result_sort;
1474
  tok->tdsort = result_sort;
1493
  tok -> params = params;
1475
  tok->params = params;
1494
  tok -> tdplace = keep_place();
1476
  tok->tdplace = keep_place();
1495
  tok -> defined = 1;
1477
  tok->defined = 1;
1496
  tok->tok_context = crt_context;
1478
  tok->tok_context = crt_context;
1497
 
1479
 
1498
    /* record the tables which are current so that they can be
1480
  /* record the tables which are current so that they can be used when
1499
       used when the token is applied */
1481
     the token is applied */
1500
  tok -> my_labtab = unit_labtab;
1482
  tok->my_labtab = unit_labtab;
1501
  tok -> my_tagtab = unit_ind_tags;
1483
  tok->my_tagtab = unit_ind_tags;
1502
  tok -> my_toktab = unit_ind_tokens;
1484
  tok->my_toktab = unit_ind_tokens;
1503
  tok -> my_altab = unit_ind_als;
1485
  tok->my_altab = unit_ind_als;
1504
  tok -> my_diagtab = unit_ind_diagtags;	/* OLD DIAGS */
1486
  tok->my_diagtab = unit_ind_diagtags;	/* OLD DIAGS */
1505
  tok -> my_dgtab = unit_ind_dgtags;		/* NEW DIAGS */
1487
  tok->my_dgtab = unit_ind_dgtags;	/* NEW DIAGS */
1506
 
1488
 
1507
  if (params.number == 0)
1489
  if (params.number == 0) {
1508
    tok -> re_evaluate = 0;
1490
    tok->re_evaluate = 0;
1509
  else
1491
  } else {
1510
    tok -> re_evaluate = 1;
1492
    tok->re_evaluate = 1;
-
 
1493
  }
1511
 
1494
 
1512
  set_place(old_place);
1495
  set_place(old_place);
1513
  return tok;
1496
  return tok;
1514
}
1497
}
1515
 
1498
 
1516
 
1499
 
1517
void init_tokdef
1500
void
1518
    PROTO_Z ()
1501
init_tokdef(void)
1519
{
1502
{
1520
  return;
1503
  return;
1521
}
1504
}
1522
 
1505
 
1523
tokdef f_dummy_tokdef;
1506
tokdef f_dummy_tokdef;
1524
 
1507
 
1525
token f_token_apply_token
1508
token
1526
    PROTO_N ( (token_value, token_args) )
-
 
1527
    PROTO_T ( token token_value X bitstream token_args )
1509
f_token_apply_token(token token_value, bitstream token_args)
1528
{
1510
{
1529
   tokval v;
1511
   tokval v;
1530
   v = apply_tok(token_value, token_args, TOKEN, (tokval*)0);
1512
   v = apply_tok(token_value, token_args, TOKEN, (tokval *)0);
1531
   return v.tk_token;
1513
   return v.tk_token;
1532
}
1514
}
1533
 
1515
 
1534
token f_make_tok
1516
token
1535
    PROTO_N ( (tokno) )
-
 
1536
    PROTO_T ( tdfint tokno )
1517
f_make_tok(tdfint tokno)
1537
{
1518
{
1538
  return get_tok(natint(tokno));
1519
  return get_tok(natint(tokno));
1539
}
1520
}
1540
 
1521
 
1541
void init_token
1522
void
1542
    PROTO_Z ()
1523
init_token(void)
1543
{
1524
{
1544
  return;
1525
  return;
1545
}
1526
}
1546
 
1527
 
1547
token f_dummy_token;
1528
token f_dummy_token;
1548
 
1529
 
1549
token_defn f_token_definition
1530
token_defn
1550
    PROTO_N ( (result_sort, tok_params) )
-
 
1551
    PROTO_T ( sortname result_sort X tokformals_list tok_params )
1531
f_token_definition(sortname result_sort, tokformals_list tok_params)
1552
{
1532
{
1553
  UNUSED (result_sort);
1533
  UNUSED(result_sort);
1554
  UNUSED (tok_params);
1534
  UNUSED(tok_params);
1555
  failer ("dummy");
1535
  failer("dummy");
1556
  return f_dummy_token_defn;
1536
  return f_dummy_token_defn;
1557
}
1537
}
1558
 
1538
 
1559
void init_token_defn
1539
void
1560
    PROTO_Z ()
1540
init_token_defn(void)
1561
{
1541
{
1562
  return;
1542
  return;
1563
}
1543
}
1564
 
1544
 
1565
token_defn f_dummy_token_defn;
1545
token_defn f_dummy_token_defn;
1566
 
1546
 
1567
tokextern f_make_tokextern
1547
tokextern
1568
    PROTO_N ( (internal, ext) )
-
 
1569
    PROTO_T ( tdfint internal X external ext )
1548
f_make_tokextern(tdfint internal, external ext)
1570
{
1549
{
1571
  tok_define * t = &capsule_toktab[natint(internal)];
1550
  tok_define *t = &capsule_toktab[natint(internal)];
1572
  char * s = external_to_string(ext);
1551
  char *s = external_to_string(ext);
1573
  t -> tok_name = s;
1552
  t->tok_name = s;
1574
 
1553
 
1575
  if (machine_toks(s))  /* determines special tokens specific
1554
  /* determines special tokens specific to each machine */
1576
			   to each machine */
1555
  if (machine_toks(s)) {
1577
    t -> tok_special = 1;
1556
    t->tok_special = 1;
1578
 
1557
  }
1579
 
1558
 
1580
  if (replace_arith_type)  {
1559
  if (replace_arith_type) {
1581
    if (!strcmp(s, "~arith_type"))
1560
    if (!strcmp(s, "~arith_type")) {
1582
      t -> tok_special = 1;
1561
      t->tok_special = 1;
-
 
1562
    }
1583
    if (!strcmp(s, "~promote"))
1563
    if (!strcmp(s, "~promote")) {
1584
      t -> tok_special = 1;
1564
      t->tok_special = 1;
-
 
1565
    }
1585
    if (!strcmp(s, "~sign_promote"))
1566
    if (!strcmp(s, "~sign_promote")) {
1586
      t -> tok_special = 1;
1567
      t->tok_special = 1;
-
 
1568
    }
1587
    if (!strcmp(s, "~convert"))
1569
    if (!strcmp(s, "~convert")) {
1588
      t -> tok_special = 1;
1570
      t->tok_special = 1;
-
 
1571
    }
1589
  };
1572
  }
1590
  if (do_alloca && !strcmp(s, "~alloca"))
1573
  if (do_alloca && !strcmp(s, "~alloca")) {
1591
    t -> tok_special = 1;
1574
    t->tok_special = 1;
-
 
1575
  }
1592
  return 0;
1576
  return 0;
1593
}
1577
}
1594
 
1578
 
1595
alextern f_make_alextern
1579
alextern
1596
    PROTO_N ( (internal, ext) )
-
 
1597
    PROTO_T ( tdfint internal X external ext )
1580
f_make_alextern(tdfint internal, external ext)
1598
{
1581
{
1599
  UNUSED(internal); UNUSED(ext);
1582
  UNUSED(internal);
-
 
1583
  UNUSED(ext);
1600
  return 0;
1584
  return 0;
1601
}
1585
}
1602
 
1586
 
1603
 
1587
 
1604
tokformals f_make_tokformals
1588
tokformals
1605
    PROTO_N ( (sn, tk) )
-
 
1606
    PROTO_T ( sortname sn X tdfint tk )
1589
f_make_tokformals(sortname sn, tdfint tk)
1607
{
1590
{
1608
  tokformals res;
1591
  tokformals res;
1609
  res.sn = sn;
1592
  res.sn = sn;
1610
  res.tk = natint(tk);
1593
  res.tk = natint(tk);
1611
  return res;
1594
  return res;
1612
}
1595
}
1613
 
1596
 
-
 
1597
void
1614
void init_tokformals
1598
init_tokformals(void)
1615
    PROTO_Z ()
-
 
1616
{
1599
{
1617
  return;
1600
  return;
1618
}
1601
}
1619
 
1602
 
1620
toklink f_make_toklink
1603
toklink
1621
    PROTO_N ( (internal, ext) )
-
 
1622
    PROTO_T ( tdfint internal X tdfint ext )
1604
f_make_toklink(tdfint internal, tdfint ext)
1623
{
1605
{
1624
  unit_ind_tokens[natint(internal)] =
1606
  unit_ind_tokens[natint(internal)] = &capsule_toktab[natint(ext)];
1625
      &capsule_toktab[natint(ext)];
-
 
1626
  return 0;
1607
  return 0;
1627
}
1608
}
1628
 
1609
 
1629
link f_make_link
1610
link
1630
    PROTO_N ( (internal, ext) )
-
 
1631
    PROTO_T ( tdfint internal X tdfint ext )
1611
f_make_link(tdfint internal, tdfint ext)
1632
{
1612
{
1633
  switch (crt_links_type)
1613
  switch (crt_links_type)
1634
   {
1614
   {
1635
     case TOK_TYPE:
1615
     case TOK_TYPE:
1636
       IGNORE f_make_toklink(internal, ext);
1616
       IGNORE f_make_toklink(internal, ext);
Line 1648... Line 1628...
1648
       IGNORE f_make_dglink(internal, ext);
1628
       IGNORE f_make_dglink(internal, ext);
1649
       return 0;
1629
       return 0;
1650
     default:
1630
     default:
1651
       failer(VARIABLE_TYPE);
1631
       failer(VARIABLE_TYPE);
1652
       return 0;
1632
       return 0;
1653
   };
1633
   }
1654
}
1634
}
1655
 
1635
 
1656
unique f_make_unique
1636
unique
1657
    PROTO_N ( (text) )
-
 
1658
    PROTO_T ( tdfstring_list text )
1637
f_make_unique(tdfstring_list text)
1659
{
1638
{
1660
  return text;
1639
  return text;
1661
}
1640
}
1662
 
1641
 
1663
void init_unique
1642
void
1664
    PROTO_Z ()
1643
init_unique(void)
1665
{
1644
{
1666
   return;
1645
   return;
1667
}
1646
}
1668
 
1647
 
1669
 
1648
 
1670
variety f_var_apply_token
1649
variety
1671
    PROTO_N ( (token_value, token_args) )
-
 
1672
    PROTO_T ( token token_value X bitstream token_args )
1650
f_var_apply_token(token token_value, bitstream token_args)
1673
{
1651
{
1674
   tokval v;
1652
   tokval v;
1675
   v = apply_tok(token_value, token_args, VARIETY, (tokval*)0);
1653
   v = apply_tok(token_value, token_args, VARIETY,(tokval *)0);
1676
   return v.tk_variety;
1654
   return v.tk_variety;
1677
}
1655
}
1678
 
1656
 
1679
variety f_var_cond
1657
variety
1680
    PROTO_N ( (control, e1, e2) )
-
 
1681
    PROTO_T ( exp control X bitstream e1 X bitstream e2 )
1658
f_var_cond(exp control, bitstream e1, bitstream e2)
1682
{
1659
{
1683
  bitstream bs;
1660
  bitstream bs;
1684
  variety res;
1661
  variety res;
1685
  int n;
1662
  int n;
1686
  bs = keep_place();
1663
  bs = keep_place();
1687
  if (name(control) != val_tag)
1664
  if (name(control) != val_tag) {
1688
    failer(CONTROL_EXP);
1665
    failer(CONTROL_EXP);
-
 
1666
  }
1689
  n = no(control);
1667
  n = no(control);
1690
  retcell(control);
1668
  retcell(control);
1691
  if (n==0)
1669
  if (n==0) {
-
 
1670
    set_place(e2);
-
 
1671
    res = d_variety();
1692
   {
1672
  } else {
1693
     set_place(e2);
1673
    set_place(e1);
1694
     res = d_variety();
1674
    res = d_variety();
1695
   }
1675
  }
-
 
1676
  
-
 
1677
  set_place(bs); return res;
-
 
1678
}
-
 
1679
 
-
 
1680
 
-
 
1681
void
-
 
1682
start_make_tokdec_unit(int no_of_tokens, int no_of_tags, int no_of_als,
-
 
1683
		       int no_of_diagtags, int no_of_dgtags)
-
 
1684
{
-
 
1685
  int i;
-
 
1686
 
-
 
1687
  unit_no_of_tokens = no_of_tokens;
-
 
1688
  unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
-
 
1689
					   sizeof(tok_define *));
-
 
1690
  for (i = 0; i < unit_no_of_tokens; ++i) {
-
 
1691
    unit_ind_tokens[i] = (tok_define *)0;
1696
  else
1692
  }
-
 
1693
 
-
 
1694
  unit_no_of_tags = no_of_tags;
-
 
1695
  unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
-
 
1696
  for (i = 0; i < unit_no_of_tags; ++i) {
-
 
1697
    unit_ind_tags[i] = (dec *)0;
1697
   {
1698
  }
-
 
1699
 
-
 
1700
  unit_no_of_als = no_of_als;
-
 
1701
  unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
-
 
1702
  for (i = 0; i < unit_no_of_als; ++i) {
1698
     set_place(e1);
1703
    unit_ind_als[i] = (aldef *)0;
-
 
1704
  }
-
 
1705
 
-
 
1706
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
-
 
1707
  unit_ind_diagtags = (diag_tagdef **)xcalloc(unit_no_of_diagtags,
1699
     res = d_variety();
1708
					      sizeof(diag_tagdef *));
-
 
1709
  for (i = 0; i < unit_no_of_diagtags; ++i) {
-
 
1710
    unit_ind_diagtags[i] = (diag_tagdef *)0;
1700
   };
1711
  }
-
 
1712
 
-
 
1713
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
-
 
1714
  unit_ind_dgtags = (dgtag_struct **)xcalloc(unit_no_of_dgtags,
1701
 set_place(bs);
1715
					     sizeof(dgtag_struct *));
-
 
1716
  for (i = 0; i < unit_no_of_dgtags; ++i) {
-
 
1717
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
1718
  }
-
 
1719
 
1702
 return res;
1720
  return;
1703
}
1721
}
1704
 
1722
 
-
 
1723
tokdec_unit
-
 
1724
f_make_tokdec_unit(void)
1705
 
1725
{
-
 
1726
  int i;
-
 
1727
  int j = 0;
-
 
1728
  for (i = 0; i < unit_no_of_tokens; ++i) {
-
 
1729
    if (unit_ind_tokens[i] == (tok_define *)0) {
-
 
1730
      unit_ind_tokens[i] = &unit_toktab[j++];
-
 
1731
    }
-
 
1732
  }
1706
void start_make_tokdec_unit
1733
  start_bytestream();
-
 
1734
  IGNORE d_tokdec_list();
-
 
1735
  end_bytestream();
-
 
1736
  return 0;
-
 
1737
}
-
 
1738
 
-
 
1739
void
1707
    PROTO_N ( (no_of_tokens, no_of_tags, no_of_als, no_of_diagtags, no_of_dgtags) )
1740
start_make_tokdef_unit(int no_of_tokens, int no_of_tags, int no_of_als,
1708
    PROTO_T ( int no_of_tokens X int no_of_tags X int no_of_als X int no_of_diagtags X int no_of_dgtags )
1741
		       int no_of_diagtags, int no_of_dgtags)
1709
{
1742
{
1710
  int i;
1743
  int i;
1711
 
1744
 
1712
  unit_no_of_tokens = no_of_tokens;
1745
  unit_no_of_tokens = no_of_tokens;
1713
  unit_ind_tokens = (tok_define * *)xcalloc(unit_no_of_tokens,
1746
  unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
1714
                    sizeof(tok_define *));
1747
					   sizeof(tok_define *));
1715
  for (i = 0; i < unit_no_of_tokens; ++i)
1748
  for (i = 0; i < unit_no_of_tokens; ++i) {
1716
    unit_ind_tokens[i] = (tok_define*)0;
1749
    unit_ind_tokens[i] = (tok_define *)0;
-
 
1750
  }
1717
 
1751
 
1718
  unit_no_of_tags = no_of_tags;
1752
  unit_no_of_tags = no_of_tags;
1719
  unit_ind_tags = (dec * *)xcalloc(unit_no_of_tags,
1753
  unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
1720
                    sizeof(dec *));
-
 
1721
  for (i = 0; i < unit_no_of_tags; ++i)
1754
  for (i = 0; i < unit_no_of_tags; ++i) {
1722
    unit_ind_tags[i] = (dec*)0;
1755
    unit_ind_tags[i] = (dec *)0;
-
 
1756
  }
1723
 
1757
 
1724
  unit_no_of_als = no_of_als;
1758
  unit_no_of_als = no_of_als;
1725
  unit_ind_als = (aldef * *)xcalloc(unit_no_of_als,
1759
  unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
1726
                    sizeof(aldef *));
-
 
1727
  for (i = 0; i < unit_no_of_als; ++i)
1760
  for (i = 0; i < unit_no_of_als; ++i) {
1728
    unit_ind_als[i] = (aldef*)0;
1761
    unit_ind_als[i] = (aldef *)0;
-
 
1762
  }
1729
 
1763
 
1730
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
1764
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
1731
  unit_ind_diagtags = (diag_tagdef * *)xcalloc(unit_no_of_diagtags,
1765
  unit_ind_diagtags = (diag_tagdef **)xcalloc(unit_no_of_diagtags,
1732
                    sizeof(diag_tagdef *));
1766
					      sizeof(diag_tagdef *));
1733
  for (i = 0; i < unit_no_of_diagtags; ++i)
1767
  for (i = 0; i < unit_no_of_diagtags; ++i) {
1734
    unit_ind_diagtags[i] = (diag_tagdef *)0;
1768
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
1769
  }
1735
 
1770
 
1736
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
1771
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
1737
  unit_ind_dgtags = (dgtag_struct * *)xcalloc(unit_no_of_dgtags,
1772
  unit_ind_dgtags = (dgtag_struct **)xcalloc(unit_no_of_dgtags,
1738
                    sizeof(dgtag_struct *));
1773
					     sizeof(dgtag_struct *));
1739
  for (i = 0; i < unit_no_of_dgtags; ++i)
1774
  for (i = 0; i < unit_no_of_dgtags; ++i) {
1740
    unit_ind_dgtags[i] = (dgtag_struct *)0;
1775
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
1776
  }
1741
 
1777
 
1742
  return;
1778
  return;
1743
}
1779
}
1744
 
1780
 
1745
tokdec_unit f_make_tokdec_unit
1781
tokdef_unit
1746
    PROTO_Z ()
1782
f_make_tokdef_unit(void)
1747
{
1783
{
1748
  int i;
1784
  int i;
1749
  int j = 0;
1785
  int j = 0;
-
 
1786
  int no_of_labels;
1750
  for (i = 0; i < unit_no_of_tokens; ++i)
1787
  for (i = 0; i < unit_no_of_tokens; ++i) {
1751
   {
-
 
1752
    if (unit_ind_tokens[i] == (tok_define*)0)
1788
    if (unit_ind_tokens[i] == (tok_define *)0) {
1753
      unit_ind_tokens[i] = &unit_toktab[j++];
1789
      unit_ind_tokens[i] = &unit_toktab[j++];
1754
   };
1790
    }
-
 
1791
  }
-
 
1792
  j = 0;
-
 
1793
  for (i = 0; i < unit_no_of_tags; ++i) {
-
 
1794
    if (unit_ind_tags[i] == (dec *)0) {
-
 
1795
      unit_ind_tags[i] = &unit_tagtab[j++];
-
 
1796
    }
-
 
1797
  }
-
 
1798
  j = 0;
-
 
1799
  for (i = 0; i < unit_no_of_als; ++i) {
-
 
1800
    if (unit_ind_als[i] == (aldef *)0) {
-
 
1801
      unit_ind_als[i] = &unit_altab[j++];
-
 
1802
    }
-
 
1803
  }
-
 
1804
  j = 0;
-
 
1805
  for (i = 0; i < unit_no_of_dgtags; ++i) {	/* NEW DIAGS */
-
 
1806
    if (unit_ind_dgtags[i] == (dgtag_struct *)0) {
-
 
1807
      unit_ind_dgtags[i] = &unit_dgtagtab[j++];
-
 
1808
    }
-
 
1809
  }
1755
  start_bytestream();
1810
  start_bytestream();
-
 
1811
  no_of_labels = small_dtdfint();
-
 
1812
  unit_no_of_labels = no_of_labels;
-
 
1813
  unit_labtab = (exp *)xcalloc(unit_no_of_labels, sizeof(exp));
1756
  IGNORE d_tokdec_list();
1814
  IGNORE d_tokdef_list();
1757
  end_bytestream();
1815
  end_bytestream();
-
 
1816
 
-
 
1817
  /* tables must be kept for use during token application */
-
 
1818
 
1758
  return 0;
1819
  return 0;
1759
}
1820
}
1760
 
1821
 
1761
void start_make_tokdef_unit
1822
void
1762
    PROTO_N ( (no_of_tokens, no_of_tags, no_of_als, no_of_diagtags, no_of_dgtags) )
1823
start_make_tagdec_unit(int no_of_tokens, int no_of_tags, int no_of_als,
1763
    PROTO_T ( int no_of_tokens X int no_of_tags X int no_of_als X int no_of_diagtags X int no_of_dgtags )
1824
		       int no_of_diagtags, int no_of_dgtags)
1764
{
1825
{
1765
  int i;
1826
  int i;
1766
 
1827
 
1767
  unit_no_of_tokens = no_of_tokens;
1828
  unit_no_of_tokens = no_of_tokens;
1768
  unit_ind_tokens = (tok_define * *)xcalloc(unit_no_of_tokens,
1829
  unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
1769
                    sizeof(tok_define *));
1830
					   sizeof(tok_define *));
1770
  for (i = 0; i < unit_no_of_tokens; ++i)
1831
  for (i = 0; i < unit_no_of_tokens; ++i) {
1771
    unit_ind_tokens[i] = (tok_define*)0;
1832
    unit_ind_tokens[i] = (tok_define *)0;
-
 
1833
  }
1772
 
1834
 
1773
  unit_no_of_tags = no_of_tags;
1835
  unit_no_of_tags = no_of_tags;
1774
  unit_ind_tags = (dec * *)xcalloc(unit_no_of_tags,
1836
  unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
1775
                    sizeof(dec *));
-
 
1776
  for (i = 0; i < unit_no_of_tags; ++i)
1837
  for (i = 0; i < unit_no_of_tags; ++i) {
1777
    unit_ind_tags[i] = (dec*)0;
1838
    unit_ind_tags[i] = (dec *)0;
-
 
1839
  }
1778
 
1840
 
1779
  unit_no_of_als = no_of_als;
1841
  unit_no_of_als = no_of_als;
1780
  unit_ind_als = (aldef * *)xcalloc(unit_no_of_als,
1842
  unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
1781
                    sizeof(aldef *));
-
 
1782
  for (i = 0; i < unit_no_of_als; ++i)
1843
  for (i = 0; i < unit_no_of_als; ++i) {
1783
    unit_ind_als[i] = (aldef*)0;
1844
    unit_ind_als[i] = (aldef *)0;
-
 
1845
  }
1784
 
1846
 
1785
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
1847
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
1786
  unit_ind_diagtags = (diag_tagdef * *)xcalloc(unit_no_of_diagtags,
1848
  unit_ind_diagtags = (diag_tagdef **)xcalloc(unit_no_of_diagtags,
1787
                    sizeof(diag_tagdef *));
1849
					      sizeof(diag_tagdef *));
1788
  for (i = 0; i < unit_no_of_diagtags; ++i)
1850
  for (i = 0; i < unit_no_of_diagtags; ++i) {
1789
    unit_ind_diagtags[i] = (diag_tagdef *)0;
1851
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
1852
  }
1790
 
1853
 
1791
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
1854
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
1792
  unit_ind_dgtags = (dgtag_struct * *)xcalloc(unit_no_of_dgtags,
1855
  unit_ind_dgtags = (dgtag_struct **)xcalloc(unit_no_of_dgtags,
1793
                    sizeof(dgtag_struct *));
1856
					     sizeof(dgtag_struct *));
1794
  for (i = 0; i < unit_no_of_dgtags; ++i)
1857
  for (i = 0; i < unit_no_of_dgtags; ++i) {
1795
    unit_ind_dgtags[i] = (dgtag_struct *)0;
1858
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
1859
  }
1796
 
1860
 
1797
  return;
1861
  return;
1798
}
1862
}
1799
 
1863
 
1800
tokdef_unit f_make_tokdef_unit
-
 
1801
    PROTO_Z ()
-
 
1802
{
-
 
1803
  int i;
-
 
1804
  int j = 0;
-
 
1805
  int no_of_labels;
-
 
1806
  for (i = 0; i < unit_no_of_tokens; ++i)
-
 
1807
   {
-
 
1808
    if (unit_ind_tokens[i] == (tok_define*)0)
-
 
1809
      unit_ind_tokens[i] = &unit_toktab[j++];
-
 
1810
   };
-
 
1811
  j = 0;
-
 
1812
  for (i = 0; i < unit_no_of_tags; ++i)
-
 
1813
   {
-
 
1814
    if (unit_ind_tags[i] == (dec*)0)
-
 
1815
      unit_ind_tags[i] = &unit_tagtab[j++];
-
 
1816
   };
-
 
1817
  j = 0;
-
 
1818
  for (i = 0; i < unit_no_of_als; ++i)
-
 
1819
   {
-
 
1820
    if (unit_ind_als[i] == (aldef*)0)
-
 
1821
      unit_ind_als[i] = &unit_altab[j++];
-
 
1822
   };
-
 
1823
  j = 0;
-
 
1824
  for (i = 0; i < unit_no_of_dgtags; ++i)	/* NEW DIAGS */
-
 
1825
   {
-
 
1826
    if (unit_ind_dgtags[i] == (dgtag_struct *)0)
-
 
1827
      unit_ind_dgtags[i] = &unit_dgtagtab[j++];
-
 
1828
   };
-
 
1829
  start_bytestream();
-
 
1830
  no_of_labels = small_dtdfint();
-
 
1831
  unit_no_of_labels = no_of_labels;
-
 
1832
  unit_labtab = (exp*)xcalloc(unit_no_of_labels, sizeof(exp));
-
 
1833
  IGNORE d_tokdef_list();
-
 
1834
  end_bytestream();
-
 
1835
 
-
 
1836
  /* tables must be kept for use during token application */
-
 
1837
 
-
 
1838
  return 0;
1864
tagdec_unit
1839
}
-
 
1840
 
-
 
1841
void start_make_tagdec_unit
1865
f_make_tagdec_unit(void)
1842
    PROTO_N ( (no_of_tokens, no_of_tags, no_of_als, no_of_diagtags, no_of_dgtags) )
-
 
1843
    PROTO_T ( int no_of_tokens X int no_of_tags X int no_of_als X int no_of_diagtags X int no_of_dgtags )
-
 
1844
{
-
 
1845
  int i;
-
 
1846
 
-
 
1847
  unit_no_of_tokens = no_of_tokens;
-
 
1848
  unit_ind_tokens = (tok_define * *)xcalloc(unit_no_of_tokens,
-
 
1849
                    sizeof(tok_define *));
-
 
1850
  for (i = 0; i < unit_no_of_tokens; ++i)
-
 
1851
    unit_ind_tokens[i] = (tok_define*)0;
-
 
1852
 
-
 
1853
  unit_no_of_tags = no_of_tags;
-
 
1854
  unit_ind_tags = (dec * *)xcalloc(unit_no_of_tags,
-
 
1855
                    sizeof(dec *));
-
 
1856
  for (i = 0; i < unit_no_of_tags; ++i)
-
 
1857
    unit_ind_tags[i] = (dec*)0;
-
 
1858
 
-
 
1859
  unit_no_of_als = no_of_als;
-
 
1860
  unit_ind_als = (aldef * *)xcalloc(unit_no_of_als,
-
 
1861
                    sizeof(aldef *));
-
 
1862
  for (i = 0; i < unit_no_of_als; ++i)
-
 
1863
    unit_ind_als[i] = (aldef*)0;
-
 
1864
 
-
 
1865
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
-
 
1866
  unit_ind_diagtags = (diag_tagdef * *)xcalloc(unit_no_of_diagtags,
-
 
1867
                    sizeof(diag_tagdef *));
-
 
1868
  for (i = 0; i < unit_no_of_diagtags; ++i)
-
 
1869
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
1870
 
-
 
1871
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
-
 
1872
  unit_ind_dgtags = (dgtag_struct * *)xcalloc(unit_no_of_dgtags,
-
 
1873
                    sizeof(dgtag_struct *));
-
 
1874
  for (i = 0; i < unit_no_of_dgtags; ++i)
-
 
1875
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
1876
 
-
 
1877
  return;
-
 
1878
}
-
 
1879
 
-
 
1880
tagdec_unit f_make_tagdec_unit
-
 
1881
    PROTO_Z ()
-
 
1882
{
1866
{
1883
  int i;
1867
  int i;
1884
  int j = 0;
1868
  int j = 0;
1885
  int no_of_labels;
1869
  int no_of_labels;
1886
  for (i = 0; i < unit_no_of_tokens; ++i)
1870
  for (i = 0; i < unit_no_of_tokens; ++i) {
1887
   {
-
 
1888
    if (unit_ind_tokens[i] == (tok_define*)0)
1871
    if (unit_ind_tokens[i] == (tok_define *)0) {
1889
      unit_ind_tokens[i] = &unit_toktab[j++];
1872
      unit_ind_tokens[i] = &unit_toktab[j++];
1890
   };
1873
    }
-
 
1874
  }
1891
  j = 0;
1875
  j = 0;
1892
  for (i = 0; i < unit_no_of_tags; ++i)
1876
  for (i = 0; i < unit_no_of_tags; ++i) {
1893
   {
-
 
1894
    if (unit_ind_tags[i] == (dec*)0)
1877
    if (unit_ind_tags[i] == (dec *)0) {
1895
      unit_ind_tags[i] = &unit_tagtab[j++];
1878
      unit_ind_tags[i] = &unit_tagtab[j++];
1896
   };
1879
    }
-
 
1880
  }
1897
  j = 0;
1881
  j = 0;
1898
  for (i = 0; i < unit_no_of_als; ++i)
1882
  for (i = 0; i < unit_no_of_als; ++i) {
1899
   {
-
 
1900
    if (unit_ind_als[i] == (aldef*)0)
1883
    if (unit_ind_als[i] == (aldef *)0) {
1901
      unit_ind_als[i] = &unit_altab[j++];
1884
      unit_ind_als[i] = &unit_altab[j++];
1902
   };
1885
    }
-
 
1886
  }
1903
  j = 0;
1887
  j = 0;
1904
  for (i = 0; i < unit_no_of_dgtags; ++i)	/* NEW DIAGS */
1888
  for (i = 0; i < unit_no_of_dgtags; ++i) {	/* NEW DIAGS */
1905
   {
-
 
1906
    if (unit_ind_dgtags[i] == (dgtag_struct *)0)
1889
    if (unit_ind_dgtags[i] == (dgtag_struct *)0) {
1907
      unit_ind_dgtags[i] = &unit_dgtagtab[j++];
1890
      unit_ind_dgtags[i] = &unit_dgtagtab[j++];
1908
   };
1891
    }
-
 
1892
  }
1909
  start_bytestream();
1893
  start_bytestream();
1910
  no_of_labels = small_dtdfint();
1894
  no_of_labels = small_dtdfint();
1911
  unit_no_of_labels = no_of_labels;
1895
  unit_no_of_labels = no_of_labels;
1912
  unit_labtab = (exp*)xcalloc(unit_no_of_labels, sizeof(exp));
1896
  unit_labtab = (exp *)xcalloc(unit_no_of_labels, sizeof(exp));
1913
  IGNORE d_tagdec_list();
1897
  IGNORE d_tagdec_list();
1914
  end_bytestream();
1898
  end_bytestream();
1915
 
1899
 
1916
  xfree((void*)unit_ind_tokens);
1900
  xfree((void *)unit_ind_tokens);
1917
  xfree((void*)unit_ind_tags);
1901
  xfree((void *)unit_ind_tags);
1918
  xfree((void*)unit_ind_als);
1902
  xfree((void *)unit_ind_als);
1919
  xfree((void*)unit_labtab);
1903
  xfree((void *)unit_labtab);
1920
 
1904
 
1921
  xfree((void*)unit_toktab);
1905
  xfree((void *)unit_toktab);
1922
 
1906
 
1923
  return 0;
1907
  return 0;
1924
}
1908
}
-
 
1909
 
-
 
1910
void
-
 
1911
start_make_versions_unit(int no_of_tokens, int no_of_tags, int no_of_als,
-
 
1912
			 int no_of_diagtags, int no_of_dgtags)
-
 
1913
{
-
 
1914
  int i;
-
 
1915
 
-
 
1916
  unit_no_of_tokens = no_of_tokens;
-
 
1917
  unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
-
 
1918
					   sizeof(tok_define *));
-
 
1919
  for (i = 0; i < unit_no_of_tokens; ++i) {
-
 
1920
    unit_ind_tokens[i] = (tok_define *)0;
-
 
1921
  }
-
 
1922
 
-
 
1923
  unit_no_of_tags = no_of_tags;
-
 
1924
  unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
-
 
1925
  for (i = 0; i < unit_no_of_tags; ++i) {
-
 
1926
    unit_ind_tags[i] = (dec *)0;
-
 
1927
  }
-
 
1928
 
-
 
1929
  unit_no_of_als = no_of_als;
-
 
1930
  unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
-
 
1931
  for (i = 0; i < unit_no_of_als; ++i) {
-
 
1932
    unit_ind_als[i] = (aldef *)0;
-
 
1933
  }
-
 
1934
 
-
 
1935
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
-
 
1936
  unit_ind_diagtags = (diag_tagdef **)xcalloc(unit_no_of_diagtags,
-
 
1937
					      sizeof(diag_tagdef *));
-
 
1938
  for (i = 0; i < unit_no_of_diagtags; ++i) {
-
 
1939
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
1940
  }
-
 
1941
 
-
 
1942
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
-
 
1943
  unit_ind_dgtags = (dgtag_struct **)xcalloc(unit_no_of_dgtags,
-
 
1944
					     sizeof(dgtag_struct *));
-
 
1945
  for (i = 0; i < unit_no_of_dgtags; ++i) {
-
 
1946
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
1947
  }
1925
 
1948
 
-
 
1949
  return;
-
 
1950
}
-
 
1951
 
-
 
1952
version_props
1926
void start_make_versions_unit
1953
f_make_versions_unit(void)
-
 
1954
{
-
 
1955
  int i;
-
 
1956
  int j = 0;
-
 
1957
  for (i = 0; i < unit_no_of_tokens; ++i) {
-
 
1958
    if (unit_ind_tokens[i] == (tok_define *)0) {
-
 
1959
      unit_ind_tokens[i] = &unit_toktab[j++];
-
 
1960
    }
-
 
1961
  }
-
 
1962
  j = 0;
-
 
1963
  for (i = 0; i < unit_no_of_tags; ++i) {
-
 
1964
    if (unit_ind_tags[i] == (dec *)0) {
-
 
1965
      unit_ind_tags[i] = &unit_tagtab[j++];
-
 
1966
    }
-
 
1967
  }
-
 
1968
  j = 0;
-
 
1969
  for (i = 0; i < unit_no_of_als; ++i) {
-
 
1970
    if (unit_ind_als[i] == (aldef *)0) {
-
 
1971
      unit_ind_als[i] = &unit_altab[j++];
-
 
1972
    }
-
 
1973
  }
-
 
1974
  start_bytestream();
-
 
1975
  IGNORE d_version_list();
-
 
1976
  end_bytestream();
-
 
1977
 
-
 
1978
  xfree((void *)unit_ind_tokens);
-
 
1979
  xfree((void *)unit_ind_tags);
-
 
1980
  xfree((void *)unit_ind_als);
-
 
1981
 
-
 
1982
  xfree((void *)unit_toktab);
-
 
1983
  xfree((void *)unit_tagtab);
-
 
1984
 
-
 
1985
  return 0;
-
 
1986
}
-
 
1987
 
-
 
1988
void
1927
    PROTO_N ( (no_of_tokens, no_of_tags, no_of_als, no_of_diagtags, no_of_dgtags) )
1989
start_make_tagdef_unit(int no_of_tokens, int no_of_tags, int no_of_als,
1928
    PROTO_T ( int no_of_tokens X int no_of_tags X int no_of_als X int no_of_diagtags X int no_of_dgtags )
1990
		       int no_of_diagtags, int no_of_dgtags)
1929
{
1991
{
1930
  int i;
1992
  int i;
-
 
1993
 
-
 
1994
  if (separate_units) {
-
 
1995
    ++crt_tagdef_unit_no;
-
 
1996
    set_large_alloc();
-
 
1997
  }
1931
 
1998
 
1932
  unit_no_of_tokens = no_of_tokens;
1999
  unit_no_of_tokens = no_of_tokens;
1933
  unit_ind_tokens = (tok_define * *)xcalloc(unit_no_of_tokens,
2000
  unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
1934
                    sizeof(tok_define *));
2001
					   sizeof(tok_define *));
1935
  for (i = 0; i < unit_no_of_tokens; ++i)
2002
  for (i = 0; i < unit_no_of_tokens; ++i) {
1936
    unit_ind_tokens[i] = (tok_define*)0;
2003
    unit_ind_tokens[i] = (tok_define *)0;
-
 
2004
  }
1937
 
2005
 
1938
  unit_no_of_tags = no_of_tags;
2006
  unit_no_of_tags = no_of_tags;
1939
  unit_ind_tags = (dec * *)xcalloc(unit_no_of_tags,
2007
  unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
1940
                    sizeof(dec *));
-
 
1941
  for (i = 0; i < unit_no_of_tags; ++i)
2008
  for (i = 0; i < unit_no_of_tags; ++i) {
1942
    unit_ind_tags[i] = (dec*)0;
2009
    unit_ind_tags[i] = (dec *)0;
-
 
2010
  }
1943
 
2011
 
1944
  unit_no_of_als = no_of_als;
2012
  unit_no_of_als = no_of_als;
1945
  unit_ind_als = (aldef * *)xcalloc(unit_no_of_als,
2013
  unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
1946
                    sizeof(aldef *));
-
 
1947
  for (i = 0; i < unit_no_of_als; ++i)
2014
  for (i = 0; i < unit_no_of_als; ++i) {
1948
    unit_ind_als[i] = (aldef*)0;
2015
    unit_ind_als[i] = (aldef *)0;
-
 
2016
  }
1949
 
2017
 
1950
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
2018
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
1951
  unit_ind_diagtags = (diag_tagdef * *)xcalloc(unit_no_of_diagtags,
2019
  unit_ind_diagtags = (diag_tagdef **)xcalloc(unit_no_of_diagtags,
1952
                    sizeof(diag_tagdef *));
2020
					      sizeof(diag_tagdef *));
1953
  for (i = 0; i < unit_no_of_diagtags; ++i)
2021
  for (i = 0; i < unit_no_of_diagtags; ++i) {
1954
    unit_ind_diagtags[i] = (diag_tagdef *)0;
2022
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
2023
  }
1955
 
2024
 
1956
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
2025
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
1957
  unit_ind_dgtags = (dgtag_struct * *)xcalloc(unit_no_of_dgtags,
2026
  unit_ind_dgtags = (dgtag_struct **)xcalloc(unit_no_of_dgtags,
1958
                    sizeof(dgtag_struct *));
2027
					     sizeof(dgtag_struct *));
1959
  for (i = 0; i < unit_no_of_dgtags; ++i)
2028
  for (i = 0; i < unit_no_of_dgtags; ++i) {
1960
    unit_ind_dgtags[i] = (dgtag_struct *)0;
2029
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
2030
  }
1961
 
2031
 
1962
  return;
2032
  return;
1963
}
2033
}
1964
 
-
 
1965
version_props f_make_versions_unit
-
 
1966
    PROTO_Z ()
-
 
1967
{
-
 
1968
  int i;
-
 
1969
  int j = 0;
-
 
1970
  for (i = 0; i < unit_no_of_tokens; ++i)
-
 
1971
   {
-
 
1972
    if (unit_ind_tokens[i] == (tok_define*)0)
-
 
1973
      unit_ind_tokens[i] = &unit_toktab[j++];
-
 
1974
   };
-
 
1975
  j = 0;
-
 
1976
  for (i = 0; i < unit_no_of_tags; ++i)
-
 
1977
   {
-
 
1978
    if (unit_ind_tags[i] == (dec*)0)
-
 
1979
      unit_ind_tags[i] = &unit_tagtab[j++];
-
 
1980
   };
-
 
1981
  j = 0;
-
 
1982
  for (i = 0; i < unit_no_of_als; ++i)
-
 
1983
   {
-
 
1984
    if (unit_ind_als[i] == (aldef*)0)
-
 
1985
      unit_ind_als[i] = &unit_altab[j++];
-
 
1986
   };
-
 
1987
  start_bytestream();
-
 
1988
  IGNORE d_version_list();
-
 
1989
  end_bytestream();
-
 
1990
 
-
 
1991
  xfree((void*)unit_ind_tokens);
-
 
1992
  xfree((void*)unit_ind_tags);
-
 
1993
  xfree((void*)unit_ind_als);
-
 
1994
 
-
 
1995
  xfree((void*)unit_toktab);
-
 
1996
  xfree((void*)unit_tagtab);
-
 
1997
 
-
 
1998
  return 0;
-
 
1999
}
-
 
2000
 
-
 
2001
void start_make_tagdef_unit
-
 
2002
    PROTO_N ( (no_of_tokens, no_of_tags, no_of_als, no_of_diagtags, no_of_dgtags) )
-
 
2003
    PROTO_T ( int no_of_tokens X int no_of_tags X int no_of_als X int no_of_diagtags X int no_of_dgtags )
-
 
2004
{
-
 
2005
  int i;
-
 
2006
 
-
 
2007
  if (separate_units)
-
 
2008
   {
-
 
2009
    ++crt_tagdef_unit_no;
-
 
2010
    set_large_alloc();
-
 
2011
   };
-
 
2012
 
-
 
2013
  unit_no_of_tokens = no_of_tokens;
-
 
2014
  unit_ind_tokens = (tok_define * *)xcalloc(unit_no_of_tokens,
-
 
2015
                    sizeof(tok_define *));
-
 
2016
  for (i = 0; i < unit_no_of_tokens; ++i)
-
 
2017
    unit_ind_tokens[i] = (tok_define*)0;
-
 
2018
 
-
 
2019
  unit_no_of_tags = no_of_tags;
-
 
2020
  unit_ind_tags = (dec * *)xcalloc(unit_no_of_tags,
-
 
2021
                    sizeof(dec *));
-
 
2022
  for (i = 0; i < unit_no_of_tags; ++i)
-
 
2023
    unit_ind_tags[i] = (dec*)0;
-
 
2024
 
-
 
2025
  unit_no_of_als = no_of_als;
-
 
2026
  unit_ind_als = (aldef * *)xcalloc(unit_no_of_als,
-
 
2027
                    sizeof(aldef *));
-
 
2028
  for (i = 0; i < unit_no_of_als; ++i)
-
 
2029
    unit_ind_als[i] = (aldef*)0;
-
 
2030
 
-
 
2031
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
-
 
2032
  unit_ind_diagtags = (diag_tagdef * *)xcalloc(unit_no_of_diagtags,
-
 
2033
                    sizeof(diag_tagdef *));
-
 
2034
  for (i = 0; i < unit_no_of_diagtags; ++i)
-
 
2035
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
2036
 
-
 
2037
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
-
 
2038
  unit_ind_dgtags = (dgtag_struct * *)xcalloc(unit_no_of_dgtags,
-
 
2039
                    sizeof(dgtag_struct *));
-
 
2040
  for (i = 0; i < unit_no_of_dgtags; ++i)
-
 
2041
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
2042
 
-
 
2043
  return;
-
 
2044
}
-
 
2045
 
-
 
2046
 
2034
 
2047
 
2035
 
2048
 
2036
 
-
 
2037
 
2049
tagdef_unit f_make_tagdef_unit
2038
tagdef_unit
2050
    PROTO_Z ()
2039
f_make_tagdef_unit(void)
2051
{
2040
{
2052
  int i;
2041
  int i;
2053
  int j = 0;
2042
  int j = 0;
2054
  int no_of_labels;
2043
  int no_of_labels;
2055
  for (i = 0; i < unit_no_of_tokens; ++i)
2044
  for (i = 0; i < unit_no_of_tokens; ++i) {
2056
   {
-
 
2057
    if (unit_ind_tokens[i] == (tok_define*)0)
2045
    if (unit_ind_tokens[i] == (tok_define *)0) {
2058
      unit_ind_tokens[i] = &unit_toktab[j++];
2046
      unit_ind_tokens[i] = &unit_toktab[j++];
2059
   };
2047
    }
-
 
2048
  }
-
 
2049
  j = 0;
-
 
2050
  for (i = 0; i < unit_no_of_tags; ++i) {
-
 
2051
    if (unit_ind_tags[i] == (dec *)0) {
-
 
2052
      unit_ind_tags[i] = &unit_tagtab[j++];
-
 
2053
    }
-
 
2054
  }
2060
  j = 0;
2055
  j = 0;
2061
  for (i = 0; i < unit_no_of_tags; ++i)
-
 
2062
   {
-
 
2063
    if (unit_ind_tags[i] == (dec*)0)
-
 
2064
      unit_ind_tags[i] = &unit_tagtab[j++];
-
 
2065
   };
-
 
2066
  j = 0;
-
 
2067
  for (i = 0; i < unit_no_of_als; ++i)
2056
  for (i = 0; i < unit_no_of_als; ++i) {
2068
   {
-
 
2069
    if (unit_ind_als[i] == (aldef*)0)
2057
    if (unit_ind_als[i] == (aldef *)0) {
2070
      unit_ind_als[i] = &unit_altab[j++];
2058
      unit_ind_als[i] = &unit_altab[j++];
2071
   };
2059
    }
-
 
2060
  }
2072
  j = 0;
2061
  j = 0;
2073
  for (i = 0; i < unit_no_of_dgtags; ++i)	/* NEW DIAGS */
2062
  for (i = 0; i < unit_no_of_dgtags; ++i) {	/* NEW DIAGS */
2074
   {
-
 
2075
    if (unit_ind_dgtags[i] == (dgtag_struct *)0)
2063
    if (unit_ind_dgtags[i] == (dgtag_struct *)0) {
2076
      unit_ind_dgtags[i] = &unit_dgtagtab[j++];
2064
      unit_ind_dgtags[i] = &unit_dgtagtab[j++];
2077
   };
2065
    }
-
 
2066
  }
2078
  start_bytestream();
2067
  start_bytestream();
2079
  no_of_labels = small_dtdfint();
2068
  no_of_labels = small_dtdfint();
2080
  unit_no_of_labels = no_of_labels;
2069
  unit_no_of_labels = no_of_labels;
2081
  unit_labtab = (exp*)xcalloc(unit_no_of_labels, sizeof(exp));
2070
  unit_labtab = (exp *)xcalloc(unit_no_of_labels, sizeof(exp));
2082
  IGNORE d_tagdef_list();
2071
  IGNORE d_tagdef_list();
2083
  tidy_initial_values();
2072
  tidy_initial_values();
2084
  translate_unit();
2073
  translate_unit();
2085
  end_bytestream();
2074
  end_bytestream();
2086
 
2075
 
2087
  xfree((void*)unit_ind_tokens);
2076
  xfree((void *)unit_ind_tokens);
2088
  xfree((void*)unit_ind_tags);
2077
  xfree((void *)unit_ind_tags);
2089
  xfree((void*)unit_ind_als);
2078
  xfree((void *)unit_ind_als);
2090
  xfree((void*)unit_labtab);
2079
  xfree((void *)unit_labtab);
2091
 
2080
 
2092
  xfree((void*)unit_toktab);
2081
  xfree((void *)unit_toktab);
2093
  xfree((void*)unit_tagtab);
2082
  xfree((void *)unit_tagtab);
2094
 
2083
 
2095
  return 0;
2084
  return 0;
2096
}
2085
}
2097
 
2086
 
2098
void start_make_aldef_unit
2087
void
2099
    PROTO_N ( (no_of_tokens, no_of_tags, no_of_als, no_of_diagtags, no_of_dgtags) )
2088
start_make_aldef_unit(int no_of_tokens, int no_of_tags, int no_of_als,
2100
    PROTO_T ( int no_of_tokens X int no_of_tags X int no_of_als X int no_of_diagtags X int no_of_dgtags )
2089
		      int no_of_diagtags, int no_of_dgtags)
2101
{
2090
{
2102
  int i;
2091
  int i;
2103
 
2092
 
2104
  unit_no_of_tokens = no_of_tokens;
2093
  unit_no_of_tokens = no_of_tokens;
2105
  unit_ind_tokens = (tok_define * *)xcalloc(unit_no_of_tokens,
2094
  unit_ind_tokens = (tok_define **)xcalloc(unit_no_of_tokens,
2106
                    sizeof(tok_define *));
2095
					   sizeof(tok_define *));
2107
  for (i = 0; i < unit_no_of_tokens; ++i)
2096
  for (i = 0; i < unit_no_of_tokens; ++i) {
2108
    unit_ind_tokens[i] = (tok_define*)0;
2097
    unit_ind_tokens[i] = (tok_define *)0;
-
 
2098
  }
2109
 
2099
 
2110
  unit_no_of_tags = no_of_tags;
2100
  unit_no_of_tags = no_of_tags;
2111
  unit_ind_tags = (dec * *)xcalloc(unit_no_of_tags,
2101
  unit_ind_tags = (dec **)xcalloc(unit_no_of_tags, sizeof(dec *));
2112
                    sizeof(dec *));
-
 
2113
  for (i = 0; i < unit_no_of_tags; ++i)
2102
  for (i = 0; i < unit_no_of_tags; ++i) {
2114
    unit_ind_tags[i] = (dec*)0;
2103
    unit_ind_tags[i] = (dec *)0;
-
 
2104
  }
2115
 
2105
 
2116
  unit_no_of_als = no_of_als;
2106
  unit_no_of_als = no_of_als;
2117
  unit_ind_als = (aldef * *)xcalloc(unit_no_of_als,
2107
  unit_ind_als = (aldef **)xcalloc(unit_no_of_als, sizeof(aldef *));
2118
                    sizeof(aldef *));
-
 
2119
  for (i = 0; i < unit_no_of_als; ++i)
2108
  for (i = 0; i < unit_no_of_als; ++i) {
2120
    unit_ind_als[i] = (aldef*)0;
2109
    unit_ind_als[i] = (aldef *)0;
-
 
2110
  }
2121
 
2111
 
2122
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
2112
  unit_no_of_diagtags = no_of_diagtags;		/* OLD DIAGS */
2123
  unit_ind_diagtags = (diag_tagdef * *)xcalloc(unit_no_of_diagtags,
2113
  unit_ind_diagtags = (diag_tagdef **)xcalloc(unit_no_of_diagtags,
2124
                    sizeof(diag_tagdef *));
2114
					      sizeof(diag_tagdef *));
2125
  for (i = 0; i < unit_no_of_diagtags; ++i)
2115
  for (i = 0; i < unit_no_of_diagtags; ++i) {
2126
    unit_ind_diagtags[i] = (diag_tagdef *)0;
2116
    unit_ind_diagtags[i] = (diag_tagdef *)0;
-
 
2117
  }
2127
 
2118
 
2128
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
2119
  unit_no_of_dgtags = no_of_dgtags;		/* NEW DIAGS */
2129
  unit_ind_dgtags = (dgtag_struct * *)xcalloc(unit_no_of_dgtags,
2120
  unit_ind_dgtags = (dgtag_struct **)xcalloc(unit_no_of_dgtags,
2130
                    sizeof(dgtag_struct *));
2121
					     sizeof(dgtag_struct *));
2131
  for (i = 0; i < unit_no_of_dgtags; ++i)
2122
  for (i = 0; i < unit_no_of_dgtags; ++i) {
2132
    unit_ind_dgtags[i] = (dgtag_struct *)0;
2123
    unit_ind_dgtags[i] = (dgtag_struct *)0;
-
 
2124
  }
2133
 
2125
 
2134
  return;
2126
  return;
2135
}
2127
}
2136
 
2128
 
2137
aldef_unit f_make_aldef_unit
2129
aldef_unit
2138
    PROTO_Z ()
2130
f_make_aldef_unit(void)
2139
{
2131
{
2140
  int i;
2132
  int i;
2141
  int j = 0;
2133
  int j = 0;
2142
  int no_of_labels;
2134
  int no_of_labels;
2143
  for (i = 0; i < unit_no_of_tokens; ++i)
2135
  for (i = 0; i < unit_no_of_tokens; ++i) {
2144
   {
-
 
2145
    if (unit_ind_tokens[i] == (tok_define*)0)
2136
    if (unit_ind_tokens[i] == (tok_define *)0) {
2146
      unit_ind_tokens[i] = &unit_toktab[j++];
2137
      unit_ind_tokens[i] = &unit_toktab[j++];
2147
   };
2138
    }
-
 
2139
  }
2148
  j = 0;
2140
  j = 0;
2149
  for (i = 0; i < unit_no_of_als; ++i)
2141
  for (i = 0; i < unit_no_of_als; ++i) {
2150
   {
-
 
2151
    if (unit_ind_als[i] == (aldef*)0)
2142
    if (unit_ind_als[i] == (aldef *)0) {
2152
      unit_ind_als[i] = &unit_altab[j++];
2143
      unit_ind_als[i] = &unit_altab[j++];
2153
   };
2144
    }
-
 
2145
  }
2154
  start_bytestream();
2146
  start_bytestream();
2155
  no_of_labels = small_dtdfint();
2147
  no_of_labels = small_dtdfint();
2156
  unit_no_of_labels = no_of_labels;
2148
  unit_no_of_labels = no_of_labels;
2157
  unit_labtab = (exp*)xcalloc(unit_no_of_labels, sizeof(exp));
2149
  unit_labtab = (exp *)xcalloc(unit_no_of_labels, sizeof(exp));
2158
  IGNORE d_al_tagdef_list();
2150
  IGNORE d_al_tagdef_list();
2159
  end_bytestream();
2151
  end_bytestream();
2160
 
2152
 
2161
  xfree((void*)unit_ind_tokens);
2153
  xfree((void *)unit_ind_tokens);
2162
  xfree((void*)unit_ind_tags);
2154
  xfree((void *)unit_ind_tags);
2163
  xfree((void*)unit_ind_als);
2155
  xfree((void *)unit_ind_als);
2164
  xfree((void*)unit_labtab);
2156
  xfree((void *)unit_labtab);
2165
 
2157
 
2166
  xfree((void*)unit_toktab);
2158
  xfree((void *)unit_toktab);
2167
  xfree((void*)unit_tagtab);
2159
  xfree((void *)unit_tagtab);
2168
 
2160
 
2169
  return 0;
2161
  return 0;
2170
}
2162
}
2171
 
2163
 
2172
void start_make_unit
2164
void
2173
    PROTO_N ( (lvl) )
-
 
2174
    PROTO_T ( tdfint_list lvl )
2165
start_make_unit(tdfint_list lvl)
2175
{
2166
{
2176
  int w;
2167
  int w;
2177
  int ntok = 0;
2168
  int ntok = 0;
2178
  int ntag = 0;
2169
  int ntag = 0;
2179
  int nal = 0;
2170
  int nal = 0;
Line 2191... Line 2182...
2191
    nal = (w == -1) ? 0 : natint(lvl.members[w]);
2182
    nal = (w == -1) ? 0 : natint(lvl.members[w]);
2192
    w = find_index("diagtag");		/* OLD DIAGS */
2183
    w = find_index("diagtag");		/* OLD DIAGS */
2193
    ndiagtype = (w == -1) ? 0 : natint(lvl.members[w]);
2184
    ndiagtype = (w == -1) ? 0 : natint(lvl.members[w]);
2194
    w = find_index("dgtag");		/* NEW DIAGS */
2185
    w = find_index("dgtag");		/* NEW DIAGS */
2195
    ndgtag = (w == -1) ? 0 : natint(lvl.members[w]);
2186
    ndgtag = (w == -1) ? 0 : natint(lvl.members[w]);
2196
  };
2187
  }
2197
 
2188
 
2198
  switch(crt_group_type)
2189
  switch (crt_group_type)
2199
   {
2190
   {
2200
     case TOKDEC_UNIT:
2191
     case TOKDEC_UNIT:
2201
              start_make_tokdec_unit(ntok, ntag, nal, ndiagtype, ndgtag);
2192
              start_make_tokdec_unit(ntok, ntag, nal, ndiagtype, ndgtag);
2202
              return;
2193
              return;
2203
     case TOKDEF_UNIT:
2194
     case TOKDEF_UNIT:
Line 2209... Line 2200...
2209
              return;
2200
              return;
2210
     case TAGDEC_UNIT:
2201
     case TAGDEC_UNIT:
2211
	      if (doing_aldefs) {
2202
	      if (doing_aldefs) {
2212
                process_aldefs();
2203
                process_aldefs();
2213
	        doing_aldefs = 0;
2204
	        doing_aldefs = 0;
2214
	      };
2205
	      }
2215
              start_make_tagdec_unit(ntok, ntag, nal, ndiagtype, ndgtag);
2206
              start_make_tagdec_unit(ntok, ntag, nal, ndiagtype, ndgtag);
2216
              return;
2207
              return;
2217
     case TAGDEF_UNIT:
2208
     case TAGDEF_UNIT:
2218
              start_make_tagdef_unit(ntok, ntag, nal, ndiagtype, ndgtag);
2209
              start_make_tagdef_unit(ntok, ntag, nal, ndiagtype, ndgtag);
2219
              return;
2210
              return;
2220
     case DIAGDEF_UNIT:		/* OLD DIAGS */
2211
     case DIAGDEF_UNIT:		/* OLD DIAGS */
2221
              start_make_diagdef_unit(ntok, ntag, nal, ndiagtype);
2212
              start_make_diagdef_unit(ntok, ntag, nal, ndiagtype);
2222
              return;
2213
              return;
2223
     case DIAGTYPE_UNIT:	/* OLD DIAGS */
2214
     case DIAGTYPE_UNIT:	/* OLD DIAGS */
2224
	      if (doing_aldefs) {
2215
	      if (doing_aldefs) {
2225
                process_aldefs();
2216
                process_aldefs();
2226
	        doing_aldefs = 0;
2217
	        doing_aldefs = 0;
2227
	      };
2218
	      }
2228
              start_make_diagtype_unit(ntok, ntag, nal, ndiagtype);
2219
              start_make_diagtype_unit(ntok, ntag, nal, ndiagtype);
2229
              return;
2220
              return;
2230
     case LINKINFO_UNIT:
2221
     case LINKINFO_UNIT:
2231
              start_make_linkinfo_unit(ntok, ntag, nal, 0 /* discarded */);
2222
              start_make_linkinfo_unit(ntok, ntag, nal, 0 /* discarded */);
2232
              return;
2223
              return;
Line 2235... Line 2226...
2235
              return;
2226
              return;
2236
     case DGCOMP_UNIT:	/* NEW DIAGS */
2227
     case DGCOMP_UNIT:	/* NEW DIAGS */
2237
	      if (doing_aldefs) {
2228
	      if (doing_aldefs) {
2238
                process_aldefs();
2229
                process_aldefs();
2239
	        doing_aldefs = 0;
2230
	        doing_aldefs = 0;
2240
	      };
2231
	      }
2241
              start_make_dg_comp_unit(ntok, ntag, nal, ndgtag);
2232
              start_make_dg_comp_unit(ntok, ntag, nal, ndgtag);
2242
              return;
2233
              return;
2243
     default:
2234
     default:
2244
              return;
2235
              return;
2245
   };
2236
   }
2246
}
2237
}
2247
 
2238
 
2248
unit f_make_unit
2239
unit
2249
    PROTO_N ( (lvl, lks, prs) )
-
 
2250
    PROTO_T ( tdfint_list lvl X links_list lks X bytestream prs )
2240
f_make_unit(tdfint_list lvl, links_list lks, bytestream prs)
2251
{
2241
{
-
 
2242
  UNUSED(lvl);
-
 
2243
  UNUSED(lks);
2252
  UNUSED(lvl); UNUSED(lks); UNUSED(prs);
2244
  UNUSED(prs);
2253
  switch(crt_group_type)
2245
  switch (crt_group_type)
2254
   {
2246
   {
2255
     case TOKDEC_UNIT:
2247
     case TOKDEC_UNIT:
2256
              IGNORE f_make_tokdec_unit();
2248
              IGNORE f_make_tokdec_unit();
2257
              break;
2249
              break;
2258
     case TOKDEF_UNIT:
2250
     case TOKDEF_UNIT:
Line 2266... Line 2258...
2266
              break;
2258
              break;
2267
     case TAGDEF_UNIT:
2259
     case TAGDEF_UNIT:
2268
              IGNORE f_make_tagdef_unit();
2260
              IGNORE f_make_tagdef_unit();
2269
              break;
2261
              break;
2270
     case DIAGDEF_UNIT:		/* OLD DIAGS */
2262
     case DIAGDEF_UNIT:		/* OLD DIAGS */
2271
              if (diagnose)
2263
              if (diagnose) {
2272
                IGNORE f_make_diagdef_unit();
2264
                IGNORE f_make_diagdef_unit();
2273
              else
2265
	      } else {
2274
                ignore_bytestream();
2266
                ignore_bytestream();
-
 
2267
	      }
2275
              break;
2268
              break;
2276
     case DIAGTYPE_UNIT:	/* OLD DIAGS */
2269
     case DIAGTYPE_UNIT:	/* OLD DIAGS */
2277
              if (diagnose)
2270
              if (diagnose) {
2278
                IGNORE f_make_diagtype_unit();
2271
                IGNORE f_make_diagtype_unit();
2279
              else
2272
	      } else {
2280
                ignore_bytestream();
2273
                ignore_bytestream();
-
 
2274
	      }
2281
              break;
2275
              break;
2282
     case LINKINFO_UNIT:
2276
     case LINKINFO_UNIT:
2283
              IGNORE f_make_linkinfo_unit();
2277
              IGNORE f_make_linkinfo_unit();
2284
              break;
2278
              break;
2285
     case VERSIONS_UNIT:
2279
     case VERSIONS_UNIT:
2286
	      IGNORE f_make_versions_unit();
2280
	      IGNORE f_make_versions_unit();
2287
	      break;
2281
	      break;
2288
     case DGCOMP_UNIT:	/* NEW DIAGS */
2282
     case DGCOMP_UNIT:	/* NEW DIAGS */
2289
              if (diagnose)
2283
              if (diagnose) {
2290
                IGNORE f_make_dg_comp_unit();
2284
                IGNORE f_make_dg_comp_unit();
2291
              else
2285
	      } else {
2292
                ignore_bytestream();
2286
                ignore_bytestream();
-
 
2287
	      }
2293
              break;
2288
              break;
2294
     default:
2289
     default:
2295
              ignore_bytestream();
2290
              ignore_bytestream();
2296
              break;
2291
              break;
2297
   };
2292
   }
2298
  return 0;
2293
  return 0;
2299
}
2294
}
2300
 
2295
 
2301
linkextern f_make_linkextern
2296
linkextern
2302
    PROTO_N ( (internal, ext) )
-
 
2303
    PROTO_T ( tdfint internal X external ext )
2297
f_make_linkextern(tdfint internal, external ext)
2304
{
2298
{
2305
  switch (crt_extern_link_type)
2299
  switch (crt_extern_link_type)
2306
   {
2300
   {
2307
     case TOK_TYPE:
2301
     case TOK_TYPE:
2308
       return f_make_tokextern(internal, ext);
2302
       return f_make_tokextern(internal, ext);
Line 2315... Line 2309...
2315
     case DGTAG_TYPE:		/* NEW DIAGS */
2309
     case DGTAG_TYPE:		/* NEW DIAGS */
2316
       return f_make_dgtagextern(internal, ext);
2310
       return f_make_dgtagextern(internal, ext);
2317
     default:
2311
     default:
2318
       failer(VARIABLE_TYPE);
2312
       failer(VARIABLE_TYPE);
2319
       return 0;
2313
       return 0;
2320
   };
2314
   }
2321
}
2315
}
2322
 
2316
 
2323
group f_make_group
2317
group
2324
    PROTO_N ( (us) )
-
 
2325
    PROTO_T ( unit_list us )
2318
f_make_group(unit_list us)
2326
{
2319
{
2327
  UNUSED(us);
2320
  UNUSED(us);
2328
  return 0;
2321
  return 0;
2329
}
2322
}
2330
 
2323
 
2331
links f_make_links
2324
links
2332
    PROTO_N ( (ls) )
-
 
2333
    PROTO_T ( link_list ls )
2325
f_make_links(link_list ls)
2334
{
2326
{
2335
  UNUSED(ls);
2327
  UNUSED(ls);
2336
  return 0;
2328
  return 0;
2337
}
2329
}
2338
 
2330
 
-
 
2331
extern_link
2339
extern_link f_make_extern_link
2332
f_make_extern_link(linkextern_list el)
-
 
2333
{
2340
    PROTO_N ( (el) )
2334
  UNUSED(el);
-
 
2335
  return 0;
-
 
2336
}
-
 
2337
 
-
 
2338
tokdef_props
2341
    PROTO_T ( linkextern_list el )
2339
f_make_tokdefs(tdfint nl, tokdef_list tds)
2342
{
2340
{
2343
  UNUSED(el);
2341
  UNUSED(nl);
-
 
2342
  UNUSED(tds);
2344
  return 0;
2343
  return 0;
2345
}
2344
}
2346
 
2345
 
2347
tokdef_props f_make_tokdefs
2346
tokdec_props
-
 
2347
f_make_tokdecs(tokdec_list tds)
-
 
2348
{
2348
    PROTO_N ( (nl, tds) )
2349
  UNUSED(tds);
-
 
2350
  return 0;
-
 
2351
}
-
 
2352
 
-
 
2353
tagdef_props
2349
    PROTO_T ( tdfint nl X tokdef_list tds )
2354
f_make_tagdefs(tdfint nl, tagdef_list tds)
2350
{
2355
{
-
 
2356
  UNUSED(nl);
2351
  UNUSED(nl); UNUSED(tds);
2357
  UNUSED(tds);
2352
  return 0;
2358
  return 0;
2353
}
2359
}
2354
 
2360
 
2355
tokdec_props f_make_tokdecs
2361
al_tagdef_props
2356
    PROTO_N ( (tds) )
-
 
2357
    PROTO_T ( tokdec_list tds )
2362
f_make_al_tagdefs(tdfint nl, al_tagdef_list tds)
2358
{
2363
{
-
 
2364
  UNUSED(nl);
2359
  UNUSED(tds);
2365
  UNUSED(tds);
2360
  return 0;
2366
  return 0;
2361
}
2367
}
2362
 
2368
 
2363
tagdef_props f_make_tagdefs
2369
tagdec_props
2364
    PROTO_N ( (nl, tds) )
-
 
2365
    PROTO_T ( tdfint nl X tagdef_list tds )
2370
f_make_tagdecs(tdfint nl, tagdec_list tds)
2366
{
-
 
2367
  UNUSED(nl); UNUSED(tds);
-
 
2368
  return 0;
-
 
2369
}
-
 
2370
 
-
 
2371
al_tagdef_props f_make_al_tagdefs
-
 
2372
    PROTO_N ( (nl, tds) )
-
 
2373
    PROTO_T ( tdfint nl X al_tagdef_list tds )
-
 
2374
{
2371
{
2375
  UNUSED(nl); UNUSED(tds);
-
 
2376
  return 0;
2372
 UNUSED(nl);
2377
}
-
 
2378
 
-
 
2379
tagdec_props f_make_tagdecs
-
 
2380
    PROTO_N ( (nl, tds) )
-
 
2381
    PROTO_T ( tdfint nl X tagdec_list tds )
-
 
2382
{
-
 
2383
 UNUSED(nl); UNUSED(tds);
2373
 UNUSED(tds);
2384
 return 0;
2374
 return 0;
2385
}
2375
}
2386
 
2376
 
2387
 
2377
 
2388
 
2378
 
2389
sortname_list new_sortname_list
2379
sortname_list
2390
    PROTO_N ( (n) )
-
 
2391
    PROTO_T ( int n )
2380
new_sortname_list(int n)
2392
{
2381
{
2393
  sortname_list res;
2382
  sortname_list res;
2394
  res.number = n;
2383
  res.number = n;
2395
  res.elems = (sortname*)xcalloc(n, sizeof(sortname));
2384
  res.elems = (sortname *)xcalloc(n, sizeof(sortname));
2396
  return res;
2385
  return res;
2397
}
2386
}
2398
 
2387
 
2399
sortname_list add_sortname_list
2388
sortname_list
2400
    PROTO_N ( (list, elem, index) )
-
 
2401
    PROTO_T ( sortname_list list X sortname elem X int index )
2389
add_sortname_list(sortname_list list, sortname elem, int index)
2402
{
2390
{
2403
  list.elems[index] = elem;
2391
  list.elems[index] = elem;
2404
  return list;
2392
  return list;
2405
}
2393
}
2406
 
2394
 
2407
tokformals_list new_tokformals_list
2395
tokformals_list
2408
    PROTO_N ( (n) )
-
 
2409
    PROTO_T ( int n )
2396
new_tokformals_list(int n)
2410
{
2397
{
2411
  tokformals_list res;
2398
  tokformals_list res;
2412
  res.number = n;
2399
  res.number = n;
2413
  res.par_sorts = (sortname *)xcalloc(n, sizeof(sortname));
2400
  res.par_sorts = (sortname *)xcalloc(n, sizeof(sortname));
2414
  res.par_names = (int *)xcalloc(n, sizeof(int));
2401
  res.par_names = (int *)xcalloc(n, sizeof(int));
2415
  return res;
2402
  return res;
2416
}
2403
}
2417
 
2404
 
2418
tokformals_list add_tokformals_list
2405
tokformals_list
2419
    PROTO_N ( (list, elem, index) )
-
 
2420
    PROTO_T ( tokformals_list list X tokformals elem X int index )
2406
add_tokformals_list(tokformals_list list, tokformals elem, int index)
2421
{
2407
{
2422
  list.par_sorts[index] = elem.sn;
2408
  list.par_sorts[index] = elem.sn;
2423
  list.par_names[index] = elem.tk;
2409
  list.par_names[index] = elem.tk;
2424
  return list;
2410
  return list;
2425
}
2411
}
2426
 
2412
 
2427
tokdec_list new_tokdec_list
2413
tokdec_list
2428
    PROTO_N ( (n) )
-
 
2429
    PROTO_T ( int n )
2414
new_tokdec_list(int n)
2430
{
2415
{
2431
  UNUSED(n);
2416
  UNUSED(n);
2432
  return 0;
2417
  return 0;
2433
}
2418
}
2434
 
2419
 
2435
tokdec_list add_tokdec_list
2420
tokdec_list
2436
    PROTO_N ( (list, elem, index) )
-
 
2437
    PROTO_T ( tokdec_list list X tokdec elem X int index )
2421
add_tokdec_list(tokdec_list list, tokdec elem, int index)
2438
{
2422
{
-
 
2423
  UNUSED(list);
-
 
2424
  UNUSED(elem);
2439
  UNUSED(list); UNUSED(elem); UNUSED(index);
2425
  UNUSED(index);
2440
  return 0;
2426
  return 0;
2441
}
2427
}
2442
 
2428
 
2443
tokdef_list new_tokdef_list
2429
tokdef_list
2444
    PROTO_N ( (n) )
2430
new_tokdef_list(int n)
-
 
2431
{
2445
    PROTO_T ( int n )
2432
  UNUSED(n);
-
 
2433
  return 0;
-
 
2434
}
-
 
2435
 
-
 
2436
tokdef_list
-
 
2437
add_tokdef_list(tokdef_list list, tokdef elem, int index)
2446
{
2438
{
-
 
2439
  UNUSED(list);
-
 
2440
  UNUSED(elem);
2447
  UNUSED(n);
2441
  UNUSED(index);
2448
  return 0;
2442
  return 0;
2449
}
2443
}
2450
 
2444
 
2451
tokdef_list add_tokdef_list
2445
al_tagdef_list
2452
    PROTO_N ( (list, elem, index) )
2446
new_al_tagdef_list(int n)
2453
    PROTO_T ( tokdef_list list X tokdef elem X int index )
-
 
2454
{
2447
{
2455
  UNUSED(list); UNUSED(elem); UNUSED(index);
2448
  UNUSED(n);
2456
  return 0;
2449
  return 0;
2457
}
2450
}
2458
 
2451
 
2459
al_tagdef_list new_al_tagdef_list
2452
al_tagdef_list
2460
    PROTO_N ( (n) )
-
 
2461
    PROTO_T ( int n )
2453
add_al_tagdef_list(al_tagdef_list list, al_tagdef elem, int index)
2462
{
2454
{
2463
  UNUSED(n);
2455
  UNUSED(list);
2464
  return 0;
2456
  UNUSED(elem);
2465
}
-
 
2466
 
-
 
2467
al_tagdef_list add_al_tagdef_list
-
 
2468
    PROTO_N ( (list, elem, index) )
-
 
2469
    PROTO_T ( al_tagdef_list list X al_tagdef elem X int index )
-
 
2470
{
-
 
2471
  UNUSED(list); UNUSED(elem); UNUSED(index);
2457
  UNUSED(index);
2472
  return 0;
2458
  return 0;
2473
}
2459
}
2474
 
2460
 
2475
 
2461
 
2476
al_tagdef f_make_al_tagdef
2462
al_tagdef
2477
    PROTO_N ( (t, a) )
-
 
2478
    PROTO_T ( tdfint t X alignment a )
2463
f_make_al_tagdef(tdfint t, alignment a)
2479
{
2464
{
2480
  aldef * ap = get_aldef(natint(t));
2465
  aldef *ap = get_aldef(natint(t));
2481
  ap -> next_aldef = top_aldef;
2466
  ap->next_aldef = top_aldef;
2482
  top_aldef = ap;
2467
  top_aldef = ap;
2483
  ap -> al = a -> al;
2468
  ap->al = a->al;
2484
  return 0;
2469
  return 0;
2485
}
2470
}
2486
 
2471
 
2487
 
2472
 
2488
 
2473
 
2489
tagdec_list new_tagdec_list
2474
tagdec_list
2490
    PROTO_N ( (n) )
-
 
2491
    PROTO_T ( int n )
2475
new_tagdec_list(int n)
2492
{
2476
{
2493
  UNUSED(n);
2477
  UNUSED(n);
2494
  return 0;
2478
  return 0;
2495
}
2479
}
2496
 
2480
 
2497
tagdec_list add_tagdec_list
2481
tagdec_list
2498
    PROTO_N ( (list, elem, index) )
-
 
2499
    PROTO_T ( tagdec_list list X tagdec elem X int index )
2482
add_tagdec_list(tagdec_list list, tagdec elem, int index)
2500
{
2483
{
2501
    dec * dp = elem.tg;
2484
    dec *dp = elem.tg;
2502
    shape s;
2485
    shape s;
2503
    exp e;
2486
    exp e;
-
 
2487
    UNUSED(list);
2504
    UNUSED(list); UNUSED(index);
2488
    UNUSED(index);
2505
    s = elem.sha;
2489
    s = elem.sha;
2506
 
2490
 
2507
    e = getexp(s, nilexp, 0, nilexp, nilexp, 0, 0, ident_tag);
2491
    e = getexp(s, nilexp, 0, nilexp, nilexp, 0, 0, ident_tag);
2508
 
2492
 
2509
    if (elem.is_variable)
2493
    if (elem.is_variable) {
2510
     {
-
 
2511
#if keep_PIC_vars
2494
#if keep_PIC_vars
2512
       setvar(e);
2495
       setvar(e);
2513
#else
2496
#else
2514
       if (PIC_code && dp -> dec_u.dec_val.extnamed)
2497
       if (PIC_code && dp -> dec_u.dec_val.extnamed) {
2515
         sh(e) = f_pointer(f_alignment(s));
2498
         sh(e) = f_pointer(f_alignment(s));
2516
       else
2499
       } else {
2517
         setvar(e);
2500
         setvar(e);
-
 
2501
       }
2518
#endif
2502
#endif
2519
     };
2503
    }
2520
 
2504
 
2521
    if (elem.acc & (f_visible | f_long_jump_access))
2505
    if (elem.acc & (f_visible | f_long_jump_access)) {
2522
      setvis(e);
2506
      setvis(e);
-
 
2507
    }
2523
    if (elem.acc & f_constant)
2508
    if (elem.acc & f_constant) {
2524
      setcaonly(e);
2509
      setcaonly(e);
-
 
2510
    }
2525
 
2511
 
2526
    dp -> dec_u.dec_val.acc = elem.acc;
2512
    dp->dec_u.dec_val.acc = elem.acc;
2527
 
2513
 
2528
    dp -> dec_u.dec_val.dec_exp = e;
2514
    dp->dec_u.dec_val.dec_exp = e;
2529
 
2515
 
2530
    if (dp -> dec_u.dec_val.dec_shape != nilexp) {
2516
    if (dp->dec_u.dec_val.dec_shape != nilexp) {
2531
      if (shape_size(s) > shape_size(dp -> dec_u.dec_val.dec_shape))
2517
      if (shape_size(s) > shape_size(dp->dec_u.dec_val.dec_shape)) {
2532
        dp -> dec_u.dec_val.dec_shape = s;
2518
        dp->dec_u.dec_val.dec_shape = s;
-
 
2519
      }
2533
    };
2520
    }
2534
 
2521
 
2535
    if (dp -> dec_u.dec_val.dec_shape == nilexp) {
2522
    if (dp->dec_u.dec_val.dec_shape == nilexp) {
2536
      dp -> dec_u.dec_val.dec_shape = s;
2523
      dp->dec_u.dec_val.dec_shape = s;
2537
      dp -> def_next = (dec *)0;
2524
      dp->def_next = (dec *)0;
2538
      *deflist_end = dp;
2525
      *deflist_end = dp;
2539
      deflist_end = &((*deflist_end) -> def_next);
2526
      deflist_end = & ((*deflist_end)->def_next);
2540
    };
2527
    }
2541
 
2528
 
2542
    dp -> dec_u.dec_val.dec_var = (unsigned int)(isvar(e) || elem.is_variable) ;
2529
    dp->dec_u.dec_val.dec_var = (unsigned int)(isvar(e) || elem.is_variable);
2543
    if (!dp -> dec_u.dec_val.have_def)
2530
    if (!dp->dec_u.dec_val.have_def) {
2544
     {
-
 
2545
      setglob(e);
2531
      setglob(e);
2546
     };
2532
    }
2547
    /* the defining exp */
2533
    /* the defining exp */
2548
    brog(dp -> dec_u.dec_val.dec_exp) = dp;
2534
    brog(dp->dec_u.dec_val.dec_exp) = dp;
2549
    if (dp -> dec_u.dec_val.dec_id == (char *) 0)
2535
    if (dp->dec_u.dec_val.dec_id == (char *)0) {
2550
      dp -> dec_u.dec_val.dec_id = make_local_name();
2536
      dp->dec_u.dec_val.dec_id = make_local_name();
-
 
2537
    }
-
 
2538
 
-
 
2539
  return 0;
-
 
2540
}
2551
 
2541
 
-
 
2542
tagdef_list
-
 
2543
new_tagdef_list(int n)
-
 
2544
{
-
 
2545
  UNUSED(n);
2552
  return 0;
2546
  return 0;
2553
}
2547
}
2554
 
2548
 
2555
tagdef_list new_tagdef_list
2549
tagdef_list
2556
    PROTO_N ( (n) )
-
 
2557
    PROTO_T ( int n )
-
 
2558
{
-
 
2559
  UNUSED(n);
-
 
2560
  return 0;
-
 
2561
}
-
 
2562
 
-
 
2563
tagdef_list add_tagdef_list
-
 
2564
    PROTO_N ( (list, elem, index) )
-
 
2565
    PROTO_T ( tagdef_list list X tagdef elem X int index )
2550
add_tagdef_list(tagdef_list list, tagdef elem, int index)
2566
{
2551
{
2567
  dec * dp = elem.tg;
2552
  dec *dp = elem.tg;
2568
  exp old_def = son(dp -> dec_u.dec_val.dec_exp);
2553
  exp old_def = son(dp->dec_u.dec_val.dec_exp);
2569
  exp new_def = elem.def;
2554
  exp new_def = elem.def;
-
 
2555
  UNUSED(list);
2570
  UNUSED(list); UNUSED(index);
2556
  UNUSED(index);
2571
  if (dp -> dec_u.dec_val.processed || new_def == nilexp)
2557
  if (dp->dec_u.dec_val.processed || new_def == nilexp) {
2572
    return 0;
2558
    return 0;
-
 
2559
  }
2573
 
2560
 
2574
  if (old_def == nilexp ||
2561
  if (old_def == nilexp ||
2575
       shape_size(sh(new_def)) > shape_size(sh(old_def)) ||
2562
      shape_size(sh(new_def)) > shape_size(sh(old_def)) ||
2576
       (name(new_def) != clear_tag && name(old_def) == clear_tag))  {
2563
      (name(new_def) != clear_tag && name(old_def) == clear_tag)) {
2577
    son(dp -> dec_u.dec_val.dec_exp) = new_def;
2564
    son(dp->dec_u.dec_val.dec_exp) = new_def;
2578
    setfather(dp -> dec_u.dec_val.dec_exp, elem.def);
2565
    setfather(dp->dec_u.dec_val.dec_exp, elem.def);
2579
  };
2566
  }
2580
 
2567
 
2581
  return 0;
2568
  return 0;
2582
}
2569
}
2583
 
2570
 
2584
tdfident_list new_tdfident_list
2571
tdfident_list
2585
    PROTO_N ( (n) )
-
 
2586
    PROTO_T ( int n )
2572
new_tdfident_list(int n)
2587
{
2573
{
2588
  tdfstring_list res;
2574
  tdfstring_list res;
2589
  res.elems = (tdfstring *)xcalloc(n, sizeof(tdfstring));
2575
  res.elems = (tdfstring *)xcalloc(n, sizeof(tdfstring));
2590
  res.number = n;
2576
  res.number = n;
2591
  return res;
2577
  return res;
2592
}
2578
}
2593
 
2579
 
2594
tdfident_list add_tdfident_list
2580
tdfident_list
2595
    PROTO_N ( (list, elem, index) )
-
 
2596
    PROTO_T ( tdfident_list list X tdfident elem X int index )
2581
add_tdfident_list(tdfident_list list, tdfident elem, int index)
2597
{
2582
{
2598
  list.elems[index] = elem;
2583
  list.elems[index] = elem;
2599
  return list;
2584
  return list;
2600
}
2585
}
2601
 
2586
 
2602
tdfint_list new_tdfint_list
2587
tdfint_list
2603
    PROTO_N ( (n) )
-
 
2604
    PROTO_T ( int n )
2588
new_tdfint_list(int n)
2605
{
2589
{
2606
  tdfint_list res;
2590
  tdfint_list res;
2607
  res.members = (tdfint *)xcalloc(n, sizeof(tdfint));
2591
  res.members = (tdfint *)xcalloc(n, sizeof(tdfint));
2608
  res.number = n;
2592
  res.number = n;
2609
  return res;
2593
  return res;
2610
}
2594
}
2611
 
2595
 
2612
tdfint_list add_tdfint_list
2596
tdfint_list
2613
    PROTO_N ( (list, elem, index) )
-
 
2614
    PROTO_T ( tdfint_list list X tdfint elem X int index )
2597
add_tdfint_list(tdfint_list list, tdfint elem, int index)
2615
{
2598
{
2616
  list.members[index] = elem;
2599
  list.members[index] = elem;
2617
  return list;
2600
  return list;
2618
}
2601
}
2619
 
2602
 
2620
group_list new_group_list
2603
group_list
2621
    PROTO_N ( (n) )
-
 
2622
    PROTO_T ( int n )
2604
new_group_list(int n)
2623
{
2605
{
2624
  UNUSED(n);
2606
  UNUSED(n);
2625
  crt_group_type = group_type(crt_capsule_groups[0].ints.chars);
2607
  crt_group_type = group_type(crt_capsule_groups[0].ints.chars);
2626
  return 0;
2608
  return 0;
2627
}
2609
}
2628
 
2610
 
2629
group_list add_group_list
2611
group_list
2630
    PROTO_N ( (list, elem, index) )
-
 
2631
    PROTO_T ( group_list list X group elem X int index )
2612
add_group_list(group_list list, group elem, int index)
2632
{
2613
{
-
 
2614
  UNUSED(list);
2633
  UNUSED(list); UNUSED(elem);
2615
  UNUSED(elem);
2634
  if (index < (crt_capsule_group_no-1))
2616
  if (index < (crt_capsule_group_no - 1)) {
2635
    crt_group_type = group_type(crt_capsule_groups[index+1].ints.chars);
2617
    crt_group_type = group_type(crt_capsule_groups[index + 1].ints.chars);
-
 
2618
  }
2636
  return 0;
2619
  return 0;
2637
}
2620
}
2638
 
2621
 
2639
links_list new_links_list
2622
links_list
2640
    PROTO_N ( (n) )
-
 
2641
    PROTO_T ( int n )
2623
new_links_list(int n)
2642
{
2624
{
2643
  UNUSED(n);
2625
  UNUSED(n);
2644
  if (crt_capsule_link_no != 0)
2626
  if (crt_capsule_link_no != 0) {
2645
    crt_links_type = links_type(crt_capsule_linking.members[0].id);
2627
    crt_links_type = links_type(crt_capsule_linking.members[0].id);
-
 
2628
  }
2646
  return 0;
2629
  return 0;
2647
}
2630
}
2648
 
2631
 
2649
links_list add_links_list
2632
links_list
2650
    PROTO_N ( (list, elem, index) )
-
 
2651
    PROTO_T ( links_list list X links elem X int index )
2633
add_links_list(links_list list, links elem, int index)
2652
{
2634
{
-
 
2635
  UNUSED(list);
2653
  UNUSED(list); UNUSED(elem);
2636
  UNUSED(elem);
2654
  if (index < (crt_capsule_linking.number-1))
2637
  if (index < (crt_capsule_linking.number - 1)) {
2655
    crt_links_type = links_type(crt_capsule_linking.members[index+1].id);
2638
    crt_links_type = links_type(crt_capsule_linking.members[index + 1].id);
-
 
2639
  }
2656
  return 0;
2640
  return 0;
2657
}
2641
}
2658
 
2642
 
2659
extern_link_list new_extern_link_list
2643
extern_link_list
2660
    PROTO_N ( (n) )
-
 
2661
    PROTO_T ( int n )
2644
new_extern_link_list(int n)
2662
{
2645
{
2663
  UNUSED(n);
2646
  UNUSED(n);
2664
  if (crt_capsule_link_no != 0)
2647
  if (crt_capsule_link_no != 0) {
2665
    crt_extern_link_type = links_type(crt_capsule_linking.members[0].id);
2648
    crt_extern_link_type = links_type(crt_capsule_linking.members[0].id);
-
 
2649
  }
2666
  return 0;
2650
  return 0;
2667
}
2651
}
2668
 
2652
 
2669
extern_link_list add_extern_link_list
2653
extern_link_list
2670
    PROTO_N ( (list, elem, index) )
-
 
2671
    PROTO_T ( extern_link_list list X extern_link elem X int index )
2654
add_extern_link_list(extern_link_list list, extern_link elem, int index)
2672
{
2655
{
2673
  UNUSED(list); UNUSED(elem);
2656
  UNUSED(list);
-
 
2657
  UNUSED(elem);
2674
  if (index < (crt_capsule_linking.number-1))
2658
  if (index < (crt_capsule_linking.number - 1)) {
2675
     crt_extern_link_type =
2659
    crt_extern_link_type =
2676
         links_type(crt_capsule_linking.members[index+1].id);
2660
	links_type(crt_capsule_linking.members[index + 1].id);
-
 
2661
  }
2677
  return 0;
2662
  return 0;
2678
}
2663
}
2679
 
2664
 
2680
capsule_link_list new_capsule_link_list
2665
capsule_link_list
2681
    PROTO_N ( (n) )
-
 
2682
    PROTO_T ( int n )
2666
new_capsule_link_list(int n)
2683
{
2667
{
2684
  capsule_link_list res;
2668
  capsule_link_list res;
2685
  res.members = (capsule_link *)xcalloc(n, sizeof(capsule_link));
2669
  res.members = (capsule_link *)xcalloc(n, sizeof(capsule_link));
2686
  res.number = n;
2670
  res.number = n;
2687
  return res;
2671
  return res;
2688
}
2672
}
2689
 
2673
 
2690
capsule_link_list add_capsule_link_list
2674
capsule_link_list
2691
    PROTO_N ( (list, elem, index) )
-
 
2692
    PROTO_T ( capsule_link_list list X capsule_link elem X int index )
2675
add_capsule_link_list(capsule_link_list list, capsule_link elem, int index)
2693
{
2676
{
2694
  list.members[index] = elem;
2677
  list.members[index] = elem;
2695
  return list;
2678
  return list;
2696
}
2679
}
2697
 
2680
 
2698
unit_list new_unit_list
2681
unit_list
2699
    PROTO_N ( (n) )
-
 
2700
    PROTO_T ( int n )
2682
new_unit_list(int n)
2701
{
2683
{
2702
  UNUSED(n);
2684
  UNUSED(n);
2703
  return 0;
2685
  return 0;
2704
}
2686
}
2705
 
2687
 
2706
unit_list add_unit_list
2688
unit_list
2707
    PROTO_N ( (list, elem, index) )
-
 
2708
    PROTO_T ( unit_list list X unit elem X int index )
2689
add_unit_list(unit_list list, unit elem, int index)
2709
{
2690
{
-
 
2691
  UNUSED(list);
-
 
2692
  UNUSED(elem);
2710
  UNUSED(list); UNUSED(elem); UNUSED(index);
2693
  UNUSED(index);
2711
  return 0;
2694
  return 0;
2712
}
2695
}
2713
 
2696
 
2714
link_list new_link_list
2697
link_list
2715
    PROTO_N ( (n) )
-
 
2716
    PROTO_T ( int n )
2698
new_link_list(int n)
2717
{
2699
{
2718
  int i;
2700
  int i;
2719
  switch (crt_links_type)
2701
  switch (crt_links_type)
2720
   {
2702
   {
2721
       /* initialise the table */
2703
       /* initialise the table */
2722
     case TOK_TYPE:
2704
     case TOK_TYPE:
2723
       no_of_local_tokens = unit_no_of_tokens - n;
2705
       no_of_local_tokens = unit_no_of_tokens - n;
2724
       unit_toktab = (tok_define *)xcalloc(no_of_local_tokens,
2706
       unit_toktab = (tok_define *)xcalloc(no_of_local_tokens,
2725
                         sizeof(tok_define));
2707
					   sizeof(tok_define));
2726
       for (i = 0; i < no_of_local_tokens; ++i) {
2708
       for (i = 0; i < no_of_local_tokens; ++i) {
2727
         tok_define * tp = &unit_toktab[i];
2709
         tok_define *tp = &unit_toktab[i];
2728
         tp -> tok_special = 0;
2710
         tp->tok_special = 0;
2729
         tp -> valpresent = 0;
2711
         tp->valpresent = 0;
2730
         tp -> unit_number = crt_tagdef_unit_no;
2712
         tp->unit_number = crt_tagdef_unit_no;
2731
         tp -> defined = 0;
2713
         tp->defined = 0;
2732
         tp -> tok_index = i;
2714
         tp->tok_index = i;
2733
         tp -> is_capsule_token = 0;
2715
         tp->is_capsule_token = 0;
2734
         tp -> recursive = 0;
2716
         tp->recursive = 0;
2735
       };
2717
       }
2736
       return 0;
2718
       return 0;
2737
     case TAG_TYPE:
2719
     case TAG_TYPE:
2738
       unit_tagtab = (dec *)xcalloc(unit_no_of_tags - n,
2720
       unit_tagtab = (dec *)xcalloc(unit_no_of_tags - n, sizeof(dec));
2739
                         sizeof(dec));
-
 
2740
       for (i = 0; i < unit_no_of_tags - n; ++i) {
2721
       for (i = 0; i < unit_no_of_tags - n; ++i) {
2741
         dec * dp = &unit_tagtab[i];
2722
         dec *dp = &unit_tagtab[i];
2742
         dp -> dec_u.dec_val.dec_outermost = 0;
2723
         dp->dec_u.dec_val.dec_outermost = 0;
2743
         dp -> dec_u.dec_val.dec_id = (char *) 0;
2724
         dp->dec_u.dec_val.dec_id = (char *)0;
2744
         dp -> dec_u.dec_val.extnamed = 0;
2725
         dp->dec_u.dec_val.extnamed = 0;
2745
         dp -> dec_u.dec_val.diag_info = (diag_global *)0;
2726
         dp->dec_u.dec_val.diag_info = (diag_global *)0;
2746
         dp -> dec_u.dec_val.have_def = 0;
2727
         dp->dec_u.dec_val.have_def = 0;
2747
         dp -> dec_u.dec_val.dec_shape = nilexp;
2728
         dp->dec_u.dec_val.dec_shape = nilexp;
2748
         dp -> dec_u.dec_val.processed = 0;
2729
         dp->dec_u.dec_val.processed = 0;
2749
         dp -> dec_u.dec_val.isweak = 0;
2730
         dp->dec_u.dec_val.isweak = 0;
2750
         dp -> dec_u.dec_val.dec_exp = nilexp;
2731
         dp->dec_u.dec_val.dec_exp = nilexp;
2751
       };
2732
       }
2752
       return 0;
2733
       return 0;
2753
     case AL_TYPE:
2734
     case AL_TYPE:
2754
       unit_altab = (aldef *)xcalloc(unit_no_of_als - n,
2735
       unit_altab = (aldef *)xcalloc(unit_no_of_als - n, sizeof(aldef));
2755
                         sizeof(aldef));
-
 
2756
       for (i = 0; i < unit_no_of_als - n; ++i) {
2736
       for (i = 0; i < unit_no_of_als - n; ++i) {
2757
         aldef * ap = &unit_altab[i];
2737
         aldef *ap = &unit_altab[i];
2758
         ap -> al.al_n = 0;
2738
         ap->al.al_n = 0;
2759
       };
2739
       }
2760
       return 0;
2740
       return 0;
2761
     case DIAGTAG_TYPE:		/* OLD DIAGS */
2741
     case DIAGTAG_TYPE:		/* OLD DIAGS */
2762
       init_unit_diagtags(n);
2742
       init_unit_diagtags(n);
2763
       return 0;
2743
       return 0;
2764
     case DGTAG_TYPE:		/* NEW DIAGS */
2744
     case DGTAG_TYPE:		/* NEW DIAGS */
2765
       init_unit_dgtags(n);
2745
       init_unit_dgtags(n);
2766
       return 0;
2746
       return 0;
2767
     default:
2747
     default:
2768
       failer(LINK_TYPE);
2748
       failer(LINK_TYPE);
2769
       return 0;
2749
       return 0;
2770
   };
2750
   }
2771
}
2751
}
2772
 
2752
 
2773
link_list add_link_list
2753
link_list
2774
    PROTO_N ( (list, elem, index) )
2754
add_link_list(link_list list, link elem, int index)
-
 
2755
{
-
 
2756
  UNUSED(list);
-
 
2757
  UNUSED(elem);
-
 
2758
  UNUSED(index);
-
 
2759
  return 0;
-
 
2760
}
-
 
2761
 
-
 
2762
linkextern_list
2775
    PROTO_T ( link_list list X link elem X int index )
2763
new_linkextern_list(int n)
2776
{
2764
{
2777
  UNUSED(list); UNUSED(elem); UNUSED(index);
2765
  UNUSED(n);
2778
  return 0;
2766
  return 0;
2779
}
2767
}
2780
 
2768
 
2781
linkextern_list new_linkextern_list
2769
linkextern_list
2782
    PROTO_N ( (n) )
-
 
2783
    PROTO_T ( int n )
2770
add_linkextern_list(linkextern_list list, linkextern elem, int index)
2784
{
2771
{
-
 
2772
  UNUSED(list);
-
 
2773
  UNUSED(elem);
2785
  UNUSED(n);
2774
  UNUSED(index);
2786
  return 0;
2775
  return 0;
2787
}
2776
}
2788
 
2777
 
2789
linkextern_list add_linkextern_list
-
 
2790
    PROTO_N ( (list, elem, index) )
-
 
2791
    PROTO_T ( linkextern_list list X linkextern elem X int index )
-
 
2792
{
-
 
2793
  UNUSED(list); UNUSED(elem); UNUSED(index);
-
 
2794
  return 0;
-
 
2795
}
-
 
2796
 
-
 
2797
 
-
 
2798
 
-
 
2799
 
-
 
2800
exp_option no_exp_option;
2778
exp_option no_exp_option;
2801
 
2779
 
2802
exp_option yes_exp_option
2780
exp_option
2803
    PROTO_N ( (elem) )
-
 
2804
    PROTO_T ( exp elem )
2781
yes_exp_option(exp elem)
2805
{
2782
{
2806
  exp_option res;
2783
  exp_option res;
2807
  res.present = 1;
2784
  res.present = 1;
2808
  res.val = elem;
2785
  res.val = elem;
2809
  return res;
2786
  return res;
2810
}
2787
}
2811
 
2788
 
-
 
2789
void
2812
void init_exp_option
2790
init_exp_option(void)
2813
    PROTO_Z ()
-
 
2814
{
2791
{
2815
   no_exp_option.present = 0;
2792
   no_exp_option.present = 0;
2816
   return;
2793
   return;
2817
}
2794
}
2818
 
2795
 
2819
tag_option no_tag_option;
2796
tag_option no_tag_option;
2820
 
2797
 
2821
tag_option yes_tag_option
2798
tag_option
2822
    PROTO_N ( (elem) )
-
 
2823
    PROTO_T ( tag elem )
2799
yes_tag_option(tag elem)
2824
{
2800
{
2825
  tag_option res;
2801
  tag_option res;
2826
  res.present = 1;
2802
  res.present = 1;
2827
  res.val = elem;
2803
  res.val = elem;
2828
  return res;
2804
  return res;
2829
}
2805
}
2830
 
2806
 
-
 
2807
void
2831
void init_tag_option
2808
init_tag_option(void)
2832
    PROTO_Z ()
-
 
2833
{
2809
{
2834
   no_tag_option.present = 0;
2810
   no_tag_option.present = 0;
2835
   return;
2811
   return;
2836
}
-
 
2837
 
-
 
2838
void init_capsule_link
-
 
2839
    PROTO_Z ()
-
 
2840
{
-
 
2841
  return;
-
 
2842
}
-
 
2843
 
-
 
2844
 
-
 
2845
void init_extern_link
-
 
2846
    PROTO_Z ()
-
 
2847
{
-
 
2848
  return;
-
 
2849
}
-
 
2850
 
-
 
2851
void init_group
-
 
2852
    PROTO_Z ()
-
 
2853
{
-
 
2854
  return;
-
 
2855
}
-
 
2856
 
-
 
2857
void init_unit
-
 
2858
    PROTO_Z ()
-
 
2859
{
-
 
2860
  return;
-
 
2861
}
-
 
2862
 
-
 
2863
void init_link
-
 
2864
    PROTO_Z ()
-
 
2865
{
-
 
2866
  return;
-
 
2867
}
-
 
2868
 
-
 
2869
void init_linkextern
-
 
2870
    PROTO_Z ()
-
 
2871
{
-
 
2872
  return;
-
 
2873
}
2812
}
2874
 
2813
 
2875
void init_links
2814
void
2876
    PROTO_Z ()
2815
init_capsule_link(void)
2877
{
2816
{
2878
  return;
2817
  return;
2879
}
2818
}
2880
 
2819
 
-
 
2820
 
2881
void init_tagdec_props
2821
void
2882
    PROTO_Z ()
2822
init_extern_link(void)
2883
{
2823
{
2884
  return;
2824
  return;
2885
}
2825
}
2886
 
2826
 
2887
void init_tagdef_props
2827
void
2888
    PROTO_Z ()
2828
init_group(void)
2889
{
2829
{
2890
  return;
2830
  return;
2891
}
2831
}
2892
 
2832
 
2893
void init_al_tagdef_props
2833
void
2894
    PROTO_Z ()
2834
init_unit(void)
2895
{
2835
{
2896
  return;
2836
  return;
2897
}
2837
}
2898
 
2838
 
2899
void init_tokdec_props
2839
void
2900
    PROTO_Z ()
2840
init_link(void)
2901
{
2841
{
2902
  return;
2842
  return;
2903
}
2843
}
2904
 
2844
 
2905
void init_tokdef_props
2845
void
2906
    PROTO_Z ()
2846
init_linkextern(void)
2907
{
2847
{
2908
  return;
2848
  return;
2909
}
2849
}
2910
 
2850
 
-
 
2851
void
-
 
2852
init_links(void)
-
 
2853
{
-
 
2854
  return;
-
 
2855
}
-
 
2856
 
-
 
2857
void
-
 
2858
init_tagdec_props(void)
-
 
2859
{
-
 
2860
  return;
-
 
2861
}
-
 
2862
 
-
 
2863
void
-
 
2864
init_tagdef_props(void)
-
 
2865
{
-
 
2866
  return;
-
 
2867
}
-
 
2868
 
-
 
2869
void
-
 
2870
init_al_tagdef_props(void)
-
 
2871
{
-
 
2872
  return;
-
 
2873
}
2911
 
2874
 
-
 
2875
void
-
 
2876
init_tokdec_props(void)
-
 
2877
{
-
 
2878
  return;
-
 
2879
}
2912
 
2880
 
-
 
2881
void
-
 
2882
init_tokdef_props(void)
2913
 
2883
{
-
 
2884
  return;
2914
 
2885
}