Ignore:
Timestamp:
Nov 25, 2023, 11:47:52 PM (12 months ago)
Author:
chronos
Message:
  • Fixed: Assembler and disassembler to work correctly with supported instructions.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ByteArray/Parser.pas

    r50 r59  
    4545    function CheckNextKind(Kind: TTokenKind): Boolean;
    4646    function CheckNextAndRead(Kind: TTokenKind; Value: string = ''): Boolean;
    47     procedure Expect(Kind: TTokenKind; Value: string = '');
     47    function Expect(Kind: TTokenKind; Value: string = ''): Boolean;
    4848    procedure Error(Text: string; Pos: TPoint);
    4949    procedure Reset;
     
    5757resourcestring
    5858  SUnknownCharacter = 'Unknown character %s';
     59  SExpectedButFound = 'Expected %s but %s found.';
    5960
    6061{ TParserPos }
     
    227228end;
    228229
    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);
     230function TParser.Expect(Kind: TTokenKind; Value: string = ''): Boolean;
     231var
     232  Token: TToken;
     233begin
     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;
    236240end;
    237241
Note: See TracChangeset for help on using the changeset viewer.