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
/*
7 7u83 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
 */
31
/*
2 7u83 32
    		 Crown Copyright (c) 1997
7 7u83 33
 
2 7u83 34
    This TenDRA(r) Computer Program is subject to Copyright
35
    owned by the United Kingdom Secretary of State for Defence
36
    acting through the Defence Evaluation and Research Agency
37
    (DERA).  It is made available to Recipients with a
38
    royalty-free licence for its use, reproduction, transfer
39
    to other parties and amendment for any purpose not excluding
40
    product development provided that any such use et cetera
41
    shall be deemed to be acceptance of the following conditions:-
7 7u83 42
 
2 7u83 43
        (1) Its Recipients shall ensure that this Notice is
44
        reproduced upon any copies or amended versions of it;
7 7u83 45
 
2 7u83 46
        (2) Any amended version of it shall be clearly marked to
47
        show both the nature of and the organisation responsible
48
        for the relevant amendment or amendments;
7 7u83 49
 
2 7u83 50
        (3) Its onward transfer from a recipient to another
51
        party shall be deemed to be that party's acceptance of
52
        these conditions;
7 7u83 53
 
2 7u83 54
        (4) DERA gives no warranty or assurance as to its
55
        quality or suitability for any purpose and DERA accepts
56
        no liability whatsoever in relation to any use to which
57
        it may be put.
58
*/
59
 
60
 
61
#ifndef TYPES_INCLUDED
62
#define TYPES_INCLUDED
63
 
64
 
65
/*
66
    ELEMENTARY TYPES
67
 
68
    The types boolean, byte and pointer are defined.
69
*/
70
 
7 7u83 71
typedef char boolean;
72
typedef unsigned char byte;
73
typedef void *pointer;
2 7u83 74
 
75
 
76
/*
77
    FORWARD STRUCTURE DECLARATION
78
 
79
    The structure representing a TDF construct is defined recursively.
80
*/
81
 
7 7u83 82
struct x_construct;
2 7u83 83
 
84
 
85
/*
86
    TYPE REPRESENTING A SORT NAME
87
 
88
    Each TDF construct has an associated sort.  This is represented
89
    by a value of type sortname.  It can take any of the values of
90
    the form sort_* in tags.h.
91
*/
92
 
7 7u83 93
typedef int sortname;
2 7u83 94
 
95
 
96
/*
97
    TYPE REPRESENTING A TREE NODE
98
 
99
    TDF is represented as a tree structure.  Each node has a corresponding
100
    construct given by the cons field.  The son and bro fields give the
101
    tree its structure.  For shape checking there is also a shape field
102
    which is itself a node.
103
*/
104
 
105
typedef struct x_node {
7 7u83 106
    struct x_construct *cons;
107
    struct x_node *son;
108
    struct x_node *bro;
109
    struct x_node *shape;
110
} node;
2 7u83 111
 
112
 
113
/*
114
    TYPE REPRESENTING AN ALIGNMENT TAG
115
 
116
    The only information required about an alignment tag is its
117
    definition (if any).
118
*/
119
 
120
typedef struct x_al_tag_info {
7 7u83 121
    node *def;
122
} al_tag_info;
2 7u83 123
 
124
 
125
/*
126
    TYPE REPRESENTING A TAG
127
 
128
    A tag may be a variable or identity (indicated by the var field).
129
    It may also be declared and defined.  The vis field is used to
130
    try to catch variables declared with visible access.
131
*/
132
 
133
typedef struct x_tag_info {
7 7u83 134
    boolean var;
135
    boolean vis;
136
    node *dec;
137
    node *def;
138
} tag_info;
2 7u83 139
 
140
 
141
/*
142
    TYPE REPRESENTING A TOKEN
143
 
144
    A token may be declared or defined.  Its result sort is represented
145
    by the res field, and its argument sorts by the args field.  The
146
    formal parameters for a defined token are given as an array of
147
    constructs by the pars field.
148
*/
149
 
150
typedef struct x_tok_info {
7 7u83 151
    boolean dec;
152
    sortname res;
153
    char *args;
154
    node *sig;
155
    node *def;
156
    int depth;
157
    struct x_construct **pars;
158
} tok_info;
2 7u83 159
 
160
 
161
/*
162
    TYPE REPRESENTING A TDF CONSTRUCT
163
 
164
    A TDF construct (including user defined tokens and tags as well
165
    as the base constructs) is represented by the type construct.
166
    This consists of its sort, sortnum, its encoding, its internal
167
    and external names, plus space for extra information depending
168
    on its sort.  The next field enables us to form constructs into
169
    lists.
170
*/
171
 
172
typedef struct x_construct {
7 7u83 173
    sortname sortnum;
174
    long encoding;
175
    char *name;
176
    node *ename;
177
    struct x_construct *alias;
178
    struct x_construct *next;
2 7u83 179
    union {
7 7u83 180
	char *char_u;
181
	al_tag_info al_tag_u;
182
	tag_info tag_u;
183
	tok_info tok_u;
184
    } u;
185
} construct;
2 7u83 186
 
187
 
188
/*
189
    MACROS FOR ACCESSING INFO FIELDS OF A CONSTRUCT
190
 
191
    The following macros access the various field of the extra
192
    information union of a construct.  These macros should always
193
    be used - the fields should not be addressed directly.
194
*/
195
 
7 7u83 196
#define get_char_info(X)	((X) ->u.char_u)
197
#define get_al_tag_info(X)	(&((X) ->u.al_tag_u))
198
#define get_tag_info(X)		(&((X) ->u.tag_u))
199
#define get_tok_info(X)		(&((X) ->u.tok_u))
2 7u83 200
 
201
 
202
/*
203
    TYPE REPRESENTING A DIRECTORY
204
 
205
    In order to search for included files, the directory structure
206
    enables us to form lists of directory names.
207
*/
208
 
209
typedef struct x_directory {
7 7u83 210
    char *dirname;
211
    struct x_directory *next;
212
} directory;
2 7u83 213
 
214
 
215
#endif