FoxCSharpScanner.SymU 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. MODULE FoxCSharpScanner;
  2. IMPORT Streams, Strings, Diagnostics, Commands, StringPool, D := Debugging, Basic := FoxBasic, FoxScanner;
  3. CONST
  4. Trace = FALSE;
  5. MaxIdentifierLength* = FoxScanner.MaxIdentifierLength;
  6. MaxHexDigits* = FoxScanner.MaxHexDigits;
  7. MaxHugeHexDigits* = FoxScanner.MaxHugeHexDigits;
  8. MaxRealExponent* = FoxScanner.MaxRealExponent;
  9. MaxLongrealExponent* = FoxScanner.MaxLongrealExponent;
  10. EOT* = 0X;
  11. LF* = 0AX;
  12. CR* = 0DX;
  13. TAB* = 9X;
  14. None* = 0;
  15. Exclamation* = 1;
  16. ExclamationEqual* = 2;
  17. Percent* = 3;
  18. PercentEqual* = 4;
  19. And* = 5;
  20. AndEqual* = 6;
  21. AndAnd* = 7;
  22. LeftParenthesis* = 8;
  23. RightParenthesis* = 9;
  24. Times* = 10;
  25. TimesEqual* = 11;
  26. Plus* = 12;
  27. PlusEqual* = 13;
  28. PlusPlus* = 14;
  29. Comma* = 15;
  30. Minus* = 16;
  31. MinusEqual* = 17;
  32. MinusMinus* = 18;
  33. Period* = 19;
  34. Slash* = 20;
  35. SlashEqual* = 21;
  36. Colon* = 22;
  37. Semicolon* = 23;
  38. Less* = 24;
  39. LessEqual* = 25;
  40. LeftShift* = 26;
  41. LeftShiftEqual* = 27;
  42. Equal* = 28;
  43. EqualEqual* = 29;
  44. Greater* = 30;
  45. GreaterEqual* = 31;
  46. RightShift* = 32;
  47. RightShiftEqual* = 33;
  48. LeftBracket* = 34;
  49. RightBracket* = 35;
  50. Arrow* = 36;
  51. ArrowEqual* = 37;
  52. LeftBrace* = 38;
  53. Bar* = 39;
  54. BarEqual* = 40;
  55. BarBar* = 41;
  56. RightBrace* = 42;
  57. Tilde* = 43;
  58. As* = 44;
  59. Base* = 45;
  60. Bool* = 46;
  61. Break* = 47;
  62. Case* = 48;
  63. Char* = 49;
  64. Class* = 50;
  65. Const* = 51;
  66. Default* = 52;
  67. Delegate* = 53;
  68. Do* = 54;
  69. Double* = 55;
  70. Else* = 56;
  71. False* = 57;
  72. Float* = 58;
  73. For* = 59;
  74. If* = 60;
  75. Import* = 61;
  76. Int* = 62;
  77. Internal* = 63;
  78. Is* = 64;
  79. Long* = 65;
  80. Module* = 66;
  81. New* = 67;
  82. Null* = 68;
  83. Object* = 69;
  84. Public* = 70;
  85. Readonly* = 71;
  86. Ref* = 72;
  87. Return* = 73;
  88. Sbyte* = 74;
  89. Short* = 75;
  90. String* = 76;
  91. Struct* = 77;
  92. Switch* = 78;
  93. This* = 79;
  94. True* = 80;
  95. Void* = 81;
  96. While* = 82;
  97. Identifier* = 83;
  98. IntegerLiteral* = 84;
  99. RealLiteral* = 85;
  100. CharacterLiteral* = 86;
  101. StringLiteral* = 87;
  102. Comment* = 88;
  103. Cell* = 89;
  104. Cellnet* = 90;
  105. In* = 91;
  106. Out* = 92;
  107. Select* = 93;
  108. Question* = 94;
  109. QuestionQuestion* = 95;
  110. EndOfText* = 96;
  111. IntNumber* = 1;
  112. LongNumber* = 2;
  113. FloatNumber* = 3;
  114. DoubleNumber* = 4;
  115. SingleQuote = 27X;
  116. DoubleQuote* = 22X;
  117. Backslash = 5CX;
  118. TYPE
  119. StringType* = FoxScanner.StringType;
  120. IdentifierType* = FoxScanner.IdentifierType;
  121. IdentifierString* = FoxScanner.IdentifierString;
  122. Keyword* = FoxScanner.Keyword;
  123. KeywordTable* = FoxScanner.KeywordTable;
  124. Token* = LONGINT;
  125. Position* = Basic.Position;
  126. Symbol* = RECORD
  127. position*: Position;
  128. token*: Token;
  129. identifier*: IdentifierType;
  130. identifierString*: IdentifierString;
  131. string*: StringType;
  132. stringLength*: LONGINT;
  133. numberType*: FoxScanner.SubType;
  134. integer*: LONGINT;
  135. hugeint*: HUGEINT;
  136. character*: CHAR;
  137. real*: LONGREAL;
  138. END;
  139. StringMaker* = FoxScanner.StringMaker;
  140. Scanner* = OBJECT
  141. VAR
  142. source-: StringType;
  143. reader: Streams.Reader;
  144. diagnostics: Diagnostics.Diagnostics;
  145. ch: CHAR;
  146. position-: Position;
  147. error-: BOOLEAN;
  148. stringWriter: Streams.Writer;
  149. stringMaker: StringMaker;
  150. PROCEDURE ^ & InitializeScanner*(CONST source: ARRAY OF CHAR; reader: Streams.Reader; position: LONGINT; diagnostics: Diagnostics.Diagnostics);
  151. PROCEDURE ^ ErrorS(CONST msg: ARRAY OF CHAR);
  152. PROCEDURE ^ Error(code: INTEGER);
  153. PROCEDURE ^ GetNextCharacter;
  154. PROCEDURE ^ IsNewlineCharacter(ch: CHAR): BOOLEAN;
  155. PROCEDURE ^ GetEscapeSequence(VAR esc: CHAR);
  156. PROCEDURE ^ GetCharacter(VAR symbol: Symbol);
  157. PROCEDURE ^ GetString(VAR symbol: Symbol);
  158. PROCEDURE ^ GetIdentifier(VAR symbol: Symbol);
  159. PROCEDURE ^ GetNumber(VAR symbol: Symbol; frac: BOOLEAN): Token;
  160. PROCEDURE ^ ReadSingleLineComment(VAR symbol: Symbol);
  161. PROCEDURE ^ ReadDelimitedComment(VAR symbol: Symbol);
  162. PROCEDURE ^ SkipBlanks;
  163. PROCEDURE ^ GetNextSymbol*(VAR symbol: Symbol): BOOLEAN;
  164. PROCEDURE ^ ResetError*;
  165. PROCEDURE ^ ResetErrorDiagnostics*(VAR diagnostics: Diagnostics.Diagnostics);
  166. END Scanner;
  167. VAR
  168. reservedCharacter: ARRAY 256 OF BOOLEAN;
  169. tokens-: ARRAY (EndOfText + 1) OF Keyword;
  170. keywords: KeywordTable;
  171. PROCEDURE ^ NewScanner*(CONST source: ARRAY OF CHAR; reader: Streams.Reader; position: LONGINT; diagnostics: Diagnostics.Diagnostics): Scanner;
  172. PROCEDURE ^ SymbolToString*(CONST symbol: Symbol; VAR str: ARRAY OF CHAR);
  173. PROCEDURE ^ OutSymbol*(w: Streams.Writer; CONST symbol: Symbol);
  174. PROCEDURE ^ InitReservedCharacters;
  175. PROCEDURE ^ GetKeyword*(token: LONGINT; VAR identifier: IdentifierType);
  176. PROCEDURE ^ InitTokens;
  177. PROCEDURE ^ InitKeywords;
  178. PROCEDURE ^ ReportKeywords*(context: Commands.Context);
  179. BEGIN
  180. END FoxCSharpScanner.