Changeset 59 for branches/ByteArray/Parser.pas
- Timestamp:
- Nov 25, 2023, 11:47:52 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray/Parser.pas
r50 r59 45 45 function CheckNextKind(Kind: TTokenKind): Boolean; 46 46 function CheckNextAndRead(Kind: TTokenKind; Value: string = ''): Boolean; 47 procedure Expect(Kind: TTokenKind; Value: string = '');47 function Expect(Kind: TTokenKind; Value: string = ''): Boolean; 48 48 procedure Error(Text: string; Pos: TPoint); 49 49 procedure Reset; … … 57 57 resourcestring 58 58 SUnknownCharacter = 'Unknown character %s'; 59 SExpectedButFound = 'Expected %s but %s found.'; 59 60 60 61 { TParserPos } … … 227 228 end; 228 229 229 procedure TParser.Expect(Kind: TTokenKind; Value: string = ''); 230 var 231 Token: TToken; 232 begin 233 Token := ReadNext; 234 if (Token.Kind <> Kind) or (LowerCase(Token.Value) <> LowerCase(Value)) then 235 Error('Expected ' + Value + ' but ' + Token.Value +' found.', Token.Pos); 230 function TParser.Expect(Kind: TTokenKind; Value: string = ''): Boolean; 231 var 232 Token: TToken; 233 begin 234 Result := True; 235 Token := ReadNext; 236 if (Token.Kind <> Kind) or (LowerCase(Token.Value) <> LowerCase(Value)) then begin 237 Result := False; 238 Error(Format(SExpectedButFound, [Value, Token.Value]), Token.Pos); 239 end; 236 240 end; 237 241
Note:
See TracChangeset
for help on using the changeset viewer.