Changeset 17 for branches/Void/UCompilator.pas
- Timestamp:
- Nov 10, 2009, 11:13:51 AM (15 years ago)
- Location:
- branches/Void
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/Void
- Property svn:ignore
-
old new 7 7 *.dsk 8 8 *.~dsk 9 Output.bdsproj 10 Output.c 11 Output.dpr 12 Output.exe
-
- Property svn:ignore
-
branches/Void/UCompilator.pas
r16 r17 10 10 type 11 11 TOnErrorEvent = procedure (Text: string; var Terminate: Boolean; Position: TPoint) of object; 12 13 TErrorMessage = class 14 CodePosition: TPoint; 15 Text: string; 16 end; 12 17 13 18 TCompilator = class 14 19 private 15 20 FOnError: TOnErrorEvent; 16 procedure DoError( Text: string);21 procedure DoError(AText: string); 17 22 procedure ParseBeginEnd; 18 23 procedure ParseProgram; 19 24 procedure ParseVariableDefinition; 20 25 public 26 ErrorMessages: TList; 21 27 Model: TModel; 22 28 SourceCode: TStream; … … 33 39 { TCompilator } 34 40 35 procedure TCompilator.DoError( Text: string);41 procedure TCompilator.DoError(AText: string); 36 42 var 37 43 Terminate: Boolean; 38 44 begin 45 with TErrorMessage(ErrorMessages[ErrorMessages.Add(TErrorMessage.Create)]) do begin 46 CodePosition := Parser.TokenStartPosition; 47 Text := AText; 48 end; 39 49 Terminate := False; 40 if Assigned(FOnError) then FOnError( Text, Terminate, Parser.TokenStartPosition);50 if Assigned(FOnError) then FOnError(AText, Terminate, Parser.TokenStartPosition); 41 51 if Terminate then raise Exception.Create('Compilation terminated'); 42 52 end; … … 123 133 begin 124 134 Model.Clear; 135 for I := 0 to ErrorMessages.Count - 1 do 136 TErrorMessage(ErrorMessages[I]).Destroy; 137 ErrorMessages.Clear; 125 138 SourceCode.Position := 0; 126 139 Parser.Open(SourceCode); … … 250 263 constructor TCompilator.Create; 251 264 begin 265 ErrorMessages := TList.Create; 252 266 SourceCode := TMemoryStream.Create; 253 267 Model := TModel.Create; … … 256 270 257 271 destructor TCompilator.Destroy; 258 begin 272 var 273 I: Integer; 274 begin 275 for I := 0 to ErrorMessages.Count - 1 do 276 TErrorMessage(ErrorMessages[I]).Destroy; 277 ErrorMessages.Destroy; 259 278 SourceCode.Destroy; 260 279 Model.Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.