private Exclusion CreateExclusion(Parser.Line line) { Exclusion exclusion = new Exclusion(); exclusion.relationKey = line.binding.key; bool[] boundVars = new bool[line.binding.tokens.Length]; Pair[] vars = TokenToPairs(line.binding.tokens); Rule rule = this.WalkRule(line, vars, false); exclusion.rule = rule; Parser.Line parent = line.parent; while (parent != null) { foreach (Parser.Token token in parent.binding.tokens) { for (int i = 0; i < boundVars.Length; i++) { if (token.value == line.binding.tokens[i].value) { boundVars[i] = true; } } } parent = parent.parent; } exclusion.boundVars = boundVars; return(exclusion); }
private void LoadLine(Parser.Line line) { if (line.type == Parser.LineType.Claim) { if (line.parent == null) { this.Claim(line.binding); } else { Relation claimRelation = this.GetRelation(line.binding); Pair[] vars = TokenToPairs(line.binding.tokens); Rule rule = this.WalkRule(line, vars); claimRelation.AddRule(rule); } } else if (line.type == Parser.LineType.Action) { Action action = this.GetAction(line.binding); Pair[] vars = TokenToPairs(line.binding.tokens); Rule rule = this.WalkRule(line, vars, false); string payloadID = System.Guid.NewGuid().ToString(); action.AddPayload(rule, payloadID); this.actionPayloads[payloadID] = line.children.ToArray(); } else if (line.type == Parser.LineType.Exclusion) { Exclusion exclusion = this.CreateExclusion(line); this.AddExclusion(exclusion, line.binding.key); } foreach (Parser.Line child in line.children) { this.LoadLine(child); } }