/Units/Misc/CastaliaPasLexTypes.pas

http://github.com/moparisthebest/Simba · Pascal · 322 lines · 267 code · 22 blank · 33 comment · 0 complexity · a62492612408195e480b7df74a5529c0 MD5 · raw file

  1. {---------------------------------------------------------------------------
  2. The contents of this file are subject to the Mozilla Public License Version
  3. 1.1 (the "License"); you may not use this file except in compliance with the
  4. License. You may obtain a copy of the License at
  5. http://www.mozilla.org/NPL/NPL-1_1Final.html
  6. Software distributed under the License is distributed on an "AS IS" basis,
  7. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
  8. the specific language governing rights and limitations under the License.
  9. The Original Code is: mwPasLexTypes, released November 14, 1999.
  10. The Initial Developer of the Original Code is Martin Waldenburg
  11. unit CastaliaPasLexTypes;
  12. ----------------------------------------------------------------------------}
  13. unit CastaliaPasLexTypes;
  14. {$include ValistusDefines.inc}
  15. interface
  16. uses SysUtils, TypInfo;
  17. var
  18. CompTable: array[#0..#255] of byte;
  19. type
  20. TMessageEventType = ( meError, meNotSupported );
  21. TMessageEvent = procedure(Sender: TObject; const Typ : TMessageEventType; const Msg: string; X, Y: Integer ) of object; //jdj 7/16/1999; DR 2001-11-06
  22. TCommentState = (csAnsi, csBor, csNo);
  23. TTokenPoint = packed record
  24. X : Integer;
  25. Y : Integer;
  26. end;
  27. TptTokenKind = (
  28. tokAbort, //JThurman 2004-11-8 (flow control routines)
  29. tokAbsolute,
  30. tokAbstract,
  31. tokAdd,
  32. tokAddressOp,
  33. tokAmpersand,
  34. tokAnd,
  35. tokAnsiComment,
  36. tokAnsiString,
  37. tokArray,
  38. tokAs,
  39. tokAsciiChar,
  40. tokAsm,
  41. tokAssembler,
  42. tokAssign,
  43. tokAt,
  44. tokAutomated,
  45. tokBegin,
  46. tokBoolean,
  47. tokBorComment,
  48. tokBraceClose,
  49. tokBraceOpen,
  50. tokBreak, //JThurman 2004-11-8 (flow control routines)
  51. tokByte,
  52. tokByteBool,
  53. tokCardinal,
  54. tokCase,
  55. tokCdecl,
  56. tokChar,
  57. tokClass,
  58. tokClassForward,
  59. tokClassFunction,
  60. tokClassProcedure,
  61. tokColon,
  62. tokComma,
  63. tokComp,
  64. tokCompDirect,
  65. tokConst,
  66. tokConstructor,
  67. tokContains,
  68. tokContinue, //JThurman 2004-11-8 (flow control routines)
  69. tokCRLF,
  70. tokCRLFCo,
  71. tokCurrency,
  72. tokDefault,
  73. tokDefineDirect,
  74. tokDeprecated, // DR 2001-10-20
  75. tokDestructor,
  76. tokDispid,
  77. tokDispinterface,
  78. tokDiv,
  79. tokDo,
  80. tokDotDot,
  81. tokDouble,
  82. tokDoubleAddressOp,
  83. tokDownto,
  84. tokDWORD,
  85. tokDynamic,
  86. tokElse,
  87. tokElseDirect,
  88. tokEnd,
  89. tokEndIfDirect,
  90. tokEqual,
  91. tokError,
  92. tokExcept,
  93. tokExit, //JThurman 2004-11-8 (flow control routine)
  94. tokExport,
  95. tokExports,
  96. tokExtended,
  97. tokExternal,
  98. tokFar,
  99. tokFile,
  100. {$IFDEF D8_NEWER} //JThurman 2004-03-20
  101. tokFinal,
  102. {$ENDIF}
  103. tokFinalization,
  104. tokFinally,
  105. tokFloat,
  106. tokFor,
  107. tokForward,
  108. tokFunction,
  109. tokGoto,
  110. tokGreater,
  111. tokGreaterEqual,
  112. tokHalt, //JThurman 2004-11-8 (flow control routines)
  113. {$IFDEF D8_NEWER} //JThurman 2004-04-06
  114. tokHelper,
  115. {$ENDIF}
  116. tokIdentifier,
  117. tokIf,
  118. tokIfDirect,
  119. tokIfEndDirect,
  120. tokElseIfDirect,
  121. tokIfDefDirect,
  122. tokIfNDefDirect,
  123. tokIfOptDirect,
  124. tokImplementation,
  125. tokImplements,
  126. tokIn,
  127. tokIncludeDirect,
  128. tokIndex,
  129. tokInherited,
  130. tokInitialization,
  131. tokInline,
  132. tokInt64,
  133. tokInteger,
  134. tokIntegerConst,
  135. tokInterface,
  136. tokIs,
  137. tokLabel,
  138. tokLibrary,
  139. tokLocal, // DR 2001-11-14
  140. tokLongBool,
  141. tokLongint,
  142. tokLongword,
  143. tokLower,
  144. tokLowerEqual,
  145. tokMessage,
  146. tokMinus,
  147. tokMod,
  148. tokName,
  149. tokNear,
  150. tokNil,
  151. tokNodefault,
  152. tokNone,
  153. tokNot,
  154. tokNotEqual,
  155. tokNull,
  156. tokObject,
  157. tokOf,
  158. tokOleVariant,
  159. tokOn,
  160. {$IFDEF D8_NEWER} //JThurman 2004-03-20
  161. tokOperator,
  162. {$ENDIF}
  163. tokOr,
  164. tokOut,
  165. tokOverload,
  166. tokOverride,
  167. tokPackage,
  168. tokPacked,
  169. tokPascal,
  170. tokPChar,
  171. tokPlatform, // DR 2001-10-20
  172. tokPlus,
  173. tokPoint,
  174. tokPointerSymbol,
  175. tokPrivate,
  176. tokProcedure,
  177. tokProgram,
  178. tokProperty,
  179. tokProtected,
  180. tokPublic,
  181. tokPublished,
  182. tokRaise,
  183. tokRead,
  184. tokReadonly,
  185. tokReal,
  186. tokReal48,
  187. tokRecord,
  188. {$IFDEF D12_NEWER}
  189. tokReference, //JThurman 2008-25-07 (anonymous methods)
  190. {$ENDIF}
  191. tokRegister,
  192. tokReintroduce,
  193. tokRemove,
  194. tokRepeat,
  195. tokRequires,
  196. tokResident,
  197. tokResourceDirect,
  198. tokResourcestring,
  199. tokRoundClose,
  200. tokRoundOpen,
  201. tokRunError, //JThurman 2004-11-8 (flow control routines)
  202. tokSafeCall,
  203. {$IFDEF D8_NEWER} //JThurman 2004-03-19
  204. tokSealed,
  205. {$ENDIF}
  206. tokSemiColon,
  207. tokSet,
  208. tokShl,
  209. tokShortint,
  210. tokShortString,
  211. tokShr,
  212. tokSingle,
  213. tokSlash,
  214. tokSlashesComment,
  215. tokSmallint,
  216. tokSpace,
  217. tokSquareClose,
  218. tokSquareOpen,
  219. tokStar,
  220. {$IFDEF D8_NEWER} //JThurman 2004-03-20
  221. tokStatic,
  222. {$ENDIF}
  223. tokStdcall,
  224. tokStored,
  225. {$IFDEF D8_NEWER}
  226. tokStrict, //JThurman 2004-03-03
  227. {$ENDIF}
  228. tokString,
  229. tokStringConst,
  230. tokStringDQConst, // 2002-01-14
  231. tokStringresource,
  232. tokSymbol,
  233. tokThen,
  234. tokThreadvar,
  235. tokTo,
  236. tokTry,
  237. tokType,
  238. tokUndefDirect,
  239. tokUnit,
  240. tokUnknown,
  241. {$IFDEF D8_NEWER} //JThurman 2004-03-2003
  242. tokUnsafe,
  243. {$ENDIF}
  244. tokUntil,
  245. tokUses,
  246. tokVar,
  247. tokVarargs, // DR 2001-11-14
  248. tokVariant,
  249. tokVirtual,
  250. tokWhile,
  251. tokWideChar,
  252. tokWideString,
  253. tokWith,
  254. tokWord,
  255. tokWordBool,
  256. tokWrite,
  257. tokWriteonly,
  258. tokXor,
  259. tok_DONE);
  260. TmwPasLexStatus = record
  261. CommentState: TCommentState;
  262. ExID: TptTokenKind;
  263. LineNumber: Integer;
  264. LinePos: Integer;
  265. Origin: PAnsiChar;
  266. RunPos: Integer;
  267. TokenPos: Integer;
  268. TokenID: TptTokenKind;
  269. end;
  270. const ExTypes = [tokDWORD, tokUnknown];
  271. function TokenName(Value: TptTokenKind): string;
  272. function tokTokenName(Value: TptTokenKind): string;
  273. function IsTokenIDJunk(const aTokenID : TptTokenKind ) :Boolean; //XM 20001210
  274. implementation
  275. function TokenName(Value: TptTokenKind): string;
  276. begin //jdj 7/18/1999
  277. Result := Copy(tokTokenName(Value), 4, MaxInt);
  278. end;
  279. function tokTokenName(Value: TptTokenKind): string;
  280. begin
  281. result := GetEnumName(TypeInfo(TptTokenKind), Integer(Value));
  282. end;
  283. function IsTokenIDJunk(const aTokenID : TptTokenKind ) :boolean; //XM 20001210
  284. begin
  285. Result := aTokenID in [tokAnsiComment, tokBorComment, tokCRLF, tokCRLFCo, tokSlashesComment, tokSpace,
  286. tokIfDirect,
  287. tokIfEndDirect,
  288. tokElseIfDirect,
  289. tokIfDefDirect,
  290. tokIfNDefDirect,
  291. tokEndIfDirect,
  292. tokIfOptDirect,
  293. tokDefineDirect,
  294. tokUndefDirect];
  295. end;
  296. end.