Subversion Repositories tendra.SVN

Rev

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

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997, 1998
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
12
 
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
15
 
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
19
 
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
23
 
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
28
*/
29
 
30
 
31
/*
32
    TYPE SYSTEM SPECIFICATION
33
 
34
    The main type system for the program is specified using the calculus
35
    tool.  This generates two representations of the type algebra, c_class.
36
    The files in obj_tok describe the output type system abstractly in terms
37
    of the TenDRA '#pragma token' constructs.  These may be used to apply
38
    extremely rigorous type checking to the program.  The files in obj_c
39
    give the implementation of the type system in C terms.  The
40
    implementation specific parts of the program, including the memory
41
    management, is handled in obj_c/c_class.c.
42
*/
43
 
44
ALGEBRA c_class (1.1) :
45
 
46
 
47
/*
48
    PRIMITIVE TYPES
49
 
50
    These are the primitive types from which the algebra is built.  int,
51
    unsigned and string are self-explanitory.  BITSTREAM_P represents a
52
    series of bits, and is used to hold any compiled code.  PPTOKEN_P
53
    represents a list of preprocessing tokens, and is used in macro
54
    definitions etc.
55
*/
56
 
57
int =			"int" ;
58
unsigned =		"unsigned" ;
59
string =		"character *" ;
60
ulong_type (ulong) =	"unsigned long" ;
61
BITSTREAM_P (bits) =	"struct bits_tag *" ;
62
PPTOKEN_P (pptok) =	"struct pptok_tag *" ;
63
 
64
 
65
/*
66
    TYPE REPRESENTING A CONST-VOLATILE SPECIFIER
67
 
68
    The const and volatile type qualifiers are represented by an
69
    enumeration type (which is actually a bit pattern).  An additional
70
    value is used to indicate lvalues.  Type linkage specifiers are also
71
    included.
72
*/
73
 
74
enum !CV_SPEC (cv) = {
75
    none =		0,
76
    const =		1 << 0,
77
    volatile =		1 << 1,
78
    lvalue =		1 << 2,
79
 
80
    c =			1 << 3,
81
    cpp =		1 << 4,
82
 
83
    qual =		const | volatile,
84
    mask =		qual | lvalue,
85
    language =		c | cpp
86
} ;
87
 
88
 
89
/*
90
    TYPE REPRESENTING A BUILT-IN TYPE
91
 
92
    The built-in types have two representations - as a BASE_TYPE (see below)
93
    or as a BUILTIN_TYPE.  The latter is used primarily as an index into
94
    various tables.
95
*/
96
 
97
enum !BUILTIN_TYPE (ntype) = {
98
    none =		0,
99
    char =		1,
100
    schar =		2,
101
    uchar =		3,
102
    sshort =		4,
103
    ushort =		5,
104
    sint =		6,
105
    uint =		7,
106
    slong =		8,
107
    ulong =		9,
108
    sllong =		10,
109
    ullong =		11,
110
    float =		12,
111
    double =		13,
112
    ldouble =		14,
113
    void =		15,
114
    bottom =		16,
115
    bool =		17,
116
    ptrdiff_t =		18,
117
    size_t =		19,
118
    wchar_t =		20,
119
    ellipsis =		21
120
} ;
121
 
122
 
123
/*
124
    TYPE REPRESENTING A BASIC TYPE
125
 
126
    The basic types are represented by an enumeration type (which is
127
    actually a bit pattern except for the named type component).  The
128
    composite bitpatterns for the maximally valid combinations are also
129
    given.  The elaborated type keys are also represented by this type.
130
*/
131
 
132
enum !BASE_TYPE (btype) = {
133
    none =		0,
134
    class =		1,
135
    struct_ =		2,
136
    union_ =		3,
137
    enum_ =		4,
138
    alias =		5,
139
    any =		6,
140
    named =		7,
141
 
142
    signed =		1 << 3,
143
    unsigned =		1 << 4,
144
    char =		1 << 5,
145
    short =		1 << 6,
146
    int =		1 << 7,
147
    long =		1 << 8,
148
    long2 =		1 << 9,
149
    float =		1 << 10,
150
    double =		1 << 11,
151
    void =		1 << 12,
152
    bottom =		1 << 13,
153
    bool =		1 << 14,
154
    ptrdiff_t =		1 << 15,
155
    size_t =		1 << 16,
156
    wchar_t =		1 << 17,
157
 
158
    schar =		signed | char,
159
    uchar =		unsigned | char,
160
    sshort =		signed | short | int,
161
    ushort =		unsigned | short | int,
162
    sint =		signed | int,
163
    uint =		unsigned | int,
164
    slong =		signed | long | int,
165
    ulong =		unsigned | long | int,
166
    llong =		long | long2,
167
    sllong =		signed | llong | int,
168
    ullong =		unsigned | llong | int,
169
    ldouble =		long | double,
170
 
171
    ellipsis =		1 << 18,
172
    star =		1 << 19,
173
    template =		1 << 20,
174
    typename =		1 << 21,
175
    args =		1 << 22,
176
    keyword =		float | double | void | bool | wchar_t,
177
    other =		keyword | bottom | ptrdiff_t | size_t,
178
    arith =		int | float,
179
    scalar =		int | float | star
180
} ;
181
 
182
 
183
/*
184
    TYPE REPRESENTING AN INTEGRAL TYPE
185
 
186
    An integral type can be one of the built-in types, an integral promotion
187
    type or an arithmetic conversion type.  The promotion type for each
188
    integral type is stored as part of its definition.
189
*/
190
 
191
union INT_TYPE (itype) = {
192
    TYPE prom ;
193
    LIST TYPE cases ;
194
    BUILTIN_TYPE unprom = "ntype_none" ;
195
    ulong_type itok = "LINK_NONE" ;
196
    ulong_type ntok = "LINK_NONE" ;
197
    ulong_type diag = "LINK_NONE" ;
198
} + {
199
    basic -> {
200
	/* Built-in types */
201
	BASE_TYPE rep ;
202
	BUILTIN_TYPE no ;
203
    },
204
    bitfield -> {
205
	/* Bitfield types */
206
	TYPE sub ;
207
	BASE_TYPE rep ;
208
	NAT size ;
209
	DECL_SPEC info ;
210
    },
211
    promote -> {
212
	/* Promotion types */
213
	INT_TYPE arg ;
214
    },
215
    arith -> {
216
	/* Arithmetic conversion types */
217
	INT_TYPE arg1, arg2 ;
218
    },
219
    literal -> {
220
	/* Target dependent literal type */
221
	NAT nat ;
222
	int spec ;
223
	int form, suff ;
224
	IDENTIFIER tok ;
225
    },
226
    token -> {
227
	/* Tokenised integral type */
228
	IDENTIFIER tok ;
229
	LIST TOKEN args ;
230
    }
231
} ;
232
 
233
 
234
/*
235
    TYPE REPRESENTING A FLOATING POINT TYPE
236
 
237
    A floating point type can be one of the built-in types or an arithmetic
238
    conversion type.  Note that all floating point types are their own
239
    arithmetic promotions, but they do have distinct argument promotions.
240
*/
241
 
242
union FLOAT_TYPE (ftype) = {
243
    TYPE arg_prom ;
244
    ulong_type ftok = "LINK_NONE" ;
245
    ulong_type ntok = "LINK_NONE" ;
246
    ulong_type diag = "LINK_NONE" ;
247
    LIST FLOAT small = "NULL_list ( FLOAT )" ;
248
} + {
249
    basic -> {
250
	/* Built-in types */
251
	BASE_TYPE rep ;
252
	BUILTIN_TYPE no ;
253
    },
254
    arg_promote -> {
255
	/* Argument promotion types */
256
	FLOAT_TYPE arg ;
257
    },
258
    arith -> {
259
	/* Arithmetic conversion types */
260
	FLOAT_TYPE arg1, arg2 ;
261
    },
262
    token -> {
263
	/* Tokenised floating type */
264
	IDENTIFIER tok ;
265
	LIST TOKEN args ;
266
    }
267
} ;
268
 
269
 
270
/*
271
    TYPE REPRESENTING CLASS INFORMATION
272
 
273
    This type is a bitpattern giving information about a class, for example,
274
    if it is complete, whether it has base classes, non-static data members,
275
    and so on.
276
*/
277
 
278
enum !CLASS_INFO (cinfo) = {
279
    none =		0,
280
    complete =		1 << 0,		/* completed definition */
281
    defined =		1 << 1,		/* started definition */
282
    struct_ =		1 << 2,		/* structure class */
283
    union_ =		1 << 3,		/* union class */
284
    template =		1 << 4,		/* template class */
285
    token =		1 << 5,		/* tokenised structure */
286
    pod =		1 << 6,		/* plain ol' data structure */
287
    nested =		1 << 7,		/* is nested class */
288
    rescan =		1 << 8,		/* expands by rescanning */
289
    recursive =		1 << 9,		/* recursively defined */
290
    incomplete =	1 << 10,	/* warn if not completed */
291
    base =		1 << 11,	/* has base class */
292
    multiple_base =	1 << 12,	/* multiple inheritance */
293
    virtual_base =	1 << 13,	/* has virtual base class */
294
    templ_base =	1 << 14,	/* has template base class */
295
    ambiguous =		1 << 15,	/* has ambiguous base class */
296
    empty =		1 << 16,	/* empty class */
297
    private =		1 << 17,	/* non-public data member */
298
    const =		1 << 18,	/* const data member */
299
    static =		1 << 19,	/* static data member */
300
    function =		1 << 20,	/* function member */
301
    params =		1 << 21,	/* layout dependent on parameters */
302
    polymorphic =	1 << 22,	/* virtual function */
303
    poly_base =		1 << 23,	/* polymorphic base class */
304
    abstract =		1 << 24,	/* pure function */
305
    trivial_constr =	1 << 25,	/* trivial constructor */
306
    trivial_destr =	1 << 26,	/* trivial destructor */
307
    trivial_copy =	1 << 27,	/* trivial copy constructor */
308
    trivial_assign =	1 << 28,	/* trivial assign operator */
309
    const_copy =	1 << 29,	/* const copy constructor */
310
    const_assign =	1 << 30,	/* const assign operator */
311
    usr_constr =	1 << 31,	/* user defined constructor */
312
 
313
    key =		struct_ | union_,
314
    non_aggregate =	private | usr_constr | base | polymorphic | token,
315
    force_copy =	static | function | params,
316
    trivial_make =	trivial_constr | trivial_copy | trivial_assign,
317
    trivial =		trivial_make | trivial_destr,
318
    implicit =		trivial | const_copy | const_assign,
319
    default =		implicit | empty | pod
320
} ;
321
 
322
 
323
/*
324
    TYPE REPRESENTING CLASS USAGE INFORMATION
325
 
326
    This type is a bitpattern used to represent information on how a class
327
    is used.
328
*/
329
 
330
enum !CLASS_USAGE (cusage) = {
331
    none =		0,
332
    address =		1 << 0,		/* address of incomplete */
333
    destr =		1 << 1,		/* destroyed incomplete */
334
    delete =		1 << 2,		/* deleted incomplete */
335
    delete_array =	1 << 3		/* deleted incomplete array */
336
} ;
337
 
338
 
339
/*
340
    TYPE REPRESENTING A CLASS TYPE
341
 
342
    A class type has an associated type name, type key (class, struct or
343
    union), and class information.  The hash table entries for the
344
    constructors and destructors, plus a list of the conversion functions
345
    on the class are maintained within the class definition.  The class
346
    members themselves are just a namespace.  The base classes are
347
    represented by a graph.
348
*/
349
 
350
union CLASS_TYPE (ctype) = {
351
    IDENTIFIER name ;
352
    CLASS_INFO info ;
353
    CLASS_USAGE usage ;
354
    NAMESPACE member ;
355
    GRAPH base ;
356
    unsigned no_bases ;
357
    TYPE prev ;
358
    TYPE form = "NULL_type" ;
359
    IDENTIFIER constr = "NULL_id" ;
360
    IDENTIFIER destr = "NULL_id" ;
361
    VIRTUAL virt = "NULL_virt" ;
362
    LIST GRAPH vbase = "NULL_list ( GRAPH )" ;
363
    LIST IDENTIFIER conv = "NULL_list ( IDENTIFIER )" ;
364
    LIST CLASS_TYPE chums = "NULL_list ( CLASS_TYPE )" ;
365
    LIST IDENTIFIER pals = "NULL_list ( IDENTIFIER )" ;
366
    LIST IDENTIFIER nest = "NULL_list ( IDENTIFIER )" ;
367
    ulong_type tok1 = "LINK_NONE" ;
368
    ulong_type tok2 = "LINK_NONE" ;
369
} + {
370
    basic -> {
371
	/* empty */
372
    }
373
} ;
374
 
375
 
376
/*
377
    TYPE REPRESENTING A GRAPH OF DERIVED CLASSES
378
 
379
    This type is used to represent the directed acyclic graphs of base
380
    classes associated with a class.  Each node of this graph consists
381
    of a class and a list of its base classes.  The access of each base
382
    class, and other information, is recorded.  Identical virtual bases
383
    are linked using the equal field.  The next field is used to link
384
    all instances of a class within a graph, whether virtual or not.
385
*/
386
 
387
union GRAPH (graph) = {
388
    CLASS_TYPE head ;
389
    DECL_SPEC access ;
390
    LIST GRAPH tails = "NULL_list ( GRAPH )" ;
391
    GRAPH top = "NULL_graph" ;
392
    GRAPH equal = "NULL_graph" ;
393
    GRAPH up = "NULL_graph" ;
394
    unsigned no = "0" ;
395
    OFFSET off = "NULL_off" ;
396
    LIST IDENTIFIER member = "NULL_list ( IDENTIFIER )" ;
397
    ulong_type tok1 = "LINK_NONE" ;
398
    ulong_type tok2 = "LINK_NONE" ;
399
} + {
400
    basic -> {
401
	/* empty */
402
    }
403
} ;
404
 
405
 
406
/*
407
    TYPE REPRESENTING A VIRTUAL FUNCTION
408
 
409
    This type is used to represent a virtual function table or an entry
410
    of such a table.  Each table entry has an associated function plus
411
    information on where this was inherited from and any difference in
412
    the return type of an overriding function.
413
*/
414
 
415
union VIRTUAL (virt) = {
416
    IDENTIFIER func ;
417
    ulong_type no ;
418
    GRAPH base ;
419
    VIRTUAL next = "NULL_virt" ;
420
} + {
421
    table -> {
422
	/* Virtual function table */
423
	OFFSET off ;
424
	LIST VIRTUAL entries = "NULL_list ( VIRTUAL )" ;
425
	ulong_type tok = "LINK_NONE" ;
426
	ulong_type tbl = "LINK_NONE" ;
427
	ulong_type rtti = "LINK_NONE" ;
428
	int rtti_used = "0" ;
429
    },
430
    simple -> {
431
	/* New virtual function */
432
    },
433
    override -> {
434
	/* Overriding virtual function */
435
	GRAPH ret ;
436
	IDENTIFIER orig ;
437
	GRAPH src ;
438
    },
439
    inherit -> {
440
	/* Inherited primary function */
441
    },
442
    complex -> {
443
	/* Inherited overriding virtual function */
444
	GRAPH ret ;
445
	IDENTIFIER orig ;
446
	GRAPH src ;
447
    },
448
    link -> {
449
	/* Symbolic link */
450
	PTR VIRTUAL to ;
451
    }
452
} ;
453
 
454
 
455
/*
456
    TYPE REPRESENTING AN ENUMERATION TYPE
457
 
458
    An enumeration type has an associated type name, a class information
459
    field (which is only used to indicate whether the type is complete),
460
    and an underlying integral type.  The enumerators themselves are given
461
    as a simple list (note that they do not form a namespace).
462
*/
463
 
464
union ENUM_TYPE (etype) = {
465
    IDENTIFIER name ;
466
    CLASS_INFO info ;
467
    TYPE rep ;
468
    TYPE form = "NULL_type" ;
469
    LIST IDENTIFIER values = "NULL_list ( IDENTIFIER )" ;
470
    EXP value = "NULL_exp" ;
471
    ulong_type plus = "0" ;
472
} + {
473
    basic -> {
474
	/* empty */
475
    }
476
} ;
477
 
478
 
479
/*
480
    TYPE REPRESENTING A TYPE
481
 
482
    The types are represented by a union type, with one field per type
483
    class.  Any type may be qualified using const, volatile and lvalue.
484
*/
485
 
486
union TYPE (type) = {
487
    /* Type qualifiers */
488
    CV_SPEC qual ;
489
    IDENTIFIER name = "NULL_id" ;
490
} + {
491
    pre -> {
492
	/* Pre-types (used during parsing only) */
493
	BASE_TYPE rep ;
494
	QUALIFIER nqual ;
495
    },
496
    integer -> {
497
	/* Integer types */
498
	INT_TYPE rep ;
499
	INT_TYPE sem ;
500
    },
501
    floating -> {
502
	/* Floating point types */
503
	FLOAT_TYPE rep ;
504
	FLOAT_TYPE sem ;
505
    },
506
    top, bottom -> {
507
	/* The void types */
508
    },
509
    ptr, ref -> {
510
	/* Pointer and reference types */
511
	TYPE sub ;
512
    },
513
    ptr_mem -> {
514
	/* Pointer to member types */
515
	CLASS_TYPE of ;
516
	TYPE sub ;
517
    },
518
    func -> {
519
	/* Function types */
520
	TYPE ret ;
521
	LIST TYPE ptypes ;
522
	int ellipsis ;
523
	CV_SPEC mqual ;
524
	LIST TYPE mtypes ;
525
	NAMESPACE pars ;
526
	LIST IDENTIFIER pids ;
527
	LIST TYPE except ;
528
    },
529
    array -> {
530
	/* Array types */
531
	TYPE sub ;
532
	NAT size ;
533
    },
534
    bitfield -> {
535
	/* Bitfield types */
536
	INT_TYPE defn ;
537
    },
538
    compound -> {
539
	/* Class types */
540
	CLASS_TYPE defn ;
541
    },
542
    enumerate -> {
543
	/* Enumeration types */
544
	ENUM_TYPE defn ;
545
    },
546
    token -> {
547
	/* Tokenised type */
548
	IDENTIFIER tok ;
549
	LIST TOKEN args ;
550
	INSTANCE app = "NULL_inst" ;
551
    },
552
    templ -> {
553
	/* Template type */
554
	TOKEN sort ;
555
	TYPE defn ;
556
	int fix ;
557
    },
558
    instance -> {
559
	/* Template member type */
560
	IDENTIFIER id ;
561
	DECL_SPEC access ;
562
    },
563
    dummy -> {
564
	/* Dummy special token type */
565
	int tok ;
566
    },
567
    error -> {
568
	/* Error propagation type */
569
    }
570
} ;
571
 
572
 
573
/*
574
    TYPE REPRESENTING A DECLARATION SPECIFIER
575
 
576
    The basic declaration specifiers (i.e. the storage class specifiers,
577
    the function specifiers, friend and typedef) are represented by an
578
    enumeration type (which is actually a bit pattern).  Other declaration
579
    and linkage information is also included, including access specifiers.
580
    The fact that public < protected < private is used extensively.  The
581
    values none, static and extern are also used to specify the linkage of
582
    an object.
583
*/
584
 
585
enum DECL_SPEC (dspec) = {
586
    none =		0,
587
    used =		1 << 0,
588
    called =		1 << 1,
589
    defn =		1 << 2,
590
    inherit =		1 << 3,
591
    alias =		1 << 4,
592
    done =		1 << 5,
593
 
594
    static =		1 << 6,
595
    extern =		1 << 7,
596
    auto =		1 << 8,
597
    register =		1 << 9,
598
    mutable =		1 << 10,
599
    inline =		1 << 11,
600
    virtual =		1 << 12,
601
    explicit =		1 << 13,
602
    friend =		1 << 14,
603
    typedef =		1 << 15,
604
 
605
    public =		1 << 16,
606
    protected =		2 << 16,
607
    private =		3 << 16,
608
 
609
    public2 =		public << 2,
610
    protected2 =	protected << 2,
611
    private2 =		private << 2,
612
 
613
    c =			1 << 20,
614
    cpp =		1 << 21,
615
 
616
    ignore =		1 << 22,
617
    implicit =		1 << 23,
618
    instance =		1 << 24,
619
    main =		1 << 25,
620
    pure =		1 << 26,
621
    reserve =		1 << 27,
622
    temp =		1 << 28,
623
    template =		1 << 29,
624
    token =		1 << 30,
625
    trivial =		1 << 31,
626
 
627
    linkage =		static | extern,
628
    storage =		static | extern | auto | register | mutable,
629
    function =		inline | virtual | explicit,
630
    keyword =		storage | function | friend | typedef,
631
    duplicate =		keyword,
632
    access =		public | protected | private,
633
    access2 =		public2 | protected2 | private2,
634
    language =		c | cpp,
635
    other =		ignore | implicit | instance | main | pure |
636
			reserve | temp | template | token | trivial
637
} ;
638
 
639
 
640
/*
641
    TYPE REPRESENTING A HASH TABLE ENTRY
642
 
643
    Identifier names are represented by a hash table entry.  There are
644
    several different types of names (simp1e strings, destructor names and
645
    so on).  Each hash table entry contains, in effect, a built-in namespace
646
    member indicating the underlying meaning of this name.  It also contains
647
    the hash value for this entry.
648
*/
649
 
650
union HASHID (hashid) = {
651
    IDENTIFIER id = "NULL_id" ;
652
    IDENTIFIER cache = "NULL_id" ;
653
    HASHID next ;
654
    ulong_type hash ;
655
} + {
656
    name, ename -> {
657
	/* Simple and extended identifiers */
658
	string text ;
659
    },
660
    constr, destr, conv -> {
661
	/* Constructors, destructors and conversion functions */
662
	TYPE type ;
663
	IDENTIFIER tid ;
664
    },
665
    op -> {
666
	/* Overloaded operator name */
667
	int lex ;
668
    },
669
    anon -> {
670
	/* Unnamed identifier */
671
	ulong_type uniq ;
672
    }
673
} ;
674
 
675
 
676
/*
677
    TYPE REPRESENTING AN IDENTIFIER QUALIFIER
678
 
679
    These values are used to identify how an identifier is qualified,
680
    either unqualified, a nested qualifier (for example A::B::n), a full
681
    nested qualifier (for example ::A::B::n), or a top nested qualifier
682
    (for example ::n).  A value to mark resolved overloaded functions
683
    is also included.
684
*/
685
 
686
enum !QUALIFIER (qual) = {
687
    none =		0,
688
    nested =		1,
689
    full =		2,
690
    top =		3,
691
    mark =		4,
692
    explicit =		nested | full | top
693
} ;
694
 
695
 
696
/*
697
    TYPE REPRESENTING AN IDENTIFIER
698
 
699
    Identifiers have an associated hash table entry, indicating the
700
    identifier name, plus a location indicating where the identifier was
701
    first declared.  The various things an identifier can represent are
702
    given by the different fields of the union.
703
*/
704
 
705
union IDENTIFIER (id) = {
706
    HASHID name ;
707
    DECL_SPEC storage ;
708
    NAMESPACE parent ;
709
    LOCATION loc ;
710
    IDENTIFIER alias = "%0" ;
711
    ulong_type no = "LINK_NONE" ;
712
    ulong_type dump = "LINK_NONE" ;
713
} + {
714
    dummy -> {
715
	/* Undefined identifier */
716
    },
717
    keyword, iso_keyword, reserved -> {
718
	/* Keywords */
719
    },
720
    builtin -> {
721
	/* Built-in operators */
722
	TYPE ret ;
723
	LIST TYPE ptypes ;
724
    },
725
    obj_macro -> {
726
	/* Object-like macros */
727
	PPTOKEN_P defn ;
728
    },
729
    func_macro -> {
730
	/* Function-like macros */
731
	PPTOKEN_P defn ;
732
	LIST HASHID params ;
733
	unsigned no_params ;
734
    },
735
    predicate -> {
736
	/* Predicates */
737
	LIST PPTOKEN_P values = "NULL_list ( PPTOKEN_P )" ;
738
    },
739
    class_name, enum_name,
740
    class_alias, enum_alias, type_alias -> {
741
	/* Type names */
742
	TYPE defn ;
743
	BASE_TYPE rep = "btype_none" ;
744
    },
745
    nspace_name, nspace_alias -> {
746
	/* Namespace names */
747
	NAMESPACE defn ;
748
    },
749
    variable, parameter, stat_member -> {
750
	/* Variables (including static members) */
751
	TYPE type ;
752
	EXP init = "NULL_exp" ;
753
	EXP term = "NULL_exp" ;
754
    },
755
    weak_param -> {
756
	/* Non-prototype function parameters */
757
    },
758
    function, mem_func, stat_mem_func -> {
759
	/* Functions (including member functions) */
760
	TYPE type ;
761
	IDENTIFIER over ;
762
	TYPE form = "NULL_type" ;
763
	LIST CLASS_TYPE chums = "NULL_list ( CLASS_TYPE )" ;
764
	EXP defn = "NULL_exp" ;
765
    },
766
    member -> {
767
	/* Simple data member */
768
	TYPE type ;
769
	OFFSET off = "NULL_off" ;
770
	GRAPH base = "NULL_graph" ;
771
    },
772
    enumerator -> {
773
	/* Enumerators */
774
	TYPE etype ;
775
	EXP value ;
776
    },
777
    label -> {
778
	/* Labels */
779
	int op ;
780
	EXP stmt = "NULL_exp" ;
781
	EXP gotos = "NULL_exp" ;
782
	LIST VARIABLE vars = "NULL_list ( VARIABLE )" ;
783
    },
784
    token -> {
785
	/* Tokens */
786
	TOKEN sort ;
787
	IDENTIFIER alt ;
788
    },
789
    ambig -> {
790
	/* Ambiguous identifier */
791
	LIST IDENTIFIER ids ;
792
	int over ;
793
    },
794
    undef -> {
795
	/* Undefined identifier */
796
	TYPE form = "NULL_type" ;
797
    },
798
    pending -> {
799
	/* Pending identifier (used in spec input) */
800
	unsigned itag ;
801
	TYPE type ;
802
    }
803
} ;
804
 
805
 
806
/*
807
    TYPE REPRESENTING A NAMESPACE MEMBER
808
 
809
    There are two kinds of namespace member, small and large, corresponding
810
    to the two kinds of namespace.  The important section consists of two
811
    identifiers, giving the current meanings of a name in the namespace.
812
    Everything else is just links to other members.
813
*/
814
 
815
union MEMBER (member) = {
816
    IDENTIFIER id = "NULL_id" ;
817
    IDENTIFIER alt = "NULL_id" ;
818
    MEMBER next ;
819
} + {
820
    small -> {
821
	/* empty */
822
    },
823
    large -> {
824
	MEMBER tnext ;
825
    }
826
} ;
827
 
828
 
829
/*
830
    TYPE REPRESENTING A NAMESPACE
831
 
832
    There are two kinds of namespace, small and large.  The small namespaces
833
    are the block and parameter spaces, the large ones are the class and
834
    namespace spaces.  Every namespace has an associated namespace name
835
    (which may be the null identifier).  A small namespace consists of a
836
    simple linked list of small members (in reverse order of declaration).
837
    A large namespace consists of a hash table of large members, plus a list
838
    of all such members in order of declaration.  The distinct orders reflect
839
    the distinct purposes the two kinds of namespace are put to.
840
*/
841
 
842
union NAMESPACE (nspace) = {
843
    IDENTIFIER name ;
844
    MEMBER last = "NULL_member" ;
845
    MEMBER prev = "NULL_member" ;
846
    NAMESPACE parent ;
847
    LIST NAMESPACE use = "NULL_list ( NAMESPACE )" ;
848
    LIST NAMESPACE join = "NULL_list ( NAMESPACE )" ;
849
    STACK IDENTIFIER set = "NULL_stack ( IDENTIFIER )" ;
850
    ulong_type dump = "LINK_NONE" ;
851
} + {
852
    block, param, dummy, label, templ -> {
853
	/* Member list */
854
    },
855
    named, unnamed, global, ctype -> {
856
	/* Member hash table */
857
	MEMBER first = "NULL_member" ;
858
	LIST IDENTIFIER extra = "NULL_list ( IDENTIFIER )" ;
859
	ulong_type size ;
860
	PTR MEMBER table ;
861
    }
862
} ;
863
 
864
 
865
/*
866
    TYPE REPRESENTING AN INTEGER LITERAL
867
 
868
    An integer literal (or constant integral expression) is represented by
869
    a sign and a list of numbers in the range [0,0xffff] representing the
870
    value base 0x10000.  The case where there is only one digit is dealt
871
    with separately.  It is also possible to form an integer literal from
872
    an expression.
873
*/
874
 
875
union NAT (nat) = {
876
    /* empty */
877
} + {
878
    small -> {
879
	/* Single digit */
880
	unsigned value ;
881
    },
882
    large -> {
883
	/* Multiple digits */
884
	LIST unsigned values ;
885
    },
886
    calc -> {
887
	/* Calculated value */
888
	EXP value ;
889
	ulong_type tok = "LINK_NONE" ;
890
    },
891
    neg -> {
892
	/* Negation */
893
	NAT arg ;
894
    },
895
    token -> {
896
	/* Tokenised expression */
897
	IDENTIFIER tok ;
898
	LIST TOKEN args ;
899
    }
900
} ;
901
 
902
 
903
/*
904
    TYPE REPRESENTING A FLOATING POINT LITERAL
905
 
906
    A floating point literal is represented by a sign, two strings giving
907
    the digits before and after the decimal point, plus an exponent.
908
*/
909
 
910
union FLOAT (flt) = {
911
    ulong_type tok = "LINK_NONE" ;
912
} + {
913
    simple -> {
914
	/* Simple literal */
915
	string int_part ;
916
	string frac_part ;
917
	NAT exponent ;
918
    }
919
} ;
920
 
921
 
922
/*
923
    TYPE REPRESENTING A STRING LITERAL
924
 
925
    A string literal consists of a sequence of characters of a given length.
926
    Characters, wide characters, strings and wide strings are represented
927
    by distinct fields of the union.
928
*/
929
 
930
union STRING (str) = {
931
    STRING next = "NULL_str" ;
932
} + {
933
    simple -> {
934
	/* Simple literals */
935
	ulong_type len ;
936
	string text ;
937
	unsigned kind ;
938
	ulong_type tok = "LINK_NONE" ;
939
    }
940
} ;
941
 
942
 
943
/*
944
    TYPE REPRESENTING A TEST
945
 
946
    Test and comparison operators are represented by an enumeration type
947
    which happen to be in the same order as the TDF encoding.  Complementary
948
    tests (for example '<' and '>=') always add up to the same value, negate.
949
*/
950
 
951
enum !NTEST (ntest) = {
952
    eq =		0,
953
    greater =		1,
954
    greater_eq =	2,
955
    less =		3,
956
    less_eq =		4,
957
    not_eq =		5,
958
    not_greater =	6,
959
    not_greater_eq =	7,
960
    not_less =		8,
961
    not_less_eq =	9,
962
    not_not_eq =	10,
963
    none =		11,
964
    negate =		eq + not_eq,
965
    not =		not_eq,
966
    not_not =		not_not_eq
967
} ;
968
 
969
 
970
/*
971
    TYPE REPRESENTING A ROUNDING MODE
972
 
973
    Floating point rounding modes are represented by an enumeration type
974
    which happen to be in the same order as the TDF encoding.
975
*/
976
 
977
enum !RMODE (rmode) = {
978
    as_state =		0,
979
    to_nearest =	1,
980
    to_larger =		2,
981
    to_smaller =	3,
982
    to_zero =		4
983
} ;
984
 
985
 
986
/*
987
    TYPE REPRESENTING AN EXPRESSION OR STATEMENT
988
 
989
    The expressions and statements are represented by a union type, with one
990
    field per expression or statement class.  Every expression has an
991
    associated type.
992
*/
993
 
994
union EXP (exp) = {
995
    /* Expression type */
996
    TYPE type ;
997
} + {
998
    identifier, member, ambiguous, undeclared -> {
999
	/* Identifiers */
1000
	IDENTIFIER id ;
1001
	QUALIFIER qual ;
1002
    },
1003
    int_lit -> {
1004
	/* Integer literal */
1005
	NAT nat ;
1006
	unsigned etag ;
1007
    },
1008
    float_lit -> {
1009
	/* Floating point literal */
1010
	FLOAT flt ;
1011
    },
1012
    char_lit -> {
1013
	/* Character literal */
1014
	STRING str ;
1015
	int digit ;
1016
    },
1017
    string_lit -> {
1018
	/* String literal */
1019
	STRING str ;
1020
    },
1021
    value -> {
1022
	/* Undefined value */
1023
    },
1024
    null, zero -> {
1025
	/* Null value (null pointer, zero etc.) */
1026
    },
1027
    paren, copy -> {
1028
	/* Identity operation (used for parentheses) */
1029
	EXP arg ;
1030
    },
1031
    assign -> {
1032
	/* Assignment */
1033
	EXP ref, arg ;
1034
    },
1035
    init -> {
1036
	/* Initialisation */
1037
	IDENTIFIER id ;
1038
	EXP arg ;
1039
    },
1040
    preinc -> {
1041
	/* Pre-increment */
1042
	EXP ref, op ;
1043
	int becomes ;
1044
    },
1045
    postinc -> {
1046
	/* Post-increment */
1047
	EXP ref, value, op ;
1048
    },
1049
    indir -> {
1050
	/* Indirection */
1051
	EXP ptr ;
1052
	int index = "0" ;
1053
    },
1054
    contents -> {
1055
	/* Contents */
1056
	EXP ptr ;
1057
    },
1058
    address -> {
1059
	/* Address of an object */
1060
	EXP arg ;
1061
    },
1062
    address_mem -> {
1063
	/* Address of a member */
1064
	EXP arg ;
1065
	int paren ;
1066
    },
1067
    func -> {
1068
	/* Function call */
1069
	EXP fn ;
1070
	LIST EXP args ;
1071
	unsigned extra = "0" ;
1072
    },
1073
    func_id -> {
1074
	/* Named function call */
1075
	IDENTIFIER id ;
1076
	LIST EXP args ;
1077
	EXP virt ;
1078
	unsigned extra = "0" ;
1079
    },
1080
    call -> {
1081
	/* Member function call */
1082
	EXP ptr, arg ;
1083
	GRAPH base ;
1084
    },
1085
    negate, compl, not, abs -> {
1086
	/* Simple unary operations */
1087
	EXP arg ;
1088
    },
1089
    plus, minus, mult, div, rem,
1090
    and, or, xor, log_and, log_or,
1091
    lshift, rshift, max, min -> {
1092
	/* Simple binary operations */
1093
	EXP arg1, arg2 ;
1094
    },
1095
    test -> {
1096
	/* Compare against null value */
1097
	NTEST tst ;
1098
	EXP arg ;
1099
    },
1100
    compare -> {
1101
	/* Compare two values */
1102
	NTEST tst ;
1103
	EXP arg1, arg2 ;
1104
    },
1105
    cast -> {
1106
	/* Casts */
1107
	unsigned conv ;
1108
	EXP arg ;
1109
    },
1110
    base_cast -> {
1111
	/* Base class conversion */
1112
	unsigned conv ;
1113
	EXP arg ;
1114
	OFFSET off ;
1115
    },
1116
    dyn_cast -> {
1117
	/* Dynamic cast */
1118
	EXP arg ;
1119
	EXP except ;
1120
    },
1121
    add_ptr -> {
1122
	/* Add a value to a pointer */
1123
	EXP ptr ;
1124
	OFFSET off ;
1125
	int virt ;
1126
    },
1127
    offset_size -> {
1128
	/* Size of offset */
1129
	OFFSET off ;
1130
	TYPE step ;
1131
	int pad ;
1132
    },
1133
    constr -> {
1134
	/* Constructor call */
1135
	EXP call, obj, alt ;
1136
	int info ;
1137
    },
1138
    destr -> {
1139
	/* Destructor call */
1140
	EXP call, obj ;
1141
	EXP count = "NULL_exp" ;
1142
    },
1143
    alloc -> {
1144
	/* Allocator call */
1145
	EXP call, init ;
1146
	EXP garbage, size ;
1147
    },
1148
    dealloc -> {
1149
	/* Deallocator call */
1150
	EXP term, call ;
1151
	EXP arg, size ;
1152
    },
1153
    rtti -> {
1154
	/* Run-time type information */
1155
	EXP arg ;
1156
	EXP except ;
1157
	int op ;
1158
    },
1159
    rtti_type -> {
1160
	/* Run-time type information */
1161
	TYPE arg ;
1162
	int op ;
1163
    },
1164
    rtti_no -> {
1165
	/* Arithmetic type number */
1166
	TYPE arg ;
1167
    },
1168
    dynamic -> {
1169
	/* Dynamic initialiser */
1170
	EXP arg ;
1171
    },
1172
    aggregate -> {
1173
	/* Aggregate initialisers */
1174
	LIST EXP args ;
1175
	LIST OFFSET offs ;
1176
    },
1177
    initialiser -> {
1178
	/* Compound initialisers */
1179
	LIST EXP args ;
1180
	LIST OFFSET offs ;
1181
	int kind ;
1182
	unsigned virt, base ;
1183
    },
1184
    nof -> {
1185
	/* Array initialisers */
1186
	EXP start ;
1187
	NAT size ;
1188
	EXP pad ;
1189
	EXP end ;
1190
    },
1191
    comma -> {
1192
	/* Comma operator */
1193
	LIST EXP args ;
1194
    },
1195
    set, unused -> {
1196
	/* Variable analysis operators */
1197
	EXP arg ;
1198
    },
1199
    reach, unreach -> {
1200
	/* Flow analysis operators */
1201
	EXP parent = "NULL_exp" ;
1202
	EXP body ;
1203
    },
1204
    sequence -> {
1205
	/* Sequence of statements */
1206
	EXP parent = "NULL_exp" ;
1207
	LIST EXP first, last ;
1208
	NAMESPACE decl ;
1209
	int block ;
1210
    },
1211
    solve_stmt -> {
1212
	/* Label complex */
1213
	EXP parent = "NULL_exp" ;
1214
	EXP body ;
1215
	LIST IDENTIFIER labels = "NULL_list ( IDENTIFIER )" ;
1216
	LIST IDENTIFIER vars = "NULL_list ( IDENTIFIER )" ;
1217
    },
1218
    decl_stmt -> {
1219
	/* Declaration statement */
1220
	EXP parent = "NULL_exp" ;
1221
	IDENTIFIER id ;
1222
	EXP body ;
1223
    },
1224
    if_stmt -> {
1225
	/* If statement */
1226
	EXP parent = "NULL_exp" ;
1227
	EXP cond ;
1228
	EXP true_code, false_code ;
1229
	IDENTIFIER label ;
1230
    },
1231
    while_stmt -> {
1232
	/* While and for statements */
1233
	EXP parent = "NULL_exp" ;
1234
	EXP cond ;
1235
	EXP body = "NULL_exp" ;
1236
	IDENTIFIER break_lab ;
1237
	IDENTIFIER cont_lab ;
1238
	IDENTIFIER loop_lab ;
1239
	LIST IDENTIFIER cond_id = "NULL_list ( IDENTIFIER )" ;
1240
    },
1241
    do_stmt -> {
1242
	/* Do statements */
1243
	EXP parent = "NULL_exp" ;
1244
	EXP cond ;
1245
	EXP body = "NULL_exp" ;
1246
	IDENTIFIER break_lab ;
1247
	IDENTIFIER cont_lab ;
1248
	IDENTIFIER loop_lab ;
1249
    },
1250
    switch_stmt -> {
1251
	/* Switch statement */
1252
	EXP parent = "NULL_exp" ;
1253
	EXP control ;
1254
	EXP body ;
1255
	LIST NAT cases = "NULL_list ( NAT )" ;
1256
	LIST IDENTIFIER case_labs = "NULL_list ( IDENTIFIER )" ;
1257
	IDENTIFIER default_lab = "NULL_id" ;
1258
	int exhaust ;
1259
	IDENTIFIER break_lab ;
1260
    },
1261
    hash_if -> {
1262
	/* #if statement */
1263
	EXP parent = "NULL_exp" ;
1264
	EXP cond ;
1265
	EXP true_code, false_code ;
1266
	EXP last = "NULL_exp" ;
1267
    },
1268
    return_stmt -> {
1269
	/* Return statement */
1270
	EXP parent = "NULL_exp" ;
1271
	EXP value ;
1272
    },
1273
    goto_stmt -> {
1274
	/* Goto statement (including break and continue statements) */
1275
	EXP parent = "NULL_exp" ;
1276
	IDENTIFIER label ;
1277
	EXP join ;
1278
	EXP next ;
1279
    },
1280
    label_stmt -> {
1281
	/* Labelled statement (including case and default statements) */
1282
	EXP parent = "NULL_exp" ;
1283
	IDENTIFIER label ;
1284
	EXP body ;
1285
	IDENTIFIER next = "NULL_id" ;
1286
    },
1287
    try_block -> {
1288
	/* Try block */
1289
	EXP parent = "NULL_exp" ;
1290
	EXP body ;
1291
	int func ;
1292
	LIST EXP handlers = "NULL_list ( EXP )" ;
1293
	LIST TYPE htypes = "NULL_list ( TYPE )" ;
1294
	EXP ellipsis = "NULL_exp" ;
1295
	LIST TYPE ttypes = "NULL_list ( TYPE )" ;
1296
	LIST LOCATION tlocs = "NULL_list ( LOCATION )" ;
1297
	ulong_type no = "LINK_NONE" ;
1298
    },
1299
    handler -> {
1300
	/* Exception handler */
1301
	EXP parent = "NULL_exp" ;
1302
	IDENTIFIER except ;
1303
	EXP body ;
1304
	ulong_type diag = "LINK_NONE" ;
1305
    },
1306
    exception -> {
1307
	/* Throw expression */
1308
	EXP arg ;
1309
	EXP size, destr ;
1310
	int expl ;
1311
    },
1312
    thrown -> {
1313
	/* Caught expression */
1314
	int done ;
1315
    },
1316
    op -> {
1317
	/* Undetermined operation */
1318
	int lex ;
1319
	EXP arg1, arg2 ;
1320
    },
1321
    opn -> {
1322
	/* Undetermined operation */
1323
	int lex ;
1324
	LIST EXP args ;
1325
    },
1326
    assembler -> {
1327
	/* asm expression */
1328
	STRING op ;
1329
	LIST EXP args ;
1330
    },
1331
    uncompiled -> {
1332
	/* Uncompiled expression */
1333
	LOCATION start ;
1334
	PPTOKEN_P defn ;
1335
    },
1336
    location -> {
1337
	/* Location expression */
1338
	LOCATION end ;
1339
	EXP arg ;
1340
    },
1341
    fail -> {
1342
	/* Install-time failure */
1343
	string msg ;
1344
    },
1345
    token -> {
1346
	/* Tokenised expression */
1347
	EXP parent = "NULL_exp" ;
1348
	IDENTIFIER tok ;
1349
	LIST TOKEN args ;
1350
    },
1351
    dummy -> {
1352
	/* Dummy expression */
1353
	EXP value ;
1354
	ulong_type no ;
1355
	OFFSET off ;
1356
	int virt = "0" ;
1357
	int cont ;
1358
    }
1359
} ;
1360
 
1361
 
1362
/*
1363
    TYPE REPRESENTING AN OFFSET
1364
 
1365
    This type is used to represent an offset between two pointers.  The
1366
    type construct gives the offset between successive elements of an
1367
    array of that type.  The other constructs are fairly obvious.
1368
*/
1369
 
1370
union OFFSET (off) = {
1371
    /* empty */
1372
} + {
1373
    zero -> {
1374
	/* Zero offset */
1375
	TYPE type ;
1376
    },
1377
    type -> {
1378
	/* Type offset */
1379
	TYPE type ;
1380
    },
1381
    array -> {
1382
	/* Array offset */
1383
	TYPE type ;
1384
	unsigned arg ;
1385
    },
1386
    extra -> {
1387
	/* Extra offset for array allocator */
1388
	TYPE type ;
1389
	int scale ;
1390
    },
1391
    base -> {
1392
	/* Base class offset */
1393
	GRAPH graph ;
1394
    },
1395
    deriv -> {
1396
	/* Derived class offset */
1397
	GRAPH graph ;
1398
	OFFSET direct ;
1399
	OFFSET indirect ;
1400
    },
1401
    member -> {
1402
	/* Member offset */
1403
	IDENTIFIER id ;
1404
    },
1405
    ptr_mem -> {
1406
	/* Pointer member offset */
1407
	EXP arg ;
1408
    },
1409
    negate -> {
1410
	/* Offset negation */
1411
	OFFSET arg ;
1412
    },
1413
    plus -> {
1414
	/* Offset addition */
1415
	OFFSET arg1, arg2 ;
1416
    },
1417
    mult -> {
1418
	/* Offset multiplication */
1419
	OFFSET arg1 ;
1420
	EXP arg2 ;
1421
    },
1422
    ptr_diff -> {
1423
	/* Pointer difference */
1424
	EXP ptr1, ptr2 ;
1425
    },
1426
    token -> {
1427
	/* Tokenised offset */
1428
	IDENTIFIER tok ;
1429
	LIST TOKEN args ;
1430
    }
1431
} ;
1432
 
1433
 
1434
/*
1435
    TYPE REPRESENTING A TOKEN
1436
 
1437
    This type is used to represent a TDF token.  The various fields
1438
    correspond to the kinds of token - expressions, statements, types etc.
1439
    Each simple component also contains a field for holding a value of
1440
    that kind, thus a list of token arguments can themselves be expressed
1441
    as a list of tokens.
1442
*/
1443
 
1444
union TOKEN (tok) = {
1445
    /* empty */
1446
} + {
1447
    exp -> {
1448
	/* Expression tokens */
1449
	TYPE type ;
1450
	int constant ;
1451
	EXP value ;
1452
    },
1453
    stmt -> {
1454
	/* Statement tokens */
1455
	EXP value ;
1456
    },
1457
    nat, snat -> {
1458
	/* Integer constant tokens */
1459
	NAT value ;
1460
    },
1461
    type -> {
1462
	/* Type tokens */
1463
	BASE_TYPE kind ;
1464
	TYPE value ;
1465
	TYPE alt = "NULL_type" ;
1466
    },
1467
    func -> {
1468
	/* Function tokens */
1469
	TYPE type ;
1470
	IDENTIFIER defn = "NULL_id" ;
1471
	TOKEN proc = "NULL_tok" ;
1472
    },
1473
    member -> {
1474
	/* Class member tokens */
1475
	TYPE of ;
1476
	TYPE type ;
1477
	OFFSET value ;
1478
    },
1479
    class -> {
1480
	/* Template class tokens */
1481
	TYPE type ;
1482
	IDENTIFIER value ;
1483
	TYPE alt = "NULL_type" ;
1484
    },
1485
    proc -> {
1486
	/* Procedure tokens */
1487
	TOKEN res ;
1488
	NAMESPACE pars ;
1489
	int key ;
1490
	INSTANCE apps = "NULL_inst" ;
1491
	LIST IDENTIFIER bids = "NULL_list ( IDENTIFIER )" ;
1492
	LIST IDENTIFIER pids = "NULL_list ( IDENTIFIER )" ;
1493
    },
1494
    templ -> {
1495
	/* Template tokens */
1496
	DECL_SPEC usage ;
1497
	NAMESPACE pars ;
1498
	INSTANCE apps = "NULL_inst" ;
1499
	LIST IDENTIFIER pids = "NULL_list ( IDENTIFIER )" ;
1500
	LIST TOKEN dargs = "NULL_list ( TOKEN )" ;
1501
    }
1502
} ;
1503
 
1504
 
1505
/*
1506
    TYPE REPRESENTING A TEMPLATE INSTANCE
1507
 
1508
    A template instance consists of an identifier, a type giving the
1509
    template form and a specifier giving declaration information.
1510
*/
1511
 
1512
union INSTANCE (inst) = {
1513
    TYPE form ;
1514
    INSTANCE alias = "%0" ;
1515
    INSTANCE next ;
1516
} + {
1517
    templ -> {
1518
	/* Template instance */
1519
	IDENTIFIER id ;
1520
	TYPE spec = "NULL_type" ;
1521
	DECL_SPEC access ;
1522
	PPTOKEN_P mode = "NULL" ;
1523
	LIST IDENTIFIER mems = "NULL_list ( IDENTIFIER )" ;
1524
	INSTANCE prev ;
1525
    },
1526
    token -> {
1527
	/* Token type instance */
1528
	ulong_type no = "LINK_NONE" ;
1529
    }
1530
} ;
1531
 
1532
 
1533
/*
1534
    TYPE REPRESENTING A VARIABLE ANALYSIS STATE
1535
 
1536
    This type is used in the variable analysis routines to record the
1537
    state of a local variable.
1538
*/
1539
 
1540
struct VARIABLE (var) = {
1541
    IDENTIFIER id ;
1542
    DECL_SPEC info ;
1543
} ;
1544
 
1545
 
1546
/*
1547
    TYPE REPRESENTING AN ERROR
1548
 
1549
    An error can be either a simple message, described by an error number,
1550
    or a compound formed from two other errors.  Some trickery is used to
1551
    store the arguments for a simple error after its size field.
1552
*/
1553
 
1554
union ERROR (err) = {
1555
    int severity ;
1556
} + {
1557
    simple -> {
1558
	/* Simple errors */
1559
	int number ;
1560
	unsigned size = "0" ;
1561
	/* arguments ... */
1562
    },
1563
    compound -> {
1564
	/* Compound errors */
1565
	ERROR head, tail ;
1566
    }
1567
} ;
1568
 
1569
 
1570
/*
1571
    TYPE REPRESENTING A FILE POSITION
1572
 
1573
    A file position consists of a line number plus a pointer to a type
1574
    giving the file name.
1575
*/
1576
 
1577
struct LOCATION (loc) = {
1578
    ulong_type line ;
1579
    ulong_type column ;
1580
    PTR POSITION posn ;
1581
} ;
1582
 
1583
struct POSITION (posn) = {
1584
    string file ;
1585
    string input ;
1586
    string base ;
1587
    string dir ;
1588
    ulong_type offset ;
1589
    PTR LOCATION from ;
1590
    ulong_type datestamp ;
1591
    ulong_type tok = "LINK_NONE" ;
1592
} ;