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 1... Line 1...
1
/*
1
/*
2
    		 Crown Copyright (c) 1997
2
    		 Crown Copyright (c) 1997
3
    
3
 
4
    This TenDRA(r) Computer Program is subject to Copyright
4
    This TenDRA(r) Computer Program is subject to Copyright
5
    owned by the United Kingdom Secretary of State for Defence
5
    owned by the United Kingdom Secretary of State for Defence
6
    acting through the Defence Evaluation and Research Agency
6
    acting through the Defence Evaluation and Research Agency
7
    (DERA).  It is made available to Recipients with a
7
    (DERA).  It is made available to Recipients with a
8
    royalty-free licence for its use, reproduction, transfer
8
    royalty-free licence for its use, reproduction, transfer
9
    to other parties and amendment for any purpose not excluding
9
    to other parties and amendment for any purpose not excluding
10
    product development provided that any such use et cetera
10
    product development provided that any such use et cetera
11
    shall be deemed to be acceptance of the following conditions:-
11
    shall be deemed to be acceptance of the following conditions:-
12
    
12
 
13
        (1) Its Recipients shall ensure that this Notice is
13
        (1) Its Recipients shall ensure that this Notice is
14
        reproduced upon any copies or amended versions of it;
14
        reproduced upon any copies or amended versions of it;
15
    
15
 
16
        (2) Any amended version of it shall be clearly marked to
16
        (2) Any amended version of it shall be clearly marked to
17
        show both the nature of and the organisation responsible
17
        show both the nature of and the organisation responsible
18
        for the relevant amendment or amendments;
18
        for the relevant amendment or amendments;
19
    
19
 
20
        (3) Its onward transfer from a recipient to another
20
        (3) Its onward transfer from a recipient to another
21
        party shall be deemed to be that party's acceptance of
21
        party shall be deemed to be that party's acceptance of
22
        these conditions;
22
        these conditions;
23
    
23
 
24
        (4) DERA gives no warranty or assurance as to its
24
        (4) DERA gives no warranty or assurance as to its
25
        quality or suitability for any purpose and DERA accepts
25
        quality or suitability for any purpose and DERA accepts
26
        no liability whatsoever in relation to any use to which
26
        no liability whatsoever in relation to any use to which
27
        it may be put.
27
        it may be put.
28
*/
28
*/
29
 
29
 
30
/*
30
/*
31
    AUTOMATICALLY GENERATED BY lexi VERSION 1.1
31
 *  AUTOMATICALLY GENERATED BY lexi VERSION 1.2
32
*/
32
 */
33
 
33
 
34
 
34
 
35
/* LOOKUP TABLE */
35
/* LOOKUP TABLE */
36
 
36
 
37
static unsigned char lookup_tab [257] = {
37
static unsigned char lookup_tab[257] = {
38
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
38
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
39
    0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
39
    0x0000, 0x0001, 0x0001, 0x0000, 0x0000, 0x0001, 0x0000, 0x0000,
40
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
40
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
41
    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,
42
    0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
43
    0x0000, 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,
44
    0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c, 0x000c,
45
    0x000c, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
45
    0x000c, 0x000c, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
46
    0x0000, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
46
    0x0000, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
47
    0x000a, 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,
48
    0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
49
    0x000a, 0x000a, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x000a,
49
    0x000a, 0x000a, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x000a,
50
    0x0000, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
50
    0x0000, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
51
    0x000a, 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,
52
    0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a, 0x000a,
53
    0x000a, 0x000a, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
53
    0x000a, 0x000a, 0x000a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
54
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
54
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
55
    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,
56
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
57
    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,
58
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
59
    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,
60
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
61
    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,
62
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
63
    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,
64
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
65
    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,
66
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
67
    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,
68
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
69
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
69
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
70
    0x0000
70
    0x0000
71
} ;
71
};
72
 
72
 
73
#ifndef LEX_EOF
73
#ifndef LEX_EOF
74
#define LEX_EOF			256
74
#define LEX_EOF		256
75
#endif
75
#endif
76
 
76
 
77
#define lookup_char( C )	( ( int ) lookup_tab [ ( C ) ] )
77
#define lookup_char(C)	((int)lookup_tab[(C)])
78
#define is_white( T )		( ( T ) & 0x0001 )
78
#define is_white(T)	((T) & 0x0001)
79
#define is_alpha( T )		( ( T ) & 0x0002 )
79
#define is_alpha(T)	((T) & 0x0002)
80
#define is_digit( T )		( ( T ) & 0x0004 )
80
#define is_digit(T)	((T) & 0x0004)
81
#define is_alphanum( T )	( ( T ) & 0x0008 )
81
#define is_alphanum(T)	((T) & 0x0008)
82
 
-
 
83
#ifndef PROTO_Z
-
 
84
#ifdef __STDC__
-
 
85
#define PROTO_Z()		( void )
-
 
86
#else
-
 
87
#define PROTO_Z()		()
-
 
88
#endif
-
 
89
#endif
-
 
90
 
82
 
91
 
83
 
92
/* MAIN PASS ANALYSER */
84
/* MAIN PASS ANALYSER */
93
 
85
 
-
 
86
int
94
int read_token PROTO_Z ()
87
read_token(void)
95
{
88
{
96
    start : {
89
    start: {
97
	int c0 = read_char (), t0 ;
90
	int c0 = read_char(), t0;
98
	t0 = lookup_char ( c0 ) ;
91
	t0 = lookup_char(c0);
99
	if ( is_white ( t0 ) ) goto start ;
92
	if (is_white(t0)) goto start;
100
	switch ( c0 ) {
93
	switch (c0) {
101
	    case '"' : {
94
	    case '"': {
102
		return ( get_string ( c0 ) ) ;
95
		return(get_string(c0));
103
	    }
96
	    }
104
	    case '(' : {
97
	    case '(': {
105
		return ( lex_open_Hround ) ;
98
		return(lex_open_Hround);
106
	    }
99
	    }
107
	    case ')' : {
100
	    case ')': {
108
		return ( lex_close_Hround ) ;
101
		return(lex_close_Hround);
109
	    }
102
	    }
110
	    case ',' : {
103
	    case ',': {
111
		return ( lex_comma ) ;
104
		return(lex_comma);
112
	    }
105
	    }
113
	    case '-' : {
106
	    case '-': {
114
		int c1 = read_char () ;
107
		int c1 = read_char();
115
		if ( c1 == '>' ) {
108
		if (c1 == '>') {
116
		    return ( lex_arrow ) ;
109
		    return(lex_arrow);
117
		}
110
		}
118
		unread_char ( c1 ) ;
111
		unread_char(c1);
119
		break ;
112
		break;
120
	    }
113
	    }
121
	    case '/' : {
114
	    case '/': {
122
		int c1 = read_char () ;
115
		int c1 = read_char();
123
		if ( c1 == '*' ) {
116
		if (c1 == '*') {
124
		    return ( get_comment ( c0, c1 ) ) ;
117
		    return(get_comment(c0, c1));
125
		}
118
		}
126
		unread_char ( c1 ) ;
119
		unread_char(c1);
127
		break ;
120
		break;
128
	    }
121
	    }
129
	    case ':' : {
122
	    case ':': {
130
		return ( lex_colon ) ;
123
		return(lex_colon);
131
	    }
124
	    }
132
	    case '=' : {
125
	    case '=': {
133
		return ( lex_equal ) ;
126
		return(lex_equal);
134
	    }
127
	    }
135
	    case '{' : {
128
	    case '{': {
136
		return ( lex_open_Hbrace ) ;
129
		return(lex_open_Hbrace);
137
	    }
130
	    }
138
	    case '|' : {
131
	    case '|': {
139
		return ( lex_or ) ;
132
		return(lex_or);
140
	    }
133
	    }
141
	    case '}' : {
134
	    case '}': {
142
		return ( lex_close_Hbrace ) ;
135
		return(lex_close_Hbrace);
143
	    }
136
	    }
144
	    case LEX_EOF : {
137
	    case LEX_EOF: {
145
		return ( lex_eof ) ;
138
		return(lex_eof);
146
	    }
139
	    }
147
	}
140
	}
148
	if ( is_alpha ( t0 ) ) {
141
	if (is_alpha(t0)) {
149
	    return ( get_identifier ( c0 ) ) ;
142
	    return(get_identifier(c0));
150
	}
143
	}
151
	return ( unknown_token ( c0 ) ) ;
144
	return(unknown_token(c0));
152
    }
145
    }
153
}
146
}