forked from jacobthurman/Castalia-Delphi-Parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CastaliaPasLexTypes.pas
320 lines (295 loc) · 6.47 KB
/
CastaliaPasLexTypes.pas
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
{---------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.mozilla.org/NPL/NPL-1_1Final.html
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
the specific language governing rights and limitations under the License.
The Original Code is: mwPasLexTypes, released November 14, 1999.
The Initial Developer of the Original Code is Martin Waldenburg
unit CastaliaPasLexTypes;
----------------------------------------------------------------------------}
unit CastaliaPasLexTypes;
interface
uses SysUtils, TypInfo;
{$INCLUDE CastaliaParserDefines.inc}
var
CompTable: array[#0..#255] of byte;
type
TMessageEventType = ( meError, meNotSupported );
TMessageEvent = procedure(Sender: TObject; const Typ : TMessageEventType; const Msg: string; X, Y: Integer ) of object; //jdj 7/16/1999; DR 2001-11-06
TCommentState = (csAnsi, csBor, csNo);
TTokenPoint = packed record
X : Integer;
Y : Integer;
end;
TptTokenKind = (
ptAbort, //JThurman 2004-11-8 (flow control routines)
ptAbsolute,
ptAbstract,
ptAdd,
ptAddressOp,
ptAmpersand,
ptAnd,
ptAnsiComment,
ptAnsiString,
ptArray,
ptAs,
ptAsciiChar,
ptAsm,
ptAssembler,
ptAssign,
ptAt,
ptAutomated,
ptBegin,
ptBoolean,
ptBorComment,
ptBraceClose,
ptBraceOpen,
ptBreak, //JThurman 2004-11-8 (flow control routines)
ptByte,
ptByteBool,
ptCardinal,
ptCase,
ptCdecl,
ptChar,
ptClass,
ptClassForward,
ptClassFunction,
ptClassProcedure,
ptColon,
ptComma,
ptComp,
ptCompDirect,
ptConst,
ptConstructor,
ptContains,
ptContinue, //JThurman 2004-11-8 (flow control routines)
ptCRLF,
ptCRLFCo,
ptCurrency,
ptDefault,
ptDefineDirect,
ptDeprecated, // DR 2001-10-20
ptDestructor,
ptDispid,
ptDispinterface,
ptDiv,
ptDo,
ptDotDot,
ptDouble,
ptDoubleAddressOp,
ptDownto,
ptDWORD,
ptDynamic,
ptElse,
ptElseDirect,
ptEnd,
ptEndIfDirect,
ptEqual,
ptError,
ptExcept,
ptExit, //JThurman 2004-11-8 (flow control routine)
ptExport,
ptExports,
ptExtended,
ptExternal,
ptFar,
ptFile,
{$IFDEF D8_NEWER} //JThurman 2004-03-20
ptFinal,
{$ENDIF}
ptFinalization,
ptFinally,
ptFloat,
ptFor,
ptForward,
ptFunction,
ptGoto,
ptGreater,
ptGreaterEqual,
ptHalt, //JThurman 2004-11-8 (flow control routines)
{$IFDEF D8_NEWER} //JThurman 2004-04-06
ptHelper,
{$ENDIF}
ptIdentifier,
ptIf,
ptIfDirect,
ptIfEndDirect,
ptElseIfDirect,
ptIfDefDirect,
ptIfNDefDirect,
ptIfOptDirect,
ptImplementation,
ptImplements,
ptIn,
ptIncludeDirect,
ptIndex,
ptInherited,
ptInitialization,
ptInline,
ptInt64,
ptInteger,
ptIntegerConst,
ptInterface,
ptIs,
ptLabel,
ptLibrary,
ptLocal, // DR 2001-11-14
ptLongBool,
ptLongint,
ptLongword,
ptLower,
ptLowerEqual,
ptMessage,
ptMinus,
ptMod,
ptName,
ptNear,
ptNil,
ptNodefault,
ptNone,
ptNot,
ptNotEqual,
ptNull,
ptObject,
ptOf,
ptOleVariant,
ptOn,
{$IFDEF D8_NEWER} //JThurman 2004-03-20
ptOperator,
{$ENDIF}
ptOr,
ptOut,
ptOverload,
ptOverride,
ptPackage,
ptPacked,
ptPascal,
ptPChar,
ptPlatform, // DR 2001-10-20
ptPlus,
ptPoint,
ptPointerSymbol,
ptPrivate,
ptProcedure,
ptProgram,
ptProperty,
ptProtected,
ptPublic,
ptPublished,
ptRaise,
ptRead,
ptReadonly,
ptReal,
ptReal48,
ptRecord,
{$IFDEF D12_NEWER}
ptReference, //JThurman 2008-25-07 (anonymous methods)
{$ENDIF}
ptRegister,
ptReintroduce,
ptRemove,
ptRepeat,
ptRequires,
ptResident,
ptResourceDirect,
ptResourcestring,
ptRoundClose,
ptRoundOpen,
ptRunError, //JThurman 2004-11-8 (flow control routines)
ptSafeCall,
{$IFDEF D8_NEWER} //JThurman 2004-03-19
ptSealed,
{$ENDIF}
ptSemiColon,
ptSet,
ptShl,
ptShortint,
ptShortString,
ptShr,
ptSingle,
ptSlash,
ptSlashesComment,
ptSmallint,
ptSpace,
ptSquareClose,
ptSquareOpen,
ptStar,
{$IFDEF D8_NEWER} //JThurman 2004-03-20
ptStatic,
{$ENDIF}
ptStdcall,
ptStored,
{$IFDEF D8_NEWER}
ptStrict, //JThurman 2004-03-03
{$ENDIF}
ptString,
ptStringConst,
ptStringDQConst, // 2002-01-14
ptStringresource,
ptSymbol,
ptThen,
ptThreadvar,
ptTo,
ptTry,
ptType,
ptUndefDirect,
ptUnit,
ptUnknown,
{$IFDEF D8_NEWER} //JThurman 2004-03-2003
ptUnsafe,
{$ENDIF}
ptUntil,
ptUses,
ptVar,
ptVarargs, // DR 2001-11-14
ptVariant,
ptVirtual,
ptWhile,
ptWideChar,
ptWideString,
ptWith,
ptWord,
ptWordBool,
ptWrite,
ptWriteonly,
ptXor);
TmwPasLexStatus = record
CommentState: TCommentState;
ExID: TptTokenKind;
LineNumber: Integer;
LinePos: Integer;
Origin: PChar;
RunPos: Integer;
TokenPos: Integer;
TokenID: TptTokenKind;
end;
const ExTypes = [ptDWORD, ptUnknown];
function TokenName(Value: TptTokenKind): string;
function ptTokenName(Value: TptTokenKind): string;
function IsTokenIDJunk(const aTokenID : TptTokenKind ) :Boolean; //XM 20001210
implementation
function TokenName(Value: TptTokenKind): string;
begin //jdj 7/18/1999
Result := Copy(ptTokenName(Value), 3, MaxInt);
end;
function ptTokenName(Value: TptTokenKind): string;
begin
result := GetEnumName(TypeInfo(TptTokenKind), Integer(Value));
end;
function IsTokenIDJunk(const aTokenID : TptTokenKind ) :boolean; //XM 20001210
begin
Result := aTokenID in [ptAnsiComment, ptBorComment, ptCRLF, ptCRLFCo, ptSlashesComment, ptSpace,
ptIfDirect,
ptIfEndDirect,
ptElseIfDirect,
ptIfDefDirect,
ptIfNDefDirect,
ptEndIfDirect,
ptIfOptDirect,
ptDefineDirect,
ptUndefDirect];
end;
end.