Changeset 204
- Timestamp:
- Apr 17, 2020, 11:07:37 PM (5 years ago)
- Location:
- branches/interpreter2
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/interpreter2/Test.pas
r203 r204 37 37 WriteLn('Can''t believe this.'); 38 38 end; 39 WriteLn ;39 WriteLn(''); 40 40 WriteLn('Test'); 41 41 WriteLn(A); -
branches/interpreter2/UFormMain.lfm
r203 r204 572 572 TabOrder = 5 573 573 end 574 object ButtonGenerate1: TButton 575 Left = 416 576 Height = 38 577 Top = 18 578 Width = 145 579 Caption = 'Generate PHP' 580 OnClick = ButtonGenerate1Click 581 TabOrder = 6 582 end 574 583 object SynFreePascalSyn1: TSynFreePascalSyn 575 584 Enabled = False -
branches/interpreter2/UFormMain.pas
r203 r204 15 15 TFormMain = class(TForm) 16 16 ButtonCompile: TButton; 17 ButtonGenerate1: TButton; 17 18 ButtonRun: TButton; 18 19 ButtonGenerate: TButton; … … 24 25 SynFreePascalSyn1: TSynFreePascalSyn; 25 26 procedure ButtonCompileClick(Sender: TObject); 27 procedure ButtonGenerate1Click(Sender: TObject); 26 28 procedure ButtonGenerateClick(Sender: TObject); 27 29 procedure ButtonRunClick(Sender: TObject); … … 49 51 50 52 uses 51 UParser, UExecutor, UGenerator ;53 UParser, UExecutor, UGenerator, UGeneratorPhp; 52 54 53 55 { TFormMain } … … 107 109 end; 108 110 111 procedure TFormMain.ButtonGenerate1Click(Sender: TObject); 112 var 113 Generator: TGeneratorPhp; 114 begin 115 ButtonCompile.Click; 116 MemoOutput.Lines.Clear; 117 if Assigned(Prog) then begin 118 Generator := TGeneratorPhp.Create; 119 Generator.Prog := Prog; 120 Generator.Generate; 121 MemoOutput.Lines.Text := Generator.Output; 122 Generator.Free; 123 end; 124 end; 125 109 126 procedure TFormMain.ButtonGenerateClick(Sender: TObject); 110 127 var -
branches/interpreter2/UGenerator.pas
r203 r204 140 140 otFunctionCall: GenerateFunctionCall(Block, Expression.FunctionCall); 141 141 otConstantDirect: GenerateValue(Expression.ConstantDirect.Value); 142 otConstantRef: GenerateValue(Expression.ConstantRef.Value);142 otConstantRef: AddText(Expression.ConstantRef.Name); 143 143 otVariableRef: AddText(Expression.VariableRef.Name); 144 144 else raise Exception.Create('Unsupported exception operand type.'); -
branches/interpreter2/UParser.pas
r203 r204 605 605 end; 606 606 with Block.Functions.AddNew('IntToStr') do begin 607 InternalName := 'IntToStr'; 607 608 Params.AddNew('Value', TypeInteger); 608 609 ResultType := TypeString; 609 610 end; 610 611 with Block.Functions.AddNew('StrToInt') do begin 612 InternalName := 'StrToInt'; 611 613 Params.AddNew('Value', TypeString); 612 614 ResultType := TypeInteger; 613 615 end; 614 616 with Block.Functions.AddNew('WriteLn') do begin 617 InternalName := 'WriteLn'; 615 618 Params.AddNew('Text', TypeString); 616 619 end; 617 620 with Block.Functions.AddNew('Write') do begin 621 InternalName := 'Write'; 618 622 Params.AddNew('Text', TypeString); 619 623 end; -
branches/interpreter2/USource.pas
r203 r204 11 11 TExpressions = class; 12 12 TFunctions = class; 13 TBeginEnd = class; 13 14 14 15 { TValue } … … 98 99 TFunction = class 99 100 Name: string; 101 InternalName: string; 100 102 Params: TFunctionParameters; 101 103 ResultType: TType; 104 BeginEnd: TBeginEnd; 102 105 constructor Create; 103 106 destructor Destroy; override; … … 340 343 begin 341 344 Params := TFunctionParameters.Create; 345 BeginEnd := TBeginEnd.Create; 342 346 end; 343 347 344 348 destructor TFunction.Destroy; 345 349 begin 350 BeginEnd.Free; 346 351 Params.Free; 347 352 inherited Destroy; -
branches/interpreter2/interpreter.lpi
r203 r204 71 71 </Item2> 72 72 </RequiredPackages> 73 <Units Count=" 8">73 <Units Count="9"> 74 74 <Unit0> 75 75 <Filename Value="interpreter.lpr"/> … … 107 107 <IsPartOfProject Value="True"/> 108 108 </Unit7> 109 <Unit8> 110 <Filename Value="UGeneratorPhp.pas"/> 111 <IsPartOfProject Value="True"/> 112 </Unit8> 109 113 </Units> 110 114 </ProjectOptions> -
branches/interpreter2/interpreter.lpr
r203 r204 8 8 {$ENDIF}{$ENDIF} 9 9 Interfaces, SysUtils, // this includes the LCL widgetset 10 Forms, UFormMain, UParser, UTokenizer, USource, UExecutor, UInterpreter, UGenerator 10 Forms, UFormMain, UParser, UTokenizer, USource, UExecutor, UInterpreter, 11 UGenerator, UGeneratorPhp 11 12 { you can add units after this }; 12 13
Note:
See TracChangeset
for help on using the changeset viewer.