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 |
/*
|
|
|
32 |
LEXICAL ANALYSER FOR CALCULUS
|
|
|
33 |
|
|
|
34 |
This file describes the lexical analyser used by calculus.
|
|
|
35 |
*/
|
|
|
36 |
|
|
|
37 |
/* Character groups */
|
|
|
38 |
GROUP white = " \t\n\r" ;
|
|
|
39 |
GROUP alpha = {A-Z} + {a-z} + "_" ;
|
|
|
40 |
GROUP digit = {0-9} ;
|
|
|
41 |
GROUP alphanum = "[alpha][digit]" ;
|
|
|
42 |
GROUP hexdigit = "[digit]ABCDEFabcdef" ;
|
|
|
43 |
|
|
|
44 |
/* Simple symbols */
|
|
|
45 |
TOKEN "!" -> $exclaim ;
|
|
|
46 |
TOKEN "#" -> $hash ;
|
|
|
47 |
TOKEN "%" -> $rem ;
|
|
|
48 |
TOKEN "?" -> $question ;
|
|
|
49 |
TOKEN "&" -> $and ;
|
|
|
50 |
TOKEN "*" -> $star ;
|
|
|
51 |
TOKEN "+" -> $plus ;
|
|
|
52 |
TOKEN "," -> $comma ;
|
|
|
53 |
TOKEN "-" -> $minus ;
|
|
|
54 |
TOKEN "->" -> $arrow ;
|
|
|
55 |
TOKEN "." -> $dot ;
|
|
|
56 |
TOKEN "/" -> $div ;
|
|
|
57 |
TOKEN ":" -> $colon ;
|
|
|
58 |
TOKEN "::" -> $colon-colon ;
|
|
|
59 |
TOKEN ";" -> $semicolon ;
|
|
|
60 |
TOKEN "<<" -> $lshift ;
|
|
|
61 |
TOKEN "=" -> $equal ;
|
|
|
62 |
TOKEN ">>" -> $rshift ;
|
|
|
63 |
TOKEN "^" -> $xor ;
|
|
|
64 |
TOKEN "|" -> $or ;
|
|
|
65 |
TOKEN "~" -> $compl ;
|
|
|
66 |
TOKEN "(" -> $open-round ;
|
|
|
67 |
TOKEN ")" -> $close-round ;
|
|
|
68 |
TOKEN "\[" -> $open-square ;
|
|
|
69 |
TOKEN "]" -> $close-square ;
|
|
|
70 |
TOKEN "{" -> $open-brace ;
|
|
|
71 |
TOKEN "}" -> $close-brace ;
|
|
|
72 |
TOKEN "\e" -> $eof ;
|
|
|
73 |
|
|
|
74 |
/* Comments, strings, identifies and numbers */
|
|
|
75 |
TOKEN "/*" -> get_comment () ;
|
|
|
76 |
TOKEN "\"" -> get_string () ;
|
|
|
77 |
TOKEN "[alpha]" -> get_identifier () ;
|
|
|
78 |
TOKEN "[digit]" -> get_number () ;
|
|
|
79 |
TOKEN "0x[hexdigit]" -> get_hex () ;
|
|
|
80 |
TOKEN "0X[hexdigit]" -> get_hex () ;
|
|
|
81 |
|
|
|
82 |
/* Keywords */
|
|
|
83 |
KEYWORD "ALGEBRA" -> $algebra ;
|
|
|
84 |
KEYWORD "LIST" -> $list ;
|
|
|
85 |
KEYWORD "PTR" -> $ptr ;
|
|
|
86 |
KEYWORD "STACK" -> get_stack () ;
|
|
|
87 |
KEYWORD "VEC" -> get_vec () ;
|
|
|
88 |
KEYWORD "VEC_PTR" -> get_vec_ptr () ;
|
|
|
89 |
|
|
|
90 |
IF ( new_format ) {
|
|
|
91 |
/* New style keywords */
|
|
|
92 |
KEYWORD "enum" -> $enum ;
|
|
|
93 |
KEYWORD "struct" -> $struct ;
|
|
|
94 |
KEYWORD "union" -> $union ;
|
|
|
95 |
KEYWORD "IMPORT" -> $import ;
|
|
|
96 |
} ELSE {
|
|
|
97 |
/* Old style keywords */
|
|
|
98 |
KEYWORD "EXTRAS" -> $extras ;
|
|
|
99 |
KEYWORD "IDENTITIES" -> $identities ;
|
|
|
100 |
KEYWORD "MAPS" -> $maps ;
|
|
|
101 |
KEYWORD "PRIMITIVES" -> $primitives ;
|
|
|
102 |
KEYWORD "STRUCTURES" -> $structures ;
|
|
|
103 |
KEYWORD "UNIONS" -> $unions ;
|
|
|
104 |
KEYWORD "WITH" -> $with ;
|
|
|
105 |
}
|