Subversion Repositories tendra.SVN

Rev

Rev 2 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 7u83 1
/*
2
    		 Crown Copyright (c) 1997
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
    AUTOMATICALLY GENERATED BY lexi VERSION 1.1
32
*/
33
 
34
 
35
/* LOOKUP TABLE */
36
 
37
static unsigned char lookup_tab [257] = {
38
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
39
    0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
40
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
41
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
42
    0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
43
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
44
    0x001c, 0x001c, 0x001c, 0x001c, 0x001c, 0x001c, 0x001c, 0x001c,
45
    0x001c, 0x001c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
46
    0x0000, 0x001a, 0x001a, 0x001a, 0x001a, 0x001a, 0x001a, 0x000a,
47
    0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
48
    0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
49
    0x000a, 0x000a, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x000a,
50
    0x0000, 0x001a, 0x001a, 0x001a, 0x001a, 0x001a, 0x001a, 0x000a,
51
    0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
52
    0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
53
    0x000a, 0x000a, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
54
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
55
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
56
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
57
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
58
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
59
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
60
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
61
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
62
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
63
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
64
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
65
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
66
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
67
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
68
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
69
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
70
    0x0000
71
} ;
72
 
73
#ifndef LEX_EOF
74
#define LEX_EOF			256
75
#endif
76
 
77
#define lookup_char( C )	( ( int ) lookup_tab [ ( C ) ] )
78
#define is_white( T )		( ( T ) & 0x0001 )
79
#define is_alpha( T )		( ( T ) & 0x0002 )
80
#define is_digit( T )		( ( T ) & 0x0004 )
81
#define is_alphanum( T )	( ( T ) & 0x0008 )
82
#define is_hexdigit( T )	( ( T ) & 0x0010 )
83
 
84
#ifndef PROTO_Z
85
#ifdef __STDC__
86
#define PROTO_Z()		( void )
87
#else
88
#define PROTO_Z()		()
89
#endif
90
#endif
91
 
92
 
93
/* MAIN PASS ANALYSER */
94
 
95
int read_token PROTO_Z ()
96
{
97
    start : {
98
	int c0 = read_char (), t0 ;
99
	t0 = lookup_char ( c0 ) ;
100
	if ( is_white ( t0 ) ) goto start ;
101
	switch ( c0 ) {
102
	    case '!' : {
103
		return ( lex_exclaim ) ;
104
	    }
105
	    case '"' : {
106
		return ( get_string ( c0 ) ) ;
107
	    }
108
	    case '#' : {
109
		return ( lex_hash ) ;
110
	    }
111
	    case '%' : {
112
		return ( lex_rem ) ;
113
	    }
114
	    case '&' : {
115
		return ( lex_and ) ;
116
	    }
117
	    case '(' : {
118
		return ( lex_open_Hround ) ;
119
	    }
120
	    case ')' : {
121
		return ( lex_close_Hround ) ;
122
	    }
123
	    case '*' : {
124
		return ( lex_star ) ;
125
	    }
126
	    case '+' : {
127
		return ( lex_plus ) ;
128
	    }
129
	    case ',' : {
130
		return ( lex_comma ) ;
131
	    }
132
	    case '-' : {
133
		int c1 = read_char () ;
134
		if ( c1 == '>' ) {
135
		    return ( lex_arrow ) ;
136
		}
137
		unread_char ( c1 ) ;
138
		return ( lex_minus ) ;
139
	    }
140
	    case '.' : {
141
		return ( lex_dot ) ;
142
	    }
143
	    case '/' : {
144
		int c1 = read_char () ;
145
		if ( c1 == '*' ) {
146
		    return ( get_comment ( c0, c1 ) ) ;
147
		}
148
		unread_char ( c1 ) ;
149
		return ( lex_div ) ;
150
	    }
151
	    case '0' : {
152
		int c1 = read_char () ;
153
		if ( c1 == 'X' ) {
154
		    int c2 = read_char (), t2 ;
155
		    t2 = lookup_char ( c2 ) ;
156
		    if ( is_hexdigit ( t2 ) ) {
157
			return ( get_hex ( c0, c1, c2 ) ) ;
158
		    }
159
		    unread_char ( c2 ) ;
160
		} else if ( c1 == 'x' ) {
161
		    int c2 = read_char (), t2 ;
162
		    t2 = lookup_char ( c2 ) ;
163
		    if ( is_hexdigit ( t2 ) ) {
164
			return ( get_hex ( c0, c1, c2 ) ) ;
165
		    }
166
		    unread_char ( c2 ) ;
167
		}
168
		unread_char ( c1 ) ;
169
		break ;
170
	    }
171
	    case ':' : {
172
		int c1 = read_char () ;
173
		if ( c1 == ':' ) {
174
		    return ( lex_colon_Hcolon ) ;
175
		}
176
		unread_char ( c1 ) ;
177
		return ( lex_colon ) ;
178
	    }
179
	    case ';' : {
180
		return ( lex_semicolon ) ;
181
	    }
182
	    case '<' : {
183
		int c1 = read_char () ;
184
		if ( c1 == '<' ) {
185
		    return ( lex_lshift ) ;
186
		}
187
		unread_char ( c1 ) ;
188
		break ;
189
	    }
190
	    case '=' : {
191
		return ( lex_equal ) ;
192
	    }
193
	    case '>' : {
194
		int c1 = read_char () ;
195
		if ( c1 == '>' ) {
196
		    return ( lex_rshift ) ;
197
		}
198
		unread_char ( c1 ) ;
199
		break ;
200
	    }
201
	    case '?' : {
202
		return ( lex_question ) ;
203
	    }
204
	    case '[' : {
205
		return ( lex_open_Hsquare ) ;
206
	    }
207
	    case ']' : {
208
		return ( lex_close_Hsquare ) ;
209
	    }
210
	    case '^' : {
211
		return ( lex_xor ) ;
212
	    }
213
	    case '{' : {
214
		return ( lex_open_Hbrace ) ;
215
	    }
216
	    case '|' : {
217
		return ( lex_or ) ;
218
	    }
219
	    case '}' : {
220
		return ( lex_close_Hbrace ) ;
221
	    }
222
	    case '~' : {
223
		return ( lex_compl ) ;
224
	    }
225
	    case LEX_EOF : {
226
		return ( lex_eof ) ;
227
	    }
228
	}
229
	if ( is_alpha ( t0 ) ) {
230
	    return ( get_identifier ( c0 ) ) ;
231
	} else if ( is_digit ( t0 ) ) {
232
	    return ( get_number ( c0 ) ) ;
233
	}
234
	return ( unknown_token ( c0 ) ) ;
235
    }
236
}