Changeset 120 for branches/generator/URules.pas
- Timestamp:
- Nov 29, 2017, 1:21:22 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.