-
Notifications
You must be signed in to change notification settings - Fork 1
/
Token.def
221 lines (179 loc) · 5.98 KB
/
Token.def
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
(*!m2r10*) (* Copyright (c) 2015 B.Kowarsch. All rights reserved. *)
DEFINITION MODULE Token;
(* Token Definitions for Modula-2 R10 Core Compiler *)
(* Semantic Tokens *)
TYPE Semantic = [Invalid..EOF] OF Token;
(* Semantic and Non-Semantic Tokens *)
TYPE Token =
( Invalid, (* 0 *)
(* Reserved Words *)
Alias, (* 1 *)
And, (* 2 *)
Arglist, (* 3 *)
Array, (* 4 *)
Bare, (* 5 *)
Begin, (* 6 *)
Blueprint, (* 7 *)
By, (* 8 *)
Case, (* 9 *)
Const, (* 10 *)
Copy, (* 11 *)
Definition, (* 12 *)
Div, (* 13 *)
Do, (* 14 *)
Else, (* 15 *)
Elsif, (* 16 *)
End, (* 17 *)
Exit, (* 18 *)
For, (* 19 *)
From, (* 20 *)
Genlib, (* 21 *)
If, (* 22 *)
Implementation, (* 23 *)
Import, (* 24 *)
In, (* 25 *)
Loop, (* 26 *)
Mod, (* 27 *)
Module, (* 28 *)
New, (* 29 *)
None, (* 30 *)
Not, (* 31 *)
Of, (* 32 *)
Opaque, (* 33 *)
Or, (* 34 *)
Pointer, (* 35 *)
Procedure, (* 36 *)
Record, (* 37 *)
Referential, (* 38 *)
Release, (* 39 *)
Repeat, (* 40 *)
Retain, (* 41 *)
Return, (* 42 *)
Set, (* 43 *)
Then, (* 44 *)
To, (* 45 *)
Type, (* 46 *)
Until, (* 47 *)
Var, (* 48 *)
While, (* 49 *)
Yield, (* 50 *)
(* Dual-Use RW-Identifiers *)
(* Constant Bindable Identifiers *)
Tflags, (* 51 *)
Tdyn, (* 52 *)
Trefc, (* 53 *)
Tordered, (* 54 *)
Tsorted, (* 55 *)
Tlimit, (* 56 *)
Tscalar, (* 57 *)
Tmax, (* 58 *)
Tmin, (* 59 *)
(* Procedure Bindable Identifiers *)
Abs, (* 60 *)
Length, (* 61 *)
Exists, (* 62 *)
Seek, (* 63 *)
Subset, (* 64 *)
Read, (* 65 *)
Readnew, (* 66 *)
Write, (* 67 *)
Writef, (* 68 *)
Sxf, (* 69 *)
Val, (* 70 *)
Count, (* 71 *)
Value, (* 72 *)
Store, (* 73 *)
Insert, (* 74 *)
Remove, (* 75 *)
Append, (* 76 *)
(* Other Dual-Use Identifiers *)
Address, (* 77 *)
Cast, (* 78 *)
Coroutine, (* 79 *)
Octet, (* 80 *)
Tliteral, (* 81 *)
Unsafe, (* 82 *)
(* Any Other Identifiers *)
OtherIdent, (* 83 *)
(* Literals *)
WholeNumber, (* 84 *)
RealNumber, (* 85 *)
Character, (* 86 *)
QuotedString, (* 87 *)
ChevronText, (* 88 *)
(* Punctuation *)
Dot, (* 89 *)
Comma, (* 90 *)
Colon, (* 91 *)
Semicolon, (* 92 *)
VerticalBar, (* 93 *)
Deref, (* 94 *)
DotDot, (* 95 *)
Assign, (* 96 *)
PlusPlus, (* 97 *)
MinusMinus, (* 98 *)
OneWayDep, (* 99 *)
MutualDep, (* 100 *)
MutualExcl, (* 101 *)
PlusMinus, (* 102 *)
(* Paired Delimiters *)
LParen, (* 103 *)
RParen, (* 104 *)
LBracket, (* 105 *)
RBracket, (* 106 *)
LBrace, (* 107 *)
RBrace, (* 108 *)
(* Operators *)
(* Non-Resword Level-1 Operators *)
Equal, (* 109 *)
NotEqual, (* 110 *)
Greater, (* 111 *)
GreaterOrEq, (* 112 *)
Less, (* 113 *)
LessOrEq, (* 114 *)
Identity, (* 115 *)
(* Non-Resword Level-2 Operators *)
Plus, (* 116 *) (* also used as punctuation *)
Minus, (* 117 *) (* also used as punctuation *)
Concat, (* 118 *)
SetDiff, (* 119 *)
(* Non-Resword Level-3 Operators *)
Asterisk, (* 120 *) (* also used as punctuation *)
RealDiv, (* 121 *)
DotProd, (* 122 *) (* reserved for future use *)
(* Non-Resword Level-4 Operators *)
Power, (* 123 *) (* reserved for future use *)
(* Non-Resword Level-5 Operators *)
TypeConv, (* 124 *)
(* End Of File Marker *)
EOF, (* 125 *)
(* Non-Semantic Tokens *)
(* Pragmas *)
Pragma, (* 126 *)
(* Comments *)
LineComment, (* 127 *)
BlockComment); (* 128 *)
(* Functions To Determine Token Classification *)
PROCEDURE isResWord ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a reserved word, otherwise FALSE. *)
PROCEDURE isIdentifier ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is an identifier, otherwise FALSE. *)
PROCEDURE isConstBindableIdent ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a constant bindable identifier, otherwise FALSE. *)
PROCEDURE isProcBindableIdent ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a procedure bindable identifier, otherwise FALSE. *)
PROCEDURE isNumber ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a number literal, otherwise FALSE. *)
PROCEDURE isCharOrString ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a character or string, otherwise FALSE. *)
PROCEDURE isOperL1 ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a level-1 operator, otherwise FALSE. *)
PROCEDURE isOperL2 ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a level-2 operator, otherwise FALSE. *)
PROCEDURE isOperL3 ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a level-3 operator, otherwise FALSE. *)
PROCEDURE isComment ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a comment, otherwise FALSE. *)
PROCEDURE isPragma ( t : Token ) : BOOLEAN;
(* Returns TRUE if t is a pragma, otherwise FALSE. *)
END Token.