Changeset 222 for branches/interpreter2/UTokenizer.pas
- Timestamp:
- Nov 25, 2020, 12:18:45 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/UTokenizer.pas
r212 r222 53 53 function GetNext: TToken; 54 54 function CheckNext(Text: string; Kind: TTokenKind): Boolean; 55 function CheckNextAndRead(Text: string; Kind: TTokenKind): Boolean; 55 56 function CheckNextKind(Kind: TTokenKind): Boolean; 57 function CheckNextKindAndRead(Kind: TTokenKind): Boolean; 56 58 procedure Expect(Text: string; Kind: TTokenKind); 57 59 procedure Error(Text: string); … … 111 113 Result := (C = ';') or (C = '.') or (C = '(') or (C = ')') or (C = '=') or 112 114 (C = ':') or (C = '+') or (C = '-') or (C = ',') or (C = '/') or 113 (C = '<') or (C = '>') ;115 (C = '<') or (C = '>') or (C = '*'); 114 116 end; 115 117 116 118 function TTokenizer.IsSpecialSymbol2(Text: string): Boolean; 117 119 begin 118 Result := (Text = ':=') or (Text = '//') or (Text = '<>'); 120 Result := (Text = ':=') or (Text = '//') or (Text = '<>') or (Text = '<=') or 121 (Text = '>='); 119 122 end; 120 123 … … 141 144 function TTokenizer.IsOperator(Text: string): Boolean; 142 145 begin 143 Result := (Text = '+') or (Text = '-') or (Text = '=') or (Text = '<>'); 146 Result := (Text = '+') or (Text = '-') or (Text = '=') or (Text = '<>') or 147 (Text = '*') or (Text = '/') or (Text = 'div') or (Text = '<=') or 148 (Text = '>=') or (Text = 'mod') or (Text = 'shl') or (Text = 'shr') or 149 (Text = 'and') or (Text = 'or') or (Text = 'xor') or (Text = 'not') or 150 (Text = '>') or (Text = '<'); 144 151 end; 145 152 … … 270 277 end; 271 278 279 function TTokenizer.CheckNextAndRead(Text: string; Kind: TTokenKind): Boolean; 280 var 281 LastPos: TTokenizerPos; 282 Token: TToken; 283 begin 284 LastPos := Pos; 285 Token := GetNext; 286 Result := (Token.Text = Text) and (Token.Kind = Kind); 287 if not Result then Pos := LastPos; 288 end; 289 272 290 function TTokenizer.CheckNextKind(Kind: TTokenKind): Boolean; 273 291 var … … 281 299 end; 282 300 301 function TTokenizer.CheckNextKindAndRead(Kind: TTokenKind): Boolean; 302 var 303 LastPos: TTokenizerPos; 304 Token: TToken; 305 begin 306 LastPos := Pos; 307 Token := GetNext; 308 Result := Token.Kind = Kind; 309 if not Result then Pos := LastPos; 310 end; 311 283 312 procedure TTokenizer.Expect(Text: string; Kind: TTokenKind); 284 313 var
Note:
See TracChangeset
for help on using the changeset viewer.