Ignore:
Timestamp:
Nov 27, 2017, 10:04:52 AM (7 years ago)
Author:
chronos
Message:
  • Modified: Rule items interface moved to separate unit UFormRuleItems.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/generator/URules.pas

    r113 r116  
    3434
    3535  TRuleItems = class(TFPGObjectList<TRuleItem>)
     36    ParentRule: TRule;
    3637    Grammer: TGrammer;
     38    RuleType: TRuleType;
    3739    procedure LoadFromXmlNode(Node: TDOMNode);
    3840    procedure SaveToXmlNode(Node: TDOMNode);
    3941    function GetBNF(RuleType: TRuleType): string;
     42  end;
     43
     44  TRuleLinkType = (ltRequire);
     45
     46  TRuleLink = class
     47    LinkType: TRuleLinkType;
     48    Rule: TRule;
     49  end;
     50
     51  TRuleLinks = class(TFPGObjectList<TRuleLink>)
     52
    4053  end;
    4154
     
    4962    Name: string;
    5063    Items: TRuleItems;
    51     RuleType: TRuleType;
     64    Links: TRuleLinks;
    5265    property Grammer: TGrammer read GetGrammer write SetGrammer;
    5366    constructor Create;
     
    184197  RuleItemNode: TDOMNode;
    185198begin
     199  WriteInteger(Node, 'Type', Integer(RuleType));
     200
    186201  for RuleItem in Self do begin
    187202    RuleItemNode := Node.OwnerDocument.CreateElement('RuleItem');
     
    210225  RuleItem: TRuleItem;
    211226begin
     227  RuleType := TRuleType(ReadInteger(Node, 'Type', Integer(rtAnd)));
     228
    212229  RuleItemNode := Node.FirstChild;
    213230  while Assigned(RuleItemNode) do begin
     
    229246begin
    230247  WriteString(Node, 'Name', Name);
    231   WriteInteger(Node, 'Type', Integer(RuleType));
    232248
    233249  RuleItemsNode := Node.OwnerDocument.CreateElement('RuleItems');
     
    238254function TRule.GetBNF: string;
    239255begin
    240   Result := Name + ' ::= ' + Items.GetBNF(RuleType);
     256  Result := Name + ' ::= ' + Items.GetBNF(Items.RuleType);
    241257end;
    242258
     
    254270begin
    255271  Items := TRuleItems.Create;
     272  Items.ParentRule := Self;
     273  Links := TRuleLinks.Create;
    256274end;
    257275
    258276destructor TRule.Destroy;
    259277begin
     278  FreeAndNil(Links);
    260279  FreeAndNil(Items);
    261280  inherited Destroy;
     
    267286begin
    268287  Name := ReadString(Node, 'Name', '');
    269   RuleType := TRuleType(ReadInteger(Node, 'Type', Integer(rtAnd)));
    270288
    271289  ItemsNode := Node.FindNode('RuleItems');
Note: See TracChangeset for help on using the changeset viewer.