Ignore:
Timestamp:
Aug 9, 2010, 2:24:24 PM (14 years ago)
Author:
george
Message:

Added support for setting cursor position to place of error code for error messages.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DelphiToC/Analyze/UPascalParser.pas

    r48 r49  
    1010
    1111type
    12   TOnErrorMessage = procedure (Text: string) of object;
     12  TOnErrorMessage = procedure (Text: string; Position: TPoint) of object;
    1313
    1414  TTokenType = (ttNone, ttIdentifier, ttConstantNumber, ttConstantString,
     
    8585begin
    8686  if Assigned(FOnErrorMessage) then
    87     FOnErrorMessage(Format(Text, Arguments));
     87    FOnErrorMessage(Format(Text, Arguments), CodePosition);
    8888end;
    8989
     
    172172procedure TBaseParser.Init;
    173173begin
     174  CodePosition := Point(1, 1);
    174175  CurrentChar := #0;
    175176  PreviousChar := #0;
     
    201202        Break;
    202203      end;
     204
    203205      if FNextTokenType = ttNone then begin
    204206        if IsWhiteSpace(CurrentChar) then FNextTokenType := ttWhiteSpace
     
    262264
    263265      if FNextTokenType <> ttNone then begin
     266        // Update cursor position
     267        Inc(CodePosition.X);
     268        if (CurrentChar = #13) then begin
     269          CodePosition.X := 1;
     270          Inc(CodePosition.Y);
     271        end;
     272
    264273        Inc(CodeStreamPosition);
    265274        PreviousChar := CurrentChar;
Note: See TracChangeset for help on using the changeset viewer.