Ignore:
Timestamp:
Jan 17, 2018, 2:25:45 PM (7 years ago)
Author:
chronos
Message:
  • Modified: ParseBeginEnd method split to several other items for parsing each specific command.
File:
1 edited

Legend:

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

    r145 r146  
    1414  private
    1515    Indent: Integer;
    16     function GenerateBeginEnd(BeginEnd: TSourceBeginEnd): string;
     16    function GenerateBeginEnd(BeginEnd: TCommandBeginEnd): string;
    1717    function IndentStr: string;
    1818  public
     
    4949end;
    5050
    51 function TSourceGenerator.GenerateBeginEnd(BeginEnd: TSourceBeginEnd): string;
     51function TSourceGenerator.GenerateBeginEnd(BeginEnd: TCommandBeginEnd): string;
    5252var
    53   Instruction: TSourceInstruction;
     53  Instruction: TSourceCommand;
    5454  I: Integer;
    5555  Value: TSourceValue;
     
    7777  with BeginEnd do
    7878  for I := 0 to Instructions.Count - 1 do begin
    79     Instruction := TSourceInstruction(Instructions[I]);
    80     if Instruction is TSourceFunctionCall then
    81     with TSourceFunctionCall(Instruction) do begin
     79    Instruction := TSourceCommand(Instructions[I]);
     80    if Instruction is TCommandFunctionCall then
     81    with TCommandFunctionCall(Instruction) do begin
    8282      if Name = 'print' then begin
    8383        Result := Result + IndentStr + 'Write(' + GenerateRef(TSourceReference(Parameters[0])) + ');' +
     
    101101      raise Exception.Create('Unsupported instruction name.');
    102102    end else
    103     if Instruction is TSourceBeginEnd then begin
    104       Result := Result + GenerateBeginEnd(TSourceBeginEnd(Instruction)) +
     103    if Instruction is TCommandBeginEnd then begin
     104      Result := Result + GenerateBeginEnd(TCommandBeginEnd(Instruction)) +
    105105        ';' + LineEnding;
     106    end else
     107    if Instruction is TCommandIfZero then begin
     108      Result := Result + IndentStr + 'if ' + TCommandIfZero(Instruction).Variable.Name + ' = 0 then ';
    106109    end else
    107110    raise Exception.Create('Unsupported instruction');
Note: See TracChangeset for help on using the changeset viewer.