- Timestamp:
- Nov 29, 2017, 1:21:22 PM (7 years ago)
- Location:
- branches/generator
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/Forms/UFormRule.lfm
r119 r120 45 45 Top = 80 46 46 Width = 640 47 ActivePage = TabSheet 147 ActivePage = TabSheetUsedBy 48 48 Anchors = [akTop, akLeft, akRight, akBottom] 49 TabIndex = 049 TabIndex = 2 50 50 TabOrder = 2 51 51 object TabSheet1: TTabSheet … … 54 54 object TabSheet2: TTabSheet 55 55 Caption = 'Links' 56 end 57 object TabSheetUsedBy: TTabSheet 58 Caption = 'Used by' 59 ClientHeight = 359 60 ClientWidth = 632 61 object ListView1: TListView 62 Left = 0 63 Height = 359 64 Top = 0 65 Width = 632 66 Align = alClient 67 Columns = < 68 item 69 Caption = 'Name' 70 Width = 200 71 end> 72 OwnerData = True 73 ReadOnly = True 74 RowSelect = True 75 TabOrder = 0 76 ViewStyle = vsReport 77 OnData = ListView1Data 78 end 56 79 end 57 80 end -
branches/generator/Forms/UFormRule.pas
r119 r120 19 19 EditName: TEdit; 20 20 Label1: TLabel; 21 ListView1: TListView; 21 22 PageControl1: TPageControl; 22 23 TabSheet1: TTabSheet; 23 24 TabSheet2: TTabSheet; 25 TabSheetUsedBy: TTabSheet; 24 26 procedure FormCreate(Sender: TObject); 25 27 procedure FormDestroy(Sender: TObject); 26 28 procedure FormShow(Sender: TObject); 29 procedure ListView1Data(Sender: TObject; Item: TListItem); 27 30 private 28 31 FormRuleItems: TFormRuleItems; 32 UsedByRules: TStringList; 33 procedure ReloadUsedByRules; 29 34 public 30 35 Rule: TRule; … … 39 44 implementation 40 45 46 uses 47 UCore; 48 41 49 {$R *.lfm} 42 50 … … 46 54 begin 47 55 EditName.SetFocus; 56 PageControl1.TabIndex := 0; // Select first tab by default 57 end; 58 59 procedure TFormRule.ListView1Data(Sender: TObject; Item: TListItem); 60 begin 61 if Item.Index < UsedByRules.Count then 62 begin 63 Item.Caption := UsedByRules[Item.Index]; 64 Item.Data := UsedByRules.Objects[Item.Index]; 65 end; 66 end; 67 68 procedure TFormRule.ReloadUsedByRules; 69 begin 70 ListView1.Items.Count := UsedByRules.Count; 71 ListView1.Refresh; 48 72 end; 49 73 … … 54 78 FormRuleItems.Align := alClient; 55 79 FormRuleItems.Show; 80 UsedByRules := TStringList.Create; 56 81 end; 57 82 58 83 procedure TFormRule.FormDestroy(Sender: TObject); 59 84 begin 85 FreeAndNil(UsedByRules); 60 86 FreeAndNil(FormRuleItems); 61 87 end; … … 64 90 begin 65 91 Self.Rule := Rule; 92 Rule.Grammer.GetUsedByRule(Rule, UsedByRules); 93 ReloadUsedByRules; 66 94 EditName.Text := Rule.Name; 67 95 CheckBoxCreateNode.Checked := Rule.CreateSourceNode; -
branches/generator/URules.pas
r119 r120 76 76 TRule = class 77 77 private 78 function GetGrammer: TGrammer;78 FGrammer: TGrammer; 79 79 procedure SetGrammer(AValue: TGrammer); 80 80 public … … 83 83 Items: TRuleItems; 84 84 Links: TRuleLinks; 85 property Grammer: TGrammer read GetGrammer write SetGrammer;86 85 constructor Create; 87 86 destructor Destroy; override; 87 procedure GetUsedByRule(RefRule: TRule; UsedByRules: TStrings); 88 88 procedure LoadFromXmlNode(Node: TDOMNode); 89 89 procedure SaveToXmlNode(Node: TDOMNode); 90 90 function GetString: string; 91 property Grammer: TGrammer read FGrammer write SetGrammer; 91 92 end; 92 93 … … 117 118 destructor Destroy; override; 118 119 procedure BuildCompiler; 120 procedure GetUsedByRule(RefRule: TRule; UsedByRules: TStrings); 119 121 function GetString: string; 120 122 property Modified: Boolean read FModified write SetModified; … … 308 310 end; 309 311 312 procedure TGrammer.GetUsedByRule(RefRule: TRule; UsedByRules: TStrings); 313 var 314 Rule: TRule; 315 begin 316 UsedByRules.Clear; 317 for Rule in Rules do 318 Rule.GetUsedByRule(RefRule, UsedByRules); 319 end; 320 310 321 function TGrammer.GetString: string; 311 322 begin … … 498 509 end; 499 510 500 function TRule.GetGrammer: TGrammer;501 begin502 Result := Items.Grammer;503 end;504 505 511 procedure TRule.SetGrammer(AValue: TGrammer); 506 512 begin 513 if FGrammer = AValue then Exit; 514 FGrammer := AValue; 507 515 Items.Grammer := AValue; 508 516 end; … … 520 528 FreeAndNil(Items); 521 529 inherited Destroy; 530 end; 531 532 procedure TRule.GetUsedByRule(RefRule: TRule; UsedByRules: TStrings); 533 var 534 Item: TRuleItem; 535 begin 536 for Item in Items do 537 if (Item.RuleItemType = ritNonTerminal) and 538 (Item.NonTerminal = RefRule) and 539 (UsedByRules.IndexOf(Item.ParentRule.Name) = -1) then 540 UsedByRules.AddObject(Item.ParentRule.Name, Item.ParentRule); 522 541 end; 523 542 -
branches/generator/generator.lpr
r117 r120 26 26 {$ENDIF} 27 27 28 Application.Title :='Language generator';28 Application.Title := 'Language generator'; 29 29 RequireDerivedFormResource := True; 30 30 Application.Initialize;
Note:
See TracChangeset
for help on using the changeset viewer.