Ignore:
Timestamp:
Jan 18, 2018, 1:30:58 PM (7 years ago)
Author:
chronos
Message:
  • Fixed: Now arrays of string and integer are supported and executed correctly by executor.
  • Added: IfNotEqual command.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/easy compiler/UCompiler.pas

    r148 r149  
    5050      ): Boolean;
    5151    function ParseFunctionCall(SourceCode: TSourceCode; out FunctionCall: TCommandFunctionCall): Boolean;
    52     function ParseIfEqual(SourceCode: TSourceCode; out IfZero: TCommandIfEqual): Boolean;
     52    function ParseIfEqual(SourceCode: TSourceCode; out IfEqual: TCommandIfEqual): Boolean;
     53    function ParseIfNotEqual(SourceCode: TSourceCode; out IfNotEqual: TCommandIfNotEqual): Boolean;
    5354    function ParseReference(SourceCode: TSourceCode): TSourceReference;
    5455    function ParseReferenceVariable(SourceCode: TSourceCode): TSourceReference;
     
    327328end;
    328329
    329 function TCompiler.ParseIfEqual(SourceCode: TSourceCode; out IfZero: TCommandIfEqual): Boolean;
     330function TCompiler.ParseIfEqual(SourceCode: TSourceCode; out IfEqual: TCommandIfEqual): Boolean;
    330331var
    331332  Token: TSourceToken;
     
    338339  Keyword := LowerCase(Token.Text);
    339340  if Keyword = 'ifequal' then begin
    340     IfZero := TCommandIfEqual.Create;
    341     IfZero.Reference1 := ParseReference(SourceCode);
    342     IfZero.Reference2 := ParseReference(SourceCode);
     341    IfEqual := TCommandIfEqual.Create;
     342    IfEqual.Reference1 := ParseReference(SourceCode);
     343    IfEqual.Reference2 := ParseReference(SourceCode);
     344    Result := True;
     345  end;
     346  if not Result then Tokenizer.TokenIndex := TokenIndex;
     347end;
     348
     349function TCompiler.ParseIfNotEqual(SourceCode: TSourceCode; out
     350  IfNotEqual: TCommandIfNotEqual): Boolean;
     351var
     352  Token: TSourceToken;
     353  TokenIndex: Integer;
     354  Keyword: string;
     355begin
     356  Result := False;
     357  TokenIndex := Tokenizer.TokenIndex;
     358  Token := Tokenizer.GetNext;
     359  Keyword := LowerCase(Token.Text);
     360  if Keyword = 'ifnotequal' then begin
     361    IfNotEqual := TCommandIfNotEqual.Create;
     362    IfNotEqual.Reference1 := ParseReference(SourceCode);
     363    IfNotEqual.Reference2 := ParseReference(SourceCode);
    343364    Result := True;
    344365  end;
     
    390411var
    391412  CommandBeginEnd: TCommandBeginEnd;
    392   CommandIfZero: TCommandIfEqual;
     413  CommandIfEqual: TCommandIfEqual;
    393414  CommandFunctionCall: TCommandFunctionCall;
    394415  CommandBreak: TCommandBreak;
    395416  CommandRepeat: TCommandRepeat;
     417  CommandIfNotEqual: TCommandIfNotEqual;
    396418begin
    397419  Command := nil;
     
    401423    Command := CommandBeginEnd;
    402424  end else
    403   if ParseIfEqual(SourceCode, CommandIfZero) then begin
    404     Command := CommandIfZero;
     425  if ParseIfEqual(SourceCode, CommandIfEqual) then begin
     426    Command := CommandIfEqual;
     427  end else
     428  if ParseIfNotEqual(SourceCode, CommandIfNotEqual) then begin
     429    Command := CommandIfNotEqual;
    405430  end else
    406431  if ParseBreak(SourceCode, CommandBreak) then begin
Note: See TracChangeset for help on using the changeset viewer.