2 |
7u83 |
1 |
/*
|
|
|
2 |
Crown Copyright (c) 1997
|
6 |
7u83 |
3 |
|
2 |
7u83 |
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:-
|
6 |
7u83 |
12 |
|
2 |
7u83 |
13 |
(1) Its Recipients shall ensure that this Notice is
|
|
|
14 |
reproduced upon any copies or amended versions of it;
|
6 |
7u83 |
15 |
|
2 |
7u83 |
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;
|
6 |
7u83 |
19 |
|
2 |
7u83 |
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;
|
6 |
7u83 |
23 |
|
2 |
7u83 |
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 |
/*
|
6 |
7u83 |
31 |
* AUTOMATICALLY GENERATED BY lexi VERSION 1.2
|
|
|
32 |
*/
|
2 |
7u83 |
33 |
|
|
|
34 |
|
|
|
35 |
/* LOOKUP TABLE */
|
|
|
36 |
|
6 |
7u83 |
37 |
static unsigned char lookup_tab[257] = {
|
2 |
7u83 |
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 |
0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c,
|
|
|
45 |
0x000c, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
|
|
|
46 |
0x0000, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 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, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 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
|
6 |
7u83 |
71 |
};
|
2 |
7u83 |
72 |
|
|
|
73 |
#ifndef LEX_EOF
|
6 |
7u83 |
74 |
#define LEX_EOF 256
|
2 |
7u83 |
75 |
#endif
|
|
|
76 |
|
6 |
7u83 |
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)
|
2 |
7u83 |
82 |
|
|
|
83 |
|
|
|
84 |
/* MAIN PASS ANALYSER */
|
|
|
85 |
|
6 |
7u83 |
86 |
int
|
|
|
87 |
read_token(void)
|
2 |
7u83 |
88 |
{
|
6 |
7u83 |
89 |
start: {
|
|
|
90 |
int c0 = read_char(), t0;
|
|
|
91 |
t0 = lookup_char(c0);
|
|
|
92 |
if (is_white(t0)) goto start;
|
|
|
93 |
switch (c0) {
|
|
|
94 |
case '"': {
|
|
|
95 |
return(get_string(c0));
|
2 |
7u83 |
96 |
}
|
6 |
7u83 |
97 |
case '(': {
|
|
|
98 |
return(lex_open_Hround);
|
2 |
7u83 |
99 |
}
|
6 |
7u83 |
100 |
case ')': {
|
|
|
101 |
return(lex_close_Hround);
|
2 |
7u83 |
102 |
}
|
6 |
7u83 |
103 |
case ',': {
|
|
|
104 |
return(lex_comma);
|
2 |
7u83 |
105 |
}
|
6 |
7u83 |
106 |
case '-': {
|
|
|
107 |
int c1 = read_char();
|
|
|
108 |
if (c1 == '>') {
|
|
|
109 |
return(lex_arrow);
|
2 |
7u83 |
110 |
}
|
6 |
7u83 |
111 |
unread_char(c1);
|
|
|
112 |
break;
|
2 |
7u83 |
113 |
}
|
6 |
7u83 |
114 |
case '/': {
|
|
|
115 |
int c1 = read_char();
|
|
|
116 |
if (c1 == '*') {
|
|
|
117 |
return(get_comment(c0, c1));
|
2 |
7u83 |
118 |
}
|
6 |
7u83 |
119 |
unread_char(c1);
|
|
|
120 |
break;
|
2 |
7u83 |
121 |
}
|
6 |
7u83 |
122 |
case ':': {
|
|
|
123 |
return(lex_colon);
|
2 |
7u83 |
124 |
}
|
6 |
7u83 |
125 |
case '=': {
|
|
|
126 |
return(lex_equal);
|
2 |
7u83 |
127 |
}
|
6 |
7u83 |
128 |
case '{': {
|
|
|
129 |
return(lex_open_Hbrace);
|
2 |
7u83 |
130 |
}
|
6 |
7u83 |
131 |
case '|': {
|
|
|
132 |
return(lex_or);
|
2 |
7u83 |
133 |
}
|
6 |
7u83 |
134 |
case '}': {
|
|
|
135 |
return(lex_close_Hbrace);
|
2 |
7u83 |
136 |
}
|
6 |
7u83 |
137 |
case LEX_EOF: {
|
|
|
138 |
return(lex_eof);
|
2 |
7u83 |
139 |
}
|
|
|
140 |
}
|
6 |
7u83 |
141 |
if (is_alpha(t0)) {
|
|
|
142 |
return(get_identifier(c0));
|
2 |
7u83 |
143 |
}
|
6 |
7u83 |
144 |
return(unknown_token(c0));
|
2 |
7u83 |
145 |
}
|
|
|
146 |
}
|