Ignore:
Timestamp:
Feb 2, 2017, 11:35:09 PM (8 years ago)
Author:
chronos
Message:
  • Modified: Improved parsin and prepared analyzed source execution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/interpreter/Execute3.pas

    r96 r97  
    1111implementation
    1212
     13procedure ExecuteCommand(Command: PCommand); forward;
     14
     15procedure ExecuteBeginEnd(BeginEnd: PBeginEnd);
     16var
     17  I: Integer;
     18begin
     19  for I := 0 to Length(BeginEnd^.Commands) - 1 do
     20    ExecuteCommand(@BeginEnd^.Commands[I]);
     21end;
     22
     23function ExecuteExpression(Expression: PExpression): Boolean;
     24begin
     25
     26end;
     27
     28procedure ExecuteWhileDo(WhileDo: PWhileDo);
     29begin
     30  if ExecuteExpression(@WhileDo^.Condition) then
     31    ExecuteCommand(@WhileDo^.Command);
     32end;
     33
     34procedure ExecuteIfThenElse(IfThenElse: PIfThenElse);
     35begin
     36  if ExecuteExpression(@IfThenElse^.Condition) then
     37    ExecuteCommand(@IfThenElse^.DoThen)
     38    else ExecuteCommand(@IfThenElse^.DoElse);
     39end;
     40
     41procedure ExecuteExecution(Execution: PExecution);
     42begin
     43  // Set parameters
     44  ExecuteBeginEnd(@Execution^.Func^.BeginEnd);
     45end;
     46
     47procedure ExecuteAssignment(Assignment: PAssignment);
     48begin
     49
     50end;
     51
     52procedure ExecuteCommand(Command: PCommand);
     53begin
     54  case Command^.CmdType of
     55    ctBeginEnd: ExecuteBeginEnd(PBeginEnd(Command^.Ptr));
     56    ctWhileDo: ExecuteWhileDo(PWhileDo(Command^.Ptr));
     57    ctIfThenElse: ExecuteIfThenElse(PIfThenElse(Command^.Ptr));
     58    ctExecution: ExecuteExecution(PExecution(Command^.Ptr));
     59    ctAssignment: ExecuteAssignment(PAssignment(Command^.Ptr));
     60  end;
     61end;
     62
    1363procedure ExecuteProgram(ProgramCode: PProgramCode);
    1464begin
    15 
     65  ExecuteBeginEnd(@ProgramCode^.BeginEnd);
    1666end;
    1767
Note: See TracChangeset for help on using the changeset viewer.