Processing Statement Blocks

This procedure processes blocks of statements between two tokens. It is used to process begin - end and Repeat - end blocks.
Procedure TStatement.ProcessStatementsBetweenTokens (StartToken, EndToken: TToken);
Var BlockStatements: TIntermediateCodeOffsets;
    StatementProcessed: Boolean;
    Statement: TStatement;
begin
  ExpectTokenAndGetNext (StartToken);
  BlockStatements.NumberOfStatements := 0;
  Repeat
    StatementProcessed := Statement.ProcessStatement;
    Statement.AddIntermediateCodeSubroutine (BlockStatements);
    If Token = EndToken then Break;
    If Token <> Token_Semicolon then
      If StatementProcessed then Error (SemicolonExpected) else Error (ErrorInStatement);
    GetNextToken;
  until False;
  Generate_icGoSub_ForEachSubroutine (BlockStatements);
  MarkSourceLineNumber (GetCurrentProgramBlockSourceLineNumber);
  StatementCode := EndSubroutine;
  GetNextToken;
end;
Procedure TStatement.AddIntermediateCodeSubroutine (Var IntermediateCodeOffsets: TIntermediateCodeOffsets);
begin
  AddCallToIntermediateCodeSubroutine (IntermediateCodeOffsets, StatementCode);
end;
 
 
 
© 2017 Turbo Pascal | Privacy Policy