Changeset 44 for branches/DelphiToC/UPascalCompiler.pas
- Timestamp:
- Aug 9, 2010, 10:22:30 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DelphiToC/UPascalCompiler.pas
r43 r44 11 11 12 12 type 13 14 { TCompiler } 15 13 16 TCompiler = class 14 17 private 15 18 FOnErrorMessage: TOnErrorMessage; 16 19 procedure ErrorMessage(Text: string); 20 procedure Init; 17 21 public 18 22 ProgramCode: TProgram; … … 32 36 procedure TCompiler.Compile; 33 37 begin 34 Parser.CodePosition := 1; 38 Init; 39 Parser.Init; 35 40 try 36 TParserProgram.Parse(Parser,ProgramCode);41 Parser.ParseAll(ProgramCode); 37 42 except 38 43 on EEndOfData do ; … … 65 70 end; 66 71 72 procedure TCompiler.Init; 73 begin 74 with Parser do begin 75 Log('==== Parse start ===='); 76 with ProgramCode do begin 77 Modules.Clear; 78 79 with TModule(Modules[Modules.Add(TModule.Create)]) do begin 80 Name := 'Main'; 81 with TType(Types[Types.Add(TType.Create)]) do begin 82 Name := 'Void'; 83 Size := 0; 84 UsedType := nil; 85 end; 86 with TType(Types[Types.Add(TType.Create)]) do begin 87 Name := 'Byte'; 88 Size := 1; 89 UsedType := nil; 90 end; 91 with TFunction(Methods[Methods.Add(TFunction.Create)]) do begin 92 Name := 'Exit'; 93 ResultType := TType(TModule(Modules[0]).Types[0]); 94 end; 95 with TFunction(Methods[Methods.Add(TFunction.Create)]) do begin 96 Name := 'WriteLn'; 97 ResultType := TType(TModule(Modules[0]).Types[0]); 98 end; 99 end; 100 end; 101 end; 102 end; 103 67 104 end.
Note:
See TracChangeset
for help on using the changeset viewer.