Changeset 111 for branches/generator/Forms
- Timestamp:
- Aug 9, 2017, 12:09:47 AM (7 years ago)
- Location:
- branches/generator/Forms
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormMain.pas
r110 r111 56 56 procedure TFormMain.ARulesExecute(Sender: TObject); 57 57 begin 58 FormRules.Rules := Core. Rules;58 FormRules.Rules := Core.Grammer.Rules; 59 59 FormRules.ShowModal; 60 MemoBNF.Lines.Text := Core. Rules.GetBNF;60 MemoBNF.Lines.Text := Core.Grammer.GetBNF; 61 61 end; 62 62 63 63 procedure TFormMain.ASaveAsExecute(Sender: TObject); 64 64 begin 65 SaveDialog1.FileName := Core. Rules.FileName;65 SaveDialog1.FileName := Core.Grammer.FileName; 66 66 if SaveDialog1.Execute then begin 67 Core. Rules.SaveToXmlFile(SaveDialog1.FileName);67 Core.Grammer.SaveToXmlFile(SaveDialog1.FileName); 68 68 end; 69 69 end; … … 71 71 procedure TFormMain.FormShow(Sender: TObject); 72 72 begin 73 MemoBNF.Lines.Text := Core. Rules.GetBNF;73 MemoBNF.Lines.Text := Core.Grammer.GetBNF; 74 74 end; 75 75 … … 81 81 procedure TFormMain.AOpenExecute(Sender: TObject); 82 82 begin 83 OpenDialog1.FileName := Core. Rules.FileName;83 OpenDialog1.FileName := Core.Grammer.FileName; 84 84 if OpenDialog1.Execute then begin 85 Core. Rules.LoadFromXmlFile(OpenDialog1.FileName);85 Core.Grammer.LoadFromXmlFile(OpenDialog1.FileName); 86 86 end; 87 87 end; -
branches/generator/Forms/UFormRule.lfm
r110 r111 47 47 object ListView: TListView 48 48 Left = 16 49 Height = 2 6450 Top = 8049 Height = 232 50 Top = 112 51 51 Width = 624 52 52 Anchors = [akTop, akLeft, akBottom] … … 67 67 OnKeyPress = ListViewKeyPress 68 68 OnSelectItem = ListViewSelectItem 69 end 70 object Label2: TLabel 71 Left = 24 72 Height = 24 73 Top = 64 74 Width = 82 75 Caption = 'Operator:' 76 ParentColor = False 77 end 78 object ComboBox1: TComboBox 79 Left = 186 80 Height = 36 81 Top = 61 82 Width = 390 83 ItemHeight = 0 84 Items.Strings = ( 85 'And' 86 'Or' 87 ) 88 Style = csDropDownList 89 TabOrder = 4 69 90 end 70 91 object ActionList1: TActionList -
branches/generator/Forms/UFormRule.pas
r110 r111 20 20 ButtonOk: TButton; 21 21 ButtonCancel: TButton; 22 ComboBox1: TComboBox; 22 23 EditName: TEdit; 23 24 Label1: TLabel; 25 Label2: TLabel; 24 26 ListView: TListView; 25 27 MenuItem1: TMenuItem; … … 39 41 { private declarations } 40 42 public 41 Rule Items: TRuleItems;43 Rule: TRule; 42 44 procedure UpdateInterface; 43 45 procedure ReloadList; … … 68 70 procedure TFormRule.ListViewData(Sender: TObject; Item: TListItem); 69 71 begin 70 if (Item.Index >= 0) and (Item.Index < Rule Items.Count) then begin71 Item.Caption := Rule Items[Item.Index].Name;72 Item.Data := Rule Items[Item.Index];72 if (Item.Index >= 0) and (Item.Index < Rule.Items.Count) then begin 73 Item.Caption := Rule.Items[Item.Index].GetBNF; 74 Item.Data := Rule.Items[Item.Index]; 73 75 end; 74 76 end; … … 95 97 begin 96 98 NewRuleItem := TRuleItem.Create; 99 NewRuleItem.Grammer := Rule.Grammer; 97 100 FormRuleItem.LoadData(NewRuleItem); 98 101 if FormRuleItem.ShowModal = mrOk then begin 99 102 FormRuleItem.SaveData(NewRuleItem); 100 RuleItems.Add(NewRuleItem); 103 NewRuleItem.ParentRule := Rule; 104 Rule.Items.Add(NewRuleItem); 101 105 ReloadList; 102 106 end else FreeAndNil(NewRuleItem); … … 121 125 for Item in ListView.Items do 122 126 if Item.Selected then 123 Rule Items.Remove(TRuleItem(Item.Data));127 Rule.Items.Remove(TRuleItem(Item.Data)); 124 128 ReloadList; 125 129 end; … … 133 137 procedure TFormRule.ReloadList; 134 138 begin 135 ListView.Items.Count := Rule Items.Count;139 ListView.Items.Count := Rule.Items.Count; 136 140 ListView.Refresh; 137 141 end; … … 139 143 procedure TFormRule.LoadData(Rule: TRule); 140 144 begin 145 Self.Rule := Rule; 146 ComboBox1.ItemIndex := Integer(Rule.RuleType); 141 147 EditName.Text := Rule.Name; 142 Rule Items := Rule.Items;148 Rule.Items := Rule.Items; 143 149 end; 144 150 145 151 procedure TFormRule.SaveData(Rule: TRule); 146 152 begin 153 Rule.RuleType := TRuleType(ComboBox1.ItemIndex); 147 154 Rule.Name := EditName.Text; 148 155 end; -
branches/generator/Forms/UFormRuleItem.lfm
r110 r111 9 9 ClientWidth = 656 10 10 LCLVersion = '1.6.4.0' 11 object Label 1: TLabel12 Left = 2411 object LabelTerminal: TLabel 12 Left = 16 13 13 Height = 24 14 Top = 2415 Width = 5616 Caption = ' Name:'14 Top = 64 15 Width = 79 16 Caption = 'Terminal:' 17 17 ParentColor = False 18 18 end 19 19 object EditName: TEdit 20 Left = 1 3220 Left = 160 21 21 Height = 34 22 Top = 1923 Width = 4 2822 Top = 64 23 Width = 400 24 24 TabOrder = 0 25 25 end … … 42 42 TabOrder = 2 43 43 end 44 object ComboBoxType: TComboBox 45 Left = 160 46 Height = 34 47 Top = 16 48 Width = 400 49 ItemHeight = 0 50 Items.Strings = ( 51 'Terminal' 52 'Non-terminal' 53 ) 54 OnChange = ComboBoxTypeChange 55 Style = csDropDownList 56 TabOrder = 3 57 end 58 object Label2: TLabel 59 Left = 16 60 Height = 24 61 Top = 24 62 Width = 45 63 Caption = 'Type:' 64 ParentColor = False 65 end 66 object LabelNonTerminal: TLabel 67 Left = 16 68 Height = 24 69 Top = 112 70 Width = 119 71 Caption = 'Non-terminal:' 72 ParentColor = False 73 end 74 object ComboBoxNonTerminal: TComboBox 75 Left = 160 76 Height = 36 77 Top = 104 78 Width = 404 79 ItemHeight = 0 80 Style = csDropDownList 81 TabOrder = 4 82 end 44 83 end -
branches/generator/Forms/UFormRuleItem.pas
r110 r111 16 16 ButtonCancel: TButton; 17 17 ButtonOk: TButton; 18 ComboBoxType: TComboBox; 19 ComboBoxNonTerminal: TComboBox; 18 20 EditName: TEdit; 19 Label1: TLabel; 21 LabelTerminal: TLabel; 22 Label2: TLabel; 23 LabelNonTerminal: TLabel; 24 procedure ComboBoxTypeChange(Sender: TObject); 20 25 private 21 { private declarations }26 procedure ReloadNonTerminals(Grammer: TGrammer); 22 27 public 28 RuleItem: TRuleItem; 29 procedure UpdateInterface; 23 30 procedure LoadData(RuleItem: TRuleItem); 24 31 procedure SaveData(RuleItem: TRuleItem); … … 34 41 { TFormRuleItem } 35 42 43 procedure TFormRuleItem.ComboBoxTypeChange(Sender: TObject); 44 begin 45 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 46 UpdateInterface; 47 end; 48 49 procedure TFormRuleItem.ReloadNonTerminals(Grammer: TGrammer); 50 var 51 Rule: TRule; 52 begin 53 ComboBoxNonTerminal.Items.Clear; 54 for Rule in Grammer.Rules do begin 55 ComboBoxNonTerminal.Items.AddObject(Rule.Name, Rule); 56 end; 57 end; 58 59 procedure TFormRuleItem.UpdateInterface; 60 begin 61 EditName.Visible := RuleItem.RuleItemType = ritTerminal; 62 LabelTerminal.Visible := RuleItem.RuleItemType = ritTerminal; 63 ComboBoxNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 64 LabelNonTerminal.Visible := RuleItem.RuleItemType = ritNonTerminal; 65 end; 66 36 67 procedure TFormRuleItem.LoadData(RuleItem: TRuleItem); 37 68 begin 38 EditName.Text := RuleItem.Name; 69 Self.RuleItem := RuleItem; 70 ReloadNonTerminals(RuleItem.Grammer); 71 ComboBoxType.ItemIndex := Integer(RuleItem.RuleItemType); 72 ComboBoxNonTerminal.ItemIndex := ComboBoxNonTerminal.Items.IndexOfObject(RuleItem.NonTerminal); 73 EditName.Text := RuleItem.Terminal; 74 UpdateInterface; 39 75 end; 40 76 41 77 procedure TFormRuleItem.SaveData(RuleItem: TRuleItem); 42 78 begin 43 RuleItem.Name := EditName.Text; 79 RuleItem.RuleItemType := TRuleItemType(ComboBoxType.ItemIndex); 80 if RuleItem.RuleItemType = ritTerminal then RuleItem.Terminal := EditName.Text 81 else if RuleItem.RuleItemType = ritNonTerminal then 82 RuleItem.NonTerminal := TRule(ComboBoxNonTerminal.Items.Objects[ComboBoxNonTerminal.ItemIndex]); 44 83 end; 45 84 -
branches/generator/Forms/UFormRules.lfm
r109 r111 27 27 Height = 24 28 28 Top = 5 29 Width = 7029 Width = 150 30 30 Align = alNone 31 31 AutoSize = True -
branches/generator/Forms/UFormRules.pas
r109 r111 69 69 begin 70 70 NewRule := TRule.Create; 71 NewRule.Grammer := Rules.Grammer; 71 72 FormRule.LoadData(NewRule); 72 73 if FormRule.ShowModal = mrOk then begin
Note:
See TracChangeset
for help on using the changeset viewer.