Press enter to see results or esc to cancel.

Processing Source Line Characters

The NextNonCommentCharacter function reads and processes characters from the source line buffer. It returns pointer to the next non-comment character. The null (#0) character means end of line. Turbo Pascal tries to read the next source line. If this fails it tries to return to the previous source file (if $I include file was loaded). Whitespace characters (#1 to space) are skipped. If comment is detected (‘{‘ or ‘(*‘ characters) it is processed together with compiler directives. In all other cases the function returns pointer to the source line character. This fuction is called by the function that extracts tokens.

Function NextNonCommentCharacter: PChar;
Var TempPtr: PChar;
    C: Char;
    TwoChars: TTwoChars;
begin
  TempPtr := Ptr (Seg (CurrentLine^), CurrentSourceFile^.CurrentPosition);
  Repeat
    C := TempPtr^;
    Inc (TempPtr);
    If C = #0 then begin
                     If NextLine then
                       begin
                         TempPtr := CurrentLine;
                         Continue;
                       end;
                     CurrentSourceFile^.CurrentPosition := Ofs (TempPtr^);
                     CreateSourceFilesRecord;
                     ReturnToPreviousSourceFile;
                     TempPtr := Ptr (Seg (CurrentLine^), CurrentSourceFile^.CurrentPosition);
                     Continue;
                   end;
    If C In [#1..' '] then Continue
      else begin
             TwoChars := PTwoChars (TempPtr - 1)^;
             If TwoChars.First = '{' then
               begin
                 ProcessComment (TempPtr, TwoChars.First);
                 Continue;
               end;
             If TwoChars.Both = '(*' then
               begin
                 Inc (TempPtr);
                 ProcessComment (TempPtr, TwoChars.Second);
                 Continue;
               end;
             NextNonCommentCharacter := TempPtr - 1;
             Exit;
           end;
  until False;
  NextNonCommentCharacter := TempPtr - 1;
end;