Changeset 205 for branches/interpreter2


Ignore:
Timestamp:
Apr 20, 2020, 1:10:44 AM (5 years ago)
Author:
chronos
Message:
  • Added: Support for repeat-until.
Location:
branches/interpreter2
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter2

    • Property svn:ignore
      •  

        old new  
        44interpreter.res
        55heaptrclog.trc
         6Generated
  • branches/interpreter2/Test.pas

    r204 r205  
    2121
    2222  // While-Do
     23  WriteLn('WhileDo');
    2324  I := 5;
    2425  while I <> 0 do begin
     
    2728  end;
    2829 
     30  // Repeat-Until
     31  I := 5;
     32  WriteLn('RepeatUntil');
     33  repeat
     34    WriteLn(IntToStr(I));
     35    I := I - 1;
     36  until I = 0;
     37
    2938  // For-To-Do
     39  WriteLn('ForToDo');
    3040  for I := 0 to 5 do begin
    3141    WriteLn(IntToStr(I));   
  • branches/interpreter2/UExecutor.pas

    r203 r205  
    102102    procedure ExecuteIfThenElse(Block: TExecutorBlock; IfThenElse: TIfThenElse);
    103103    procedure ExecuteWhileDo(Block: TExecutorBlock; WhileDo: TWhileDo);
     104    procedure ExecuteRepeatUntil(Block: TExecutorBlock; RepeatUntil: TRepeatUntil);
    104105    procedure ExecuteForToDo(Block: TExecutorBlock; ForToDo: TForToDo);
    105106    procedure ExecuteBlock(ParentBlock: TExecutorBlock; Block: TBlock);
     
    432433  else if Command is TIfThenElse then ExecuteIfThenElse(Block, TIfThenElse(Command))
    433434  else if Command is TWhileDo then ExecuteWhileDo(Block, TWhileDo(Command))
     435  else if Command is TRepeatUntil then ExecuteRepeatUntil(Block, TRepeatUntil(Command))
    434436  else if Command is TForToDo then ExecuteForToDo(Block, TForToDo(Command))
    435437  else raise Exception.Create('Unsupported command type');
     
    458460      if not TValueBoolean(Value).Value then Break;
    459461      ExecuteCommand(Block, WhileDo.Command);
     462    end else raise Exception.Create('Expected boolean value.');
     463    Value.Free;
     464  end;
     465end;
     466
     467procedure TExecutor.ExecuteRepeatUntil(Block: TExecutorBlock;
     468  RepeatUntil: TRepeatUntil);
     469var
     470  Value: TValue;
     471  I: Integer;
     472begin
     473  while True do begin
     474    for I := 0 to RepeatUntil.Commands.Count - 1 do
     475      ExecuteCommand(Block, TCommand(RepeatUntil.Commands[I]));
     476    Value := ExecuteExpression(Block, RepeatUntil.Expression);
     477    if Value is TValueBoolean then begin
     478      if TValueBoolean(Value).Value then Break;
    460479    end else raise Exception.Create('Expected boolean value.');
    461480    Value.Free;
  • branches/interpreter2/UFormMain.pas

    r204 r205  
    66
    77uses
    8   Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls,
    9   SynHighlighterPas, SynEdit, USource;
     8  Classes, SysUtils, Forms, Controls, Graphics, Dialogs, StdCtrls, Menus,
     9  ActnList, SynHighlighterPas, SynEdit, USource;
    1010
    1111type
     
    5151
    5252uses
    53   UParser, UExecutor, UGenerator, UGeneratorPhp;
     53  UParser, UExecutor, UGeneratorPascal, UGeneratorPhp;
    5454
    5555{ TFormMain }
     
    126126procedure TFormMain.ButtonGenerateClick(Sender: TObject);
    127127var
    128   Generator: TGenerator;
     128  Generator: TGeneratorPascal;
    129129begin
    130130  ButtonCompile.Click;
    131131  MemoOutput.Lines.Clear;
    132132  if Assigned(Prog) then begin
    133     Generator := TGenerator.Create;
     133    Generator := TGeneratorPascal.Create;
    134134    Generator.Prog := Prog;
    135135    Generator.Generate;
  • branches/interpreter2/UGenerator.pas

    r204 r205  
    66
    77uses
    8   Classes, SysUtils, strutils, USource;
     8  Classes, SysUtils, strutils;
    99
    1010type
    11 
    12   { TGenerator }
    13 
    1411  TGenerator = class
    1512  private
    16     Indent: Integer;
     13    FIndent: Integer;
     14    procedure SetIndent(AValue: Integer);
     15  public
     16    Output: string;
    1717    procedure AddText(Text: string);
    1818    procedure AddTextLine(Text: string = '');
    19     procedure GenerateProgram(Block: TBlock;  Prog:TProgram);
    20     procedure GenerateBlock(ParentBlock: TBlock; Block: TBlock);
    21     procedure GenerateBlockVar(ParentBlock: TBlock; Block: TBlock);
    22     procedure GenerateBlockConst(ParentBlock: TBlock; Block: TBlock);
    23     procedure GenerateBeginEnd(Block: TBlock; BeginEnd: TBeginEnd);
    24     procedure GenerateCommand(Block: TBlock; Command: TCommand);
    25     procedure GenerateIfThenElse(Block: TBlock; IfThenElse: TIfThenElse);
    26     procedure GenerateWhileDo(Block: TBlock; WhileDo: TWhileDo);
    27     procedure GenerateForToDo(Block: TBlock; ForToDo: TForToDo);
    28     procedure GenerateFunctionCall(Block: TBlock; FunctionCall: TFunctionCall);
    29     procedure GenerateAssignment(Block: TBlock; Assignment: TAssignment);
    30     procedure GenerateExpression(Block: TBlock; Expression: TExpression);
    31     procedure GenerateExpressionOperation(Block: TBlock; Expression: TExpressionOperation);
    32     procedure GenerateExpressionOperand(Block: TBlock; Expression: TExpressionOperand);
    33     procedure GenerateValue(Value: TValue);
    34   public
    35     Prog: TProgram;
    36     Output: string;
    37     procedure Generate;
     19    property Indent: Integer read FIndent write SetIndent;
    3820  end;
     21
    3922
    4023implementation
    4124
    42 { TGenerator }
    43 
    44 procedure TGenerator.GenerateCommand(Block: TBlock; Command: TCommand);
     25procedure TGenerator.SetIndent(AValue: Integer);
    4526begin
    46   if Command is TBeginEnd then GenerateBeginEnd(Block, TBeginEnd(Command))
    47   else if Command is TFunctionCall then GenerateFunctionCall(Block, TFunctionCall(Command))
    48   else if Command is TAssignment then GenerateAssignment(Block, TAssignment(Command))
    49   else if Command is TIfThenElse then GenerateIfThenElse(Block, TIfThenElse(Command))
    50   else if Command is TWhileDo then GenerateWhileDo(Block, TWhileDo(Command))
    51   else if Command is TForToDo then GenerateForToDo(Block, TForToDo(Command))
    52   else raise Exception.Create('Unsupported command type');
    53 end;
    54 
    55 procedure TGenerator.GenerateIfThenElse(Block: TBlock; IfThenElse: TIfThenElse);
    56 begin
    57   AddText('if ');
    58   GenerateExpression(Block, IfThenElse.Expression);
    59   AddText(' then ');
    60   GenerateCommand(Block, IfThenElse.CommandThen);
    61   if Assigned(IfThenElse.CommandElse) then begin
    62     AddText(' else ');
    63     GenerateCommand(Block, IfThenElse.CommandElse);
     27  if FIndent = AValue then Exit;
     28  if AValue > FIndent then begin
     29    Output := Output + DupeString('  ', AValue - FIndent);
     30  end else
     31  if AValue < FIndent then begin
     32    Output := Copy(Output, 1, Length(Output) - (FIndent - AValue) * 2);
    6433  end;
    65 end;
    66 
    67 procedure TGenerator.GenerateWhileDo(Block: TBlock; WhileDo: TWhileDo);
    68 begin
    69   AddText('while ');
    70   GenerateExpression(Block, WhileDo.Expression);
    71   AddText(' do ');
    72   GenerateCommand(Block, WhileDo.Command);
    73 end;
    74 
    75 procedure TGenerator.GenerateForToDo(Block: TBlock; ForToDo: TForToDo);
    76 begin
    77   AddText('for ');
    78   AddText(ForToDo.VariableRef.Name);
    79   AddText(' := ');
    80   GenerateExpression(Block, ForToDo.ExpressionFrom);
    81   AddText(' to ');
    82   GenerateExpression(Block, ForToDo.ExpressionTo);
    83   AddText(' do ');
    84   GenerateCommand(Block, ForToDo.Command);
    85 end;
    86 
    87 procedure TGenerator.GenerateFunctionCall(Block: TBlock;
    88   FunctionCall: TFunctionCall);
    89 var
    90   I: Integer;
    91 begin
    92   AddText(FunctionCall.FunctionDef.Name);
    93   if FunctionCall.Params.Count > 0 then begin
    94     AddText('(');
    95     for I := 0 to FunctionCall.Params.Count - 1 do
    96       GenerateExpression(Block, TExpression(FunctionCall.Params[I]));
    97     AddText(')');
    98   end;
    99 end;
    100 
    101 procedure TGenerator.GenerateAssignment(Block: TBlock; Assignment: TAssignment);
    102 begin
    103   AddText(Assignment.Variable.Name);
    104   AddText(' := ');
    105   GenerateExpression(Block, Assignment.Expression);
    106 end;
    107 
    108 procedure TGenerator.GenerateExpression(Block: TBlock; Expression: TExpression);
    109 begin
    110   if Expression is TExpressionOperation then
    111     GenerateExpressionOperation(Block, TExpressionOperation(Expression))
    112   else
    113   if Expression is TExpressionOperand then
    114     GenerateExpressionOperand(Block, TExpressionOperand(Expression))
    115   else raise Exception.Create('Unknown expression class.');
    116 end;
    117 
    118 procedure TGenerator.GenerateExpressionOperation(Block: TBlock;
    119   Expression: TExpressionOperation);
    120 var
    121   I: Integer;
    122 begin
    123   for I := 0 to Expression.Items.Count - 1 do begin
    124     if I > 0 then begin
    125       AddText(' ');
    126       if Expression.Operation = eoAdd then AddText('+')
    127       else if Expression.Operation = eoSub then AddText('-')
    128       else if Expression.Operation = eoEqual then AddText('=')
    129       else if Expression.Operation = eoNotEqual then AddText('<>');
    130       AddText(' ');
    131     end;
    132     GenerateExpression(Block, TExpression(Expression.Items[I]));
    133   end;
    134 end;
    135 
    136 procedure TGenerator.GenerateExpressionOperand(Block: TBlock;
    137   Expression: TExpressionOperand);
    138 begin
    139   case Expression.OperandType of
    140     otFunctionCall: GenerateFunctionCall(Block, Expression.FunctionCall);
    141     otConstantDirect: GenerateValue(Expression.ConstantDirect.Value);
    142     otConstantRef: AddText(Expression.ConstantRef.Name);
    143     otVariableRef: AddText(Expression.VariableRef.Name);
    144     else raise Exception.Create('Unsupported exception operand type.');
    145   end;
    146 end;
    147 
    148 procedure TGenerator.GenerateValue(Value: TValue);
    149 begin
    150   if Value is TValueBoolean then begin
    151     if TValueBoolean(Value).Value then AddText('True') else AddText('False');
    152   end else if Value is TValueString then AddText('''' + StringReplace(TValueString(Value).Value, '''', '''''', [rfReplaceAll]) + '''')
    153   else if Value is TValueInteger then AddText(IntToStr(TValueInteger(Value).Value))
    154   else raise Exception.Create('Unsupported value type.');
     34  FIndent := AValue;
    15535end;
    15636
     
    16545end;
    16646
    167 procedure TGenerator.GenerateProgram(Block: TBlock; Prog: TProgram);
    168 begin
    169   if Prog.Name <> '' then AddTextLine('program ' + Prog.Name + ';');
    170   GenerateBlock(Block, Prog.Block);
    171   AddTextLine('.');
    172 end;
    173 
    174 procedure TGenerator.GenerateBlock(ParentBlock: TBlock; Block: TBlock);
    175 begin
    176   GenerateBlockConst(ParentBlock, Block);
    177   GenerateBlockVar(ParentBlock, Block);
    178   GenerateBeginEnd(ParentBlock, Block.BeginEnd);
    179 end;
    180 
    181 procedure TGenerator.GenerateBlockVar(ParentBlock: TBlock; Block: TBlock);
    182 var
    183   I: Integer;
    184   Variable: TVariable;
    185 begin
    186   if Block.Variables.Count > 0 then begin
    187     AddText('var');
    188     Inc(Indent);
    189     AddTextLine;
    190     for I := 0 to Block.Variables.Count - 1 do begin
    191       Variable := TVariable(Block.Variables[I]);
    192       AddTextLine(Variable.Name + ': ' + Variable.TypeRef.Name + ';');
    193     end;
    194     Dec(Indent);
    195     AddTextLine;
    196   end;
    197 end;
    198 
    199 procedure TGenerator.GenerateBlockConst(ParentBlock: TBlock; Block: TBlock);
    200 var
    201   I: Integer;
    202   Constant: TConstant;
    203 begin
    204   if Block.Constants.Count > 0 then begin
    205     AddText('const');
    206     Inc(Indent);
    207     AddTextLine;
    208     for I := 0 to Block.Constants.Count - 1 do begin
    209       Constant := TConstant(Block.Constants[I]);
    210       AddText(Constant.Name + ': ' + Constant.TypeRef.Name + ' = ');
    211       GenerateValue(Constant.Value);
    212       AddTextLine(';');
    213     end;
    214     Dec(Indent);
    215     AddTextLine;
    216   end;
    217 end;
    218 
    219 procedure TGenerator.GenerateBeginEnd(Block: TBlock; BeginEnd: TBeginEnd);
    220 var
    221   I: Integer;
    222 begin
    223   AddText('begin');
    224   Inc(Indent);
    225   AddTextLine('');
    226   for I := 0 to BeginEnd.Commands.Count - 1 do begin
    227     GenerateCommand(Block, TCommand(BeginEnd.Commands[I]));
    228     AddText(';');
    229     if I < BeginEnd.Commands.Count - 1 then AddTextLine('');
    230   end;
    231   Dec(Indent);
    232   AddTextLine('');
    233   AddText('end');
    234 end;
    235 
    236 procedure TGenerator.Generate;
    237 begin
    238   Output := '';
    239   GenerateProgram(Prog.SystemBlock, Prog);
    240 end;
    241 
    24247end.
    24348
  • branches/interpreter2/UGeneratorPhp.pas

    r204 r205  
    66
    77uses
    8   Classes, SysUtils, strutils, USource;
     8  Classes, SysUtils, strutils, USource, UGenerator;
    99
    1010type
     
    1212  { TGeneratorPhp }
    1313
    14   TGeneratorPhp = class
     14  TGeneratorPhp = class(TGenerator)
    1515  private
    16     Indent: Integer;
    17     procedure AddText(Text: string);
    18     procedure AddTextLine(Text: string = '');
    1916    procedure GenerateProgram(Block: TBlock;  Prog:TProgram);
    2017    procedure GenerateBlock(ParentBlock: TBlock; Block: TBlock);
    21     procedure GenerateBlockVar(ParentBlock: TBlock; Block: TBlock);
    2218    procedure GenerateBlockConst(ParentBlock: TBlock; Block: TBlock);
    2319    procedure GenerateBlockFunctions(ParentBlock: TBlock; Block: TBlock);
     
    2622    procedure GenerateIfThenElse(Block: TBlock; IfThenElse: TIfThenElse);
    2723    procedure GenerateWhileDo(Block: TBlock; WhileDo: TWhileDo);
     24    procedure GenerateRepeatUntil(Block: TBlock; RepeatUntil: TRepeatUntil);
    2825    procedure GenerateForToDo(Block: TBlock; ForToDo: TForToDo);
    2926    procedure GenerateFunctionCall(Block: TBlock; FunctionCall: TFunctionCall);
     
    3532  public
    3633    Prog: TProgram;
    37     Output: string;
    3834    procedure Generate;
    3935  end;
     
    5046  else if Command is TIfThenElse then GenerateIfThenElse(Block, TIfThenElse(Command))
    5147  else if Command is TWhileDo then GenerateWhileDo(Block, TWhileDo(Command))
     48  else if Command is TRepeatUntil then GenerateRepeatUntil(Block, TRepeatUntil(Command))
    5249  else if Command is TForToDo then GenerateForToDo(Block, TForToDo(Command))
    5350  else raise Exception.Create('Unsupported command type');
     
    7370  AddText(' ) ');
    7471  GenerateCommand(Block, WhileDo.Command);
     72end;
     73
     74procedure TGeneratorPhp.GenerateRepeatUntil(Block: TBlock;
     75  RepeatUntil: TRepeatUntil);
     76var
     77  I: Integer;
     78begin
     79  AddTextLine('while (true)');
     80  AddTextLine('{');
     81  Indent := Indent + 1;
     82  for I := 0 to RepeatUntil.Commands.Count - 1 do begin
     83    GenerateCommand(Block, TCommand(RepeatUntil.Commands[I]));
     84    AddTextLine(';');
     85  end;
     86  AddText('if (');
     87  GenerateExpression(Block, RepeatUntil.Expression);
     88  AddTextLine(') break;');
     89  Indent := Indent - 1;
     90  AddTextLine('}');
    7591end;
    7692
     
    128144  for I := 0 to Expression.Items.Count - 1 do begin
    129145    if I > 0 then begin
    130       AddText(' ');
    131146      if Expression.Operation = eoAdd then begin
    132147        if Expression.TypeRef.Name = 'string' then AddText('.')
    133         else AddText('+');
     148        else AddText(' + ');
    134149      end
    135       else if Expression.Operation = eoSub then AddText('-')
    136       else if Expression.Operation = eoEqual then AddText('==')
    137       else if Expression.Operation = eoNotEqual then AddText('!=');
    138       AddText(' ');
     150      else if Expression.Operation = eoSub then AddText(' - ')
     151      else if Expression.Operation = eoEqual then AddText(' == ')
     152      else if Expression.Operation = eoNotEqual then AddText(' != ');
    139153    end;
    140154    GenerateExpression(Block, TExpression(Expression.Items[I]));
     
    163177end;
    164178
    165 procedure TGeneratorPhp.AddText(Text: string);
    166 begin
    167   Output := Output + Text;
    168 end;
    169 
    170 procedure TGeneratorPhp.AddTextLine(Text: string);
    171 begin
    172   AddText(Text + LineEnding + DupeString('  ', Indent));
    173 end;
    174 
    175179procedure TGeneratorPhp.GenerateProgram(Block: TBlock; Prog: TProgram);
    176180begin
     
    185189begin
    186190  GenerateBlockConst(ParentBlock, Block);
    187   //GenerateBlockVar(ParentBlock, Block);
    188191  GenerateBlockFunctions(ParentBlock, Block);
    189192  if Block.BeginEnd.Commands.Count > 0 then
    190193    GenerateBeginEnd(ParentBlock, Block.BeginEnd);
    191 end;
    192 
    193 procedure TGeneratorPhp.GenerateBlockVar(ParentBlock: TBlock; Block: TBlock);
    194 var
    195   I: Integer;
    196   Variable: TVariable;
    197 begin
    198   if Block.Variables.Count > 0 then begin
    199     AddText('var');
    200     Inc(Indent);
    201     AddTextLine;
    202     for I := 0 to Block.Variables.Count - 1 do begin
    203       Variable := TVariable(Block.Variables[I]);
    204       AddTextLine(Variable.Name + ': ' + Variable.TypeRef.Name + ';');
    205     end;
    206     Dec(Indent);
    207     AddTextLine;
    208   end;
    209194end;
    210195
     
    239224    if FunctionDef.InternalName <> '' then begin
    240225      AddTextLine('{');
     226      Indent := Indent + 1;
    241227      if FunctionDef.InternalName = 'WriteLn' then AddTextLine('echo($Text."\n");')
    242228      else if FunctionDef.InternalName = 'Write' then AddTextLine('echo($Text);')
    243229      else if FunctionDef.InternalName = 'IntToStr' then AddTextLine('return $Value;')
    244230      else if FunctionDef.InternalName = 'StrToInt' then AddTextLine('return $Value;');
    245       Dec(Indent);
     231      Indent := Indent - 1;
    246232      AddTextLine('}');
    247233    end else begin
     
    257243  I: Integer;
    258244begin
    259   AddText('{');
    260   Inc(Indent);
    261   AddTextLine('');
     245  AddTextLine('{');
     246  Indent := Indent + 1;
    262247  for I := 0 to BeginEnd.Commands.Count - 1 do begin
    263248    GenerateCommand(Block, TCommand(BeginEnd.Commands[I]));
    264     AddText(';');
    265     if I < BeginEnd.Commands.Count - 1 then AddTextLine('');
    266   end;
    267   Dec(Indent);
    268   AddTextLine('');
     249    AddTextLine(';');
     250  end;
     251  Indent := Indent - 1;
    269252  AddText('}');
    270253end;
  • branches/interpreter2/UParser.pas

    r204 r205  
    3232    function ParseIfThenElse(Block: TBlock; out IfThenElse: TIfThenElse): Boolean;
    3333    function ParseWhileDo(Block: TBlock; out WhileDo: TWhileDo): Boolean;
     34    function ParseRepeatUntil(Block: TBlock; out RepeatUntil: TRepeatUntil): Boolean;
    3435    function ParseForToDo(Block: TBlock; out ForToDo: TForToDo): Boolean;
    3536    procedure TokenizerError(Pos: TPoint; Text: string);
     
    5556begin
    5657  if Tokenizer.CheckNext('begin', tkKeyword) then begin
     58    Tokenizer.Expect('begin', tkKeyword);
    5759    BeginEnd := TBeginEnd.Create;
    5860    Result := True;
    59     Tokenizer.Expect('begin', tkKeyword);
    6061    while not Tokenizer.CheckNext('end', tkKeyword) do begin
    6162      if ParseCommand(Block, Command) then begin
     
    119120  WhileDo: TWhileDo;
    120121  ForToDo: TForToDo;
     122  RepeatUntil: TRepeatUntil;
    121123begin
    122124  if ParseIfThenElse(Block, IfThenElse) then begin
     
    139141    Result := True;
    140142    Command := FunctionCall;
     143  end else
     144  if ParseRepeatUntil(Block, RepeatUntil) then begin
     145    Result := True;
     146    Command := RepeatUntil;
    141147  end else
    142148  if ParseAssignment(Block, Assignment) then begin
     
    496502end;
    497503
     504function TParser.ParseRepeatUntil(Block: TBlock; out RepeatUntil: TRepeatUntil
     505  ): Boolean;
     506var
     507  Expression: TExpression;
     508  Command: TCommand;
     509begin
     510  Result := False;
     511  if Tokenizer.CheckNext('repeat', tkKeyword) then begin
     512    Tokenizer.Expect('repeat', tkKeyword);
     513    RepeatUntil := TRepeatUntil.Create;
     514    Result := True;
     515    while not Tokenizer.CheckNext('until', tkKeyword) do begin
     516      if ParseCommand(Block, Command) then begin
     517        RepeatUntil.Commands.Add(Command);
     518        Tokenizer.Expect(';', tkSpecialSymbol);
     519      end else begin
     520        Error('Unexpected token ' + Tokenizer.GetNext.Text);
     521        Result := False;
     522        Break;
     523      end;
     524    end;
     525    Tokenizer.Expect('until', tkKeyword);
     526    if ParseExpression(Block, Expression) then begin
     527      RepeatUntil.Expression.Free;
     528      RepeatUntil.Expression := Expression;
     529    end else Error('Expected expression');
     530  end else Result := False;
     531end;
     532
    498533function TParser.ParseForToDo(Block: TBlock; out ForToDo: TForToDo): Boolean;
    499534var
  • branches/interpreter2/USource.pas

    r204 r205  
    117117  end;
    118118
     119  TCommands = class(TObjectList)
     120  end;
     121
    119122  { TFunctionCall }
    120123
     
    129132
    130133  TBeginEnd = class(TCommand)
    131     Commands: TObjectList;
     134    Commands: TCommands;
    132135    procedure Clear;
    133136    constructor Create;
     
    197200    Expression: TExpression;
    198201    Command: TCommand;
     202    constructor Create;
     203    destructor Destroy; override;
     204  end;
     205
     206  { TRepeatUntil }
     207
     208  TRepeatUntil = class(TCommand)
     209    Expression: TExpression;
     210    Commands: TCommands;
    199211    constructor Create;
    200212    destructor Destroy; override;
     
    243255implementation
    244256
     257{ TRepeatUntil }
     258
     259constructor TRepeatUntil.Create;
     260begin
     261  Expression := TExpression.Create;
     262  Commands := TCommands.Create;
     263end;
     264
     265destructor TRepeatUntil.Destroy;
     266begin
     267  Expression.Free;
     268  Commands.Free;
     269  inherited Destroy;
     270end;
     271
    245272{ TValueBoolean }
    246273
     
    579606constructor TBeginEnd.Create;
    580607begin
    581   Commands := TObjectList.Create;
     608  Commands := TCommands.Create;
    582609end;
    583610
  • branches/interpreter2/UTokenizer.pas

    r202 r205  
    149149  (Text = 'var') or (Text = 'const') or (Text = 'if') or (Text = 'then') or
    150150  (Text = 'else') or (Text = 'while') or (Text = 'do') or (Text = 'for') or
    151   (Text = 'to');
     151  (Text = 'to') or (Text = 'repeat') or (Text = 'until');
    152152end;
    153153
  • branches/interpreter2/interpreter.lpi

    r204 r205  
    7171      </Item2>
    7272    </RequiredPackages>
    73     <Units Count="9">
     73    <Units Count="10">
    7474      <Unit0>
    7575        <Filename Value="interpreter.lpr"/>
     
    104104      </Unit6>
    105105      <Unit7>
    106         <Filename Value="UGenerator.pas"/>
     106        <Filename Value="UGeneratorPascal.pas"/>
    107107        <IsPartOfProject Value="True"/>
    108108      </Unit7>
     
    111111        <IsPartOfProject Value="True"/>
    112112      </Unit8>
     113      <Unit9>
     114        <Filename Value="UGenerator.pas"/>
     115        <IsPartOfProject Value="True"/>
     116      </Unit9>
    113117    </Units>
    114118  </ProjectOptions>
  • branches/interpreter2/interpreter.lpr

    r204 r205  
    99  Interfaces, SysUtils, // this includes the LCL widgetset
    1010  Forms, UFormMain, UParser, UTokenizer, USource, UExecutor, UInterpreter,
    11   UGenerator, UGeneratorPhp
     11  UGeneratorPascal, UGeneratorPhp, UGenerator
    1212  { you can add units after this };
    1313
Note: See TracChangeset for help on using the changeset viewer.