Ignore:
Timestamp:
Jan 17, 2018, 3:34:13 PM (7 years ago)
Author:
chronos
Message:
  • Added: Support for Repeat blocks and Break command.
File:
1 edited

Legend:

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

    r146 r147  
    1010type
    1111  TSourceCommand = class
    12   end;
    13 
    14   TSourceInstructions = class(TObjectList)
     12    Parent: TSourceCommand;
     13  end;
     14
     15  TSourceCommands = class(TObjectList)
    1516  end;
    1617
     
    140141  TCommandBeginEnd = class(TSourceCommand)
    141142    SourceCode: TSourceCode;
    142     Instructions: TSourceInstructions;
     143    Commands: TSourceCommands;
    143144    constructor Create;
    144145    destructor Destroy; override;
    145146  end;
    146147
     148  { TCommandIfZero }
     149
    147150  TCommandIfZero = class(TSourceCommand)
    148     Variable: TSourceVariable;
     151    Variable: TSourceReferenceVariable;
     152    destructor Destroy; override;
     153  end;
     154
     155  { TCommandRepeat }
     156
     157  TCommandRepeat = class(TSourceCommand)
     158    Command: TSourceCommand;
     159    destructor Destroy; override;
     160  end;
     161
     162  TCommandBreak = class(TSourceCommand)
     163  end;
     164
     165  TCommandContinue = class(TSourceCommand)
    149166  end;
    150167
     
    167184implementation
    168185
     186{ TCommandIfZero }
     187
     188destructor TCommandIfZero.Destroy;
     189begin
     190  Variable.Free;
     191  inherited Destroy;
     192end;
     193
     194{ TCommandRepeat }
     195
     196destructor TCommandRepeat.Destroy;
     197begin
     198  Command.Free;
     199  inherited Destroy;
     200end;
     201
    169202{ TSourceConstant }
    170203
     
    192225constructor TCommandBeginEnd.Create;
    193226begin
    194   Instructions := TSourceInstructions.Create;
     227  Commands := TSourceCommands.Create;
    195228end;
    196229
    197230destructor TCommandBeginEnd.Destroy;
    198231begin
    199   Instructions.Free;
     232  Commands.Free;
    200233  inherited Destroy;
    201234end;
     
    388421
    389422  Funct := Functions.AddNew('increment');
     423  Funct.AddParameter('Variable', pkVariable);
     424  Funct.AddParameter('Addition', pkString);
     425
     426  Funct := Functions.AddNew('decrement');
    390427  Funct.AddParameter('Variable', pkVariable);
    391428  Funct.AddParameter('Addition', pkString);
Note: See TracChangeset for help on using the changeset viewer.