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
6
    acting through the Defence Evaluation and Research Agency
36
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
37
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
38
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
39
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
40
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
41
    shall be deemed to be acceptance of the following conditions:-
12
    
42
 
13
        (1) Its Recipients shall ensure that this Notice is
43
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
44
        reproduced upon any copies or amended versions of it;
15
    
45
 
16
        (2) Any amended version of it shall be clearly marked to
46
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
47
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
48
        for the relevant amendment or amendments;
19
    
49
 
20
        (3) Its onward transfer from a recipient to another
50
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
51
        party shall be deemed to be that party's acceptance of
22
        these conditions;
52
        these conditions;
23
    
53
 
24
        (4) DERA gives no warranty or assurance as to its
54
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
55
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
56
        no liability whatsoever in relation to any use to which
27
        it may be put.
57
        it may be put.
28
*/
58
*/
Line 37... Line 67...
37
 
67
 
38
    A byte is used to represent a single 8-bit number read from the
68
    A byte is used to represent a single 8-bit number read from the
39
    input file.  A pointer is a generic pointer.
69
    input file.  A pointer is a generic pointer.
40
*/
70
*/
41
 
71
 
42
typedef unsigned char byte ;
72
typedef unsigned char byte;
43
#if FS_PTR_VOID
-
 
44
typedef void *pointer ;
73
typedef void *pointer;
45
#else
-
 
46
typedef char *pointer ;
-
 
47
#endif
-
 
48
 
74
 
49
 
75
 
50
/*
76
/*
51
    INPUT FILE POSITION
77
    INPUT FILE POSITION
52
 
78
 
Line 54... Line 80...
54
    of the byte number within the file, the bit number within that byte,
80
    of the byte number within the file, the bit number within that byte,
55
    and an 8-bit input buffer.
81
    and an 8-bit input buffer.
56
*/
82
*/
57
 
83
 
58
typedef struct {
84
typedef struct {
59
    long byte ;
85
    long byte;
60
    int bit ;
86
    int bit;
61
    unsigned worksp ;
87
    unsigned worksp;
62
} place ;
88
} place;
63
 
89
 
64
 
90
 
65
/*
91
/*
66
    IDENTIFIER TYPES
92
    IDENTIFIER TYPES
67
 
93
 
68
    A string is used to represent TDF strings.  A unique is a null-terminated
94
    A string is used to represent TDF strings.  A unique is a null-terminated
69
    array of strings.  An external is either a string or a unique.
95
    array of strings.  An external is either a string or a unique.
70
*/
96
*/
71
 
97
 
72
typedef char *string ;
98
typedef char *string;
73
typedef string *unique ;
99
typedef string *unique;
74
 
100
 
75
typedef struct {
101
typedef struct {
76
    char simple ;
102
    char simple;
77
    union {
103
    union {
78
	string str ;
104
	string str;
79
	unique uniq ;
105
	unique uniq;
80
    } val ;
106
    } val;
81
} external ;
107
} external;
82
 
108
 
83
 
109
 
84
/*
110
/*
85
    TYPES REPRESENTING SORTS
111
    TYPES REPRESENTING SORTS
86
 
112
 
87
    Each TDF sort name is represented by an identifying integer.  A sort
113
    Each TDF sort name is represented by an identifying integer.  A sort
88
    identifier consists of a name and a decode letter.  A foreign sort may
114
    identifier consists of a name and a decode letter.  A foreign sort may
89
    also have an associated foreign sort name.
115
    also have an associated foreign sort name.
90
*/
116
*/
91
 
117
 
92
typedef int sortname ;
118
typedef int sortname;
93
 
119
 
94
typedef struct {
120
typedef struct {
95
    char *name ;
121
    char *name;
96
    char *fname ;
122
    char *fname;
97
    char decode ;
123
    char decode;
98
    sortname res ;
124
    sortname res;
99
    char *args ;
125
    char *args;
100
} sortid ;
126
} sortid;
101
 
127
 
102
 
128
 
103
/*
129
/*
104
    TYPE REPRESENTING TOKEN INFORMATION
130
    TYPE REPRESENTING TOKEN INFORMATION
105
 
131
 
Line 108... Line 134...
108
    implicit sort (for tokens which are used before they are declared
134
    implicit sort (for tokens which are used before they are declared
109
    or defined).
135
    or defined).
110
*/
136
*/
111
 
137
 
112
typedef struct {
138
typedef struct {
113
    sortname tok_res_sort ;
139
    sortname tok_res_sort;
114
    char *tok_arg_sorts ;
140
    char *tok_arg_sorts;
115
    sortname tok_implicit_sort ;
141
    sortname tok_implicit_sort;
116
} token_info ;
142
} token_info;
117
 
143
 
118
 
144
 
119
/*
145
/*
120
    TYPE REPRESENTING VARIABLE SORTS
146
    TYPE REPRESENTING VARIABLE SORTS
121
 
147
 
Line 124... Line 150...
124
    its internal identifying number, plus extra information depending
150
    its internal identifying number, plus extra information depending
125
    on the type of object represented (see below).
151
    on the type of object represented (see below).
126
*/
152
*/
127
 
153
 
128
typedef struct object_tag {
154
typedef struct object_tag {
129
    int flag ;
155
    int flag;
130
    int named ;
156
    int named;
131
    external name ;
157
    external name;
132
    long id ;
158
    long id;
133
    long order ;
159
    long order;
134
    union {
160
    union {
135
	token_info tok ;
161
	token_info tok;
136
    } extra ;
162
    } extra;
137
    struct object_tag *aux ;
163
    struct object_tag *aux;
138
} object ;
164
} object;
139
 
165
 
140
 
166
 
141
/*
167
/*
142
    TRANSLATIONS FOR TAGS
168
    TRANSLATIONS FOR TAGS
143
 
169
 
144
    These macros give the interpretation for the field of an object
170
    These macros give the interpretation for the field of an object
145
    when that object represents a tag.
171
    when that object represents a tag.
146
*/
172
*/
147
 
173
 
148
#define var( X )		( ( X )->flag )
174
#define var(X)		((X)->flag)
149
 
175
 
150
 
176
 
151
/*
177
/*
152
    TRANSLATIONS FOR TOKENS
178
    TRANSLATIONS FOR TOKENS
153
 
179
 
154
    These macros give the interpretation for the field of an object
180
    These macros give the interpretation for the field of an object
155
    when that object represents a token.
181
    when that object represents a token.
156
*/
182
*/
157
 
183
 
158
#define is_foreign( X )		( ( X )->flag )
184
#define is_foreign(X)		((X)->flag)
159
#define res_sort( X )		( ( X )->extra.tok.tok_res_sort )
185
#define res_sort(X)		((X)->extra.tok.tok_res_sort)
160
#define arg_sorts( X )		( ( X )->extra.tok.tok_arg_sorts )
186
#define arg_sorts(X)		((X)->extra.tok.tok_arg_sorts)
161
#define implicit_sort( X )	( ( X )->extra.tok.tok_implicit_sort )
187
#define implicit_sort(X)	((X)->extra.tok.tok_implicit_sort)
162
 
188
 
163
 
189
 
164
 
190
 
165
/*
191
/*
166
    TYPE REPRESENTING BINDINGS
192
    TYPE REPRESENTING BINDINGS
Line 168... Line 194...
168
    A binding consists of a table of pointers to objects.  A binding table
194
    A binding consists of a table of pointers to objects.  A binding table
169
    is an array of bindings.
195
    is an array of bindings.
170
*/
196
*/
171
 
197
 
172
typedef struct {
198
typedef struct {
173
    long max_no ;
199
    long max_no;
174
    long sz ;
200
    long sz;
175
    object **table ;
201
    object **table;
176
} binding ;
202
} binding;
177
 
203
 
178
 
204
 
179
#endif
205
#endif