Changeset 150
- Timestamp:
- Jan 18, 2018, 2:36:23 PM (7 years ago)
- Location:
- branches/easy compiler
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/easy compiler/UFormMain.lfm
r149 r150 8 8 ClientWidth = 909 9 9 DesignTimePPI = 120 10 OnClose = FormClose 10 11 OnCreate = FormCreate 11 12 OnDestroy = FormDestroy 12 13 OnShow = FormShow 13 14 LCLVersion = '1.8.0.6' 14 object Memo Output: TMemo15 Left = 44016 Height = 4 6415 object MemoSource: TMemo 16 Left = 9 17 Height = 488 17 18 Top = 32 18 Width = 4 4819 ReadOnly = True19 Width = 416 20 Anchors = [akTop, akLeft, akBottom] 20 21 ScrollBars = ssAutoBoth 21 22 TabOrder = 0 22 23 end 23 object MemoSource: TMemo24 Left = 825 Height = 24026 Top = 3227 Width = 41628 ScrollBars = ssAutoBoth29 TabOrder = 130 end31 24 object ButtonBuild: TButton 32 Left = 11225 Left = 9 33 26 Height = 31 34 Top = 28027 Top = 528 35 28 Width = 166 29 Anchors = [akLeft, akBottom] 36 30 Caption = 'Compile && Execute' 37 31 OnClick = ButtonBuildClick 38 TabOrder = 2 39 end 40 object Edit1: TEdit 41 Left = 440 42 Height = 28 43 Top = 526 44 Width = 200 45 OnKeyPress = Edit1KeyPress 46 TabOrder = 3 47 end 48 object ButtonSend: TButton 49 Left = 656 50 Height = 31 51 Top = 526 52 Width = 94 53 Caption = 'Send' 54 OnClick = ButtonSendClick 55 TabOrder = 4 32 TabOrder = 1 56 33 end 57 34 object Label1: TLabel … … 63 40 ParentColor = False 64 41 end 65 object Label2: TLabel 66 Left = 440 67 Height = 20 68 Top = 11 69 Width = 108 70 Caption = 'Executor output:' 71 ParentColor = False 72 end 73 object Label3: TLabel 74 Left = 441 75 Height = 20 76 Top = 504 77 Width = 98 78 Caption = 'Executor input:' 79 ParentColor = False 80 end 81 object MemoGenerator: TMemo 82 Left = 8 83 Height = 216 84 Top = 344 85 Width = 416 86 ScrollBars = ssAutoBoth 87 TabOrder = 5 88 end 89 object Label4: TLabel 90 Left = 8 91 Height = 20 92 Top = 315 93 Width = 117 94 Caption = 'Generator output:' 95 ParentColor = False 42 object PageControl1: TPageControl 43 Left = 432 44 Height = 552 45 Top = 8 46 Width = 470 47 ActivePage = TabSheetExecutor 48 Anchors = [akTop, akLeft, akRight, akBottom] 49 TabIndex = 0 50 TabOrder = 2 51 object TabSheetExecutor: TTabSheet 52 Caption = 'Executor' 53 ClientHeight = 519 54 ClientWidth = 462 55 object Label2: TLabel 56 Left = 8 57 Height = 20 58 Top = 8 59 Width = 108 60 Caption = 'Executor output:' 61 ParentColor = False 62 end 63 object MemoOutput: TMemo 64 Left = 8 65 Height = 416 66 Top = 32 67 Width = 448 68 Anchors = [akTop, akLeft, akRight, akBottom] 69 ReadOnly = True 70 ScrollBars = ssAutoBoth 71 TabOrder = 0 72 end 73 object Label3: TLabel 74 Left = 8 75 Height = 20 76 Top = 452 77 Width = 98 78 Anchors = [akLeft, akBottom] 79 Caption = 'Executor input:' 80 ParentColor = False 81 end 82 object Edit1: TEdit 83 Left = 8 84 Height = 28 85 Top = 480 86 Width = 336 87 Anchors = [akLeft, akRight, akBottom] 88 OnKeyPress = Edit1KeyPress 89 TabOrder = 1 90 end 91 object ButtonSend: TButton 92 Left = 360 93 Height = 31 94 Top = 477 95 Width = 94 96 Anchors = [akRight, akBottom] 97 Caption = 'Send' 98 OnClick = ButtonSendClick 99 TabOrder = 2 100 end 101 end 102 object TabSheetGenerator: TTabSheet 103 Caption = 'Generator' 104 ClientHeight = 519 105 ClientWidth = 462 106 object Label4: TLabel 107 Left = 8 108 Height = 20 109 Top = 8 110 Width = 117 111 Caption = 'Generator output:' 112 ParentColor = False 113 end 114 object MemoGenerator: TMemo 115 Left = 8 116 Height = 480 117 Top = 32 118 Width = 448 119 Anchors = [akTop, akLeft, akRight, akBottom] 120 ScrollBars = ssAutoBoth 121 TabOrder = 0 122 end 123 end 96 124 end 97 125 end -
branches/easy compiler/UFormMain.pas
r149 r150 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 UTargetCode, USourceCode, USourceExecutor, USourceGenerator, LCLIntf; 9 UTargetCode, USourceCode, USourceExecutor, USourceGenerator, LCLIntf, 10 ComCtrls; 10 11 11 12 type … … 14 15 15 16 TForm1 = class(TForm) 17 ButtonBuild: TButton; 16 18 ButtonSend: TButton; 17 ButtonBuild: TButton;18 19 Edit1: TEdit; 19 20 Label1: TLabel; … … 21 22 Label3: TLabel; 22 23 Label4: TLabel; 24 MemoGenerator: TMemo; 23 25 MemoOutput: TMemo; 24 26 MemoSource: TMemo; 25 MemoGenerator: TMemo; 27 PageControl1: TPageControl; 28 TabSheetExecutor: TTabSheet; 29 TabSheetGenerator: TTabSheet; 26 30 procedure ButtonBuildClick(Sender: TObject); 27 31 procedure ButtonSendClick(Sender: TObject); 28 32 procedure Edit1KeyPress(Sender: TObject; var Key: char); 33 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); 29 34 procedure FormCreate(Sender: TObject); 30 35 procedure FormDestroy(Sender: TObject); … … 35 40 function ExecutorInput: string; 36 41 public 42 FileName: string; 37 43 end; 38 44 … … 51 57 procedure TForm1.FormShow(Sender: TObject); 52 58 begin 53 { with MemoSource.Lines do begin 54 Add('Begin'); 55 Add('var I Integer'); 56 Add('Assign I 10'); 57 Add('Repeat'); 58 Add('Begin'); 59 Add('PrintLn I'); 60 Add('Decrement I 1'); 61 Add('IfEqual I 0'); 62 Add('Break'); 63 Add('End'); 64 Add('End'); 65 end; 66 with MemoSource.Lines do begin 67 Add('PrintLn ''Super Calculator'''); 68 Add('var Value1 Integer'); 69 Add('var Value2 Integer'); 70 Add('var Result Integer'); 71 Add('Print ''Enter value 1: '''); 72 Add('Assign Value1 0'); 73 Add('InputLn Value1'); 74 Add('Print ''Enter value 2: '''); 75 Add('Assign Value2 0'); 76 Add('InputLn Value2'); 77 78 Add('Assign Result Value1'); 79 Add('Increment Result Value2'); 80 Add('Print ''Sum of two values is: '''); 81 Add('PrintLn Result'); 82 end; 83 with MemoSource.Lines do begin 84 Add('PrintLn ''Hello World!'''); 85 Add('print ''Hello'' PRINT '' World!'''); 86 Add('PrintLn ''Live your life.'''); 87 Add('var Text1 String'); 88 Add('Assign Text1 ''Live your life.'''); 89 Add('var Text2 String'); 90 Add('Assign Text2 ''Live your life.'''); 91 Add('PrintLn Text1'); 92 Add('PrintLn Text2'); 93 94 Add('var Value1 Integer'); 95 Add('Assign Value1 123'); 96 Add('Increment Value1 2'); 97 Add('PrintLn Value1'); 98 99 Add('var Text3 String'); 100 Add('Assign Text3 '''''); 101 Add('Print ''Enter your name:'''); 102 Add('InputLn Text3'); 103 Add('PrintLn Text3'); 104 end; 105 } 106 with MemoSource.Lines do begin 107 Add('Begin'); 108 Add('Var AnimalName StringArray'); 109 Add('Var AnimalProperty StringArray'); 110 Add('Var AnimalCount Integer'); 111 Add('Var Answer String'); 112 Add('Var I Integer'); 113 Add('Assign AnimalName[0] ''an elephant'''); 114 Add('Assign AnimalProperty[0] ''It is big and slow'''); 115 Add('Assign AnimalName[1] ''a cat'''); 116 Add('Assign AnimalProperty[1] ''It meows and purrs'''); 117 Add('Print ''An animal guessing game.'''); 118 Add('Assign AnimalCount 2'); 119 Add('Repeat'); 120 Add('Begin'); 121 Add('PrintLn ''Think an animal.'''); 122 Add('Assign I 0'); 123 Add('Repeat'); 124 Add('Begin'); 125 Add('Print AnimalProperty[I]'); 126 Add('Print ''? (y/n)'''); 127 Add('InputLn Answer'); 128 Add('IfEqual Answer ''y'''); 129 Add('Begin'); 130 Add('Print ''Thats clear. It is '''); 131 Add('PrintLn AnimalName[I]'); 132 Add('Break'); 133 Add('End'); 134 Add('Increment I 1'); 135 Add('IfEqual I AnimalCount'); 136 Add('Break'); 137 Add('End'); 138 Add('IfEqual I AnimalCount'); 139 Add('Begin'); 140 Add('PrintLn ''I am lost. What is the animal?'''); 141 Add('InputLn AnimalName[I]'); 142 Add('PrintLn ''Describe the animal for me. What is it like?'''); 143 Add('InputLn AnimalProperty[I]'); 144 Add('PrintLn ''Thank you. I will remember that animal.'''); 145 Add('Increment AnimalCount 1'); 146 Add('End'); 147 Add('Print ''Do you want to try again? (y/n)'''); 148 Add('InputLn Answer'); 149 Add('IfNotEqual Answer ''y'''); 150 Add('Break'); 151 Add('PrintLn '''''); 152 Add('End'); 153 Add('PrintLn ''Bye'''); 154 Add('End'); 155 end; 156 59 FileName := 'Examples' + DirectorySeparator + 'Animal guessing game.lan'; 60 MemoSource.Lines.LoadFromFile(FileName); 157 61 end; 158 62 … … 196 100 end; 197 101 102 procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); 103 begin 104 MemoSource.Lines.SaveToFile(FileName); 105 end; 106 198 107 procedure TForm1.FormCreate(Sender: TObject); 199 108 begin -
branches/easy compiler/USourceGenerator.pas
r149 r150 91 91 end else 92 92 if Name = 'assign' then begin 93 if TSourceReference(Parameters[0]) is TSourceReferenceArray then 94 Result := Result + IndentStr + 'SetLength(' + TSourceReferenceArray(Parameters[0]).ArrayRef.Name + 95 ', ' + GenerateRef(TSourceReferenceArray(Parameters[0]).Index) + ' + 1);' + LineEnding; 93 96 Result := Result + IndentStr + GenerateRef(TSourceReference(Parameters[0])) + ' := ' + 94 97 GenerateRef(TSourceReference(Parameters[1])) + ';' + LineEnding;
Note:
See TracChangeset
for help on using the changeset viewer.