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/UPascalCompiler.pas

    r48 r49  
    88  SysUtils, Variants, Classes, Graphics, Controls, Forms,
    99  Dialogs, UPascalSource, UCodeProducer, UPascalParser,
    10   UProducerC;
     10  UProducerC, Contnrs;
    1111
    1212type
     13
     14  TErrorMessage = class
     15    Text: string;
     16    Position: TPoint;
     17  end;
    1318
    1419  { TCompiler }
     
    1722  private
    1823    FOnErrorMessage: TOnErrorMessage;
    19     procedure ErrorMessage(Text: string);
     24    procedure ErrorMessage(Text: string; Position: TPoint);
    2025    procedure InitSystem;
    2126  public
     
    2429    Parser: TPascalParser;
    2530    Producer: TCodeProducer;
     31    ErrorMessages: TObjectList;
    2632    constructor Create;
    2733    procedure Compile;
     
    3743begin
    3844  InitSystem;
     45  ErrorMessages.Clear;
    3946  Parser.Init;
    4047  Parser.ParseAll(ProgramCode);
     
    5158  Parser.SourceCodeText := SourceCode;
    5259  Parser.OnErrorMessage := ErrorMessage;
     60  ErrorMessages := TObjectList.Create;
    5361end;
    5462
     
    5967  Parser.Free;
    6068  Producer.Free;
     69  ErrorMessages.Free;
    6170end;
    6271
    63 procedure TCompiler.ErrorMessage(Text: string);
     72procedure TCompiler.ErrorMessage(Text: string; Position: TPoint);
     73var
     74  NewMessage: TErrorMessage;
    6475begin
    65   if Assigned(FOnErrorMessage) then FOnErrorMessage(Text);
     76  NewMessage := TErrorMessage.Create;
     77  NewMessage.Text := Text;
     78  NewMessage.Position := Position;
     79  ErrorMessages.Add(NewMessage);
     80  if Assigned(FOnErrorMessage) then FOnErrorMessage(Text, Position);
    6681end;
    6782
Note: See TracChangeset for help on using the changeset viewer.