Changeset 116 for branches/generator/URules.pas
- Timestamp:
- Nov 27, 2017, 10:04:52 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/generator/URules.pas
r113 r116 34 34 35 35 TRuleItems = class(TFPGObjectList<TRuleItem>) 36 ParentRule: TRule; 36 37 Grammer: TGrammer; 38 RuleType: TRuleType; 37 39 procedure LoadFromXmlNode(Node: TDOMNode); 38 40 procedure SaveToXmlNode(Node: TDOMNode); 39 41 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 40 53 end; 41 54 … … 49 62 Name: string; 50 63 Items: TRuleItems; 51 RuleType: TRuleType;64 Links: TRuleLinks; 52 65 property Grammer: TGrammer read GetGrammer write SetGrammer; 53 66 constructor Create; … … 184 197 RuleItemNode: TDOMNode; 185 198 begin 199 WriteInteger(Node, 'Type', Integer(RuleType)); 200 186 201 for RuleItem in Self do begin 187 202 RuleItemNode := Node.OwnerDocument.CreateElement('RuleItem'); … … 210 225 RuleItem: TRuleItem; 211 226 begin 227 RuleType := TRuleType(ReadInteger(Node, 'Type', Integer(rtAnd))); 228 212 229 RuleItemNode := Node.FirstChild; 213 230 while Assigned(RuleItemNode) do begin … … 229 246 begin 230 247 WriteString(Node, 'Name', Name); 231 WriteInteger(Node, 'Type', Integer(RuleType));232 248 233 249 RuleItemsNode := Node.OwnerDocument.CreateElement('RuleItems'); … … 238 254 function TRule.GetBNF: string; 239 255 begin 240 Result := Name + ' ::= ' + Items.GetBNF( RuleType);256 Result := Name + ' ::= ' + Items.GetBNF(Items.RuleType); 241 257 end; 242 258 … … 254 270 begin 255 271 Items := TRuleItems.Create; 272 Items.ParentRule := Self; 273 Links := TRuleLinks.Create; 256 274 end; 257 275 258 276 destructor TRule.Destroy; 259 277 begin 278 FreeAndNil(Links); 260 279 FreeAndNil(Items); 261 280 inherited Destroy; … … 267 286 begin 268 287 Name := ReadString(Node, 'Name', ''); 269 RuleType := TRuleType(ReadInteger(Node, 'Type', Integer(rtAnd)));270 288 271 289 ItemsNode := Node.FindNode('RuleItems');
Note:
See TracChangeset
for help on using the changeset viewer.