void ConditionGroup(SingleNodeTree parent) { ConditionGroup group = new ConditionGroup(); parent.SetChild(group); ExpressionTreeBase addTo = group; SingleNodeTree condition = null; ConditionalExpression lastOperation = null; Expect(6); while (StartOf(2)) { lastOperation = lastOperation ?? new AndCondition(); MultiAdd(addTo, lastOperation); addTo = lastOperation; if (la.kind == 5) { Get(); NotCondition not = new NotCondition(); lastOperation.SetChild(not); lastOperation = not; } if (StartOf(3)) { Condition(lastOperation); } else if (la.kind == 6) { ConditionGroup(lastOperation); } else { SynErr(47); } if (la.kind == 9 || la.kind == 10) { Operation(out lastOperation); } else { lastOperation = null; } } if (lastOperation != null && lastOperation.Child == null) { SemErr("Invalid Condition"); } Expect(7); }
void ComplexCondition(SingleNodeTree parent, SelectorExpression selector) { ConditionGroup group = new ConditionGroup(); parent.SetChild(group); ExpressionTreeBase addTo = group; SingleNodeTree condition = null; ConditionalExpression lastOperation = null; Expect(6); while (StartOf(2)) { lastOperation = lastOperation ?? new AndCondition(); MultiAdd(addTo, lastOperation); addTo = lastOperation; selector = new SelectorExpression(selector.Field, ModifierTypes.Equals, selector.Path); if (la.kind == 5) { Get(); NotCondition not = new NotCondition(); lastOperation.SetChild(not); lastOperation = not; } if (la.kind == 6) { ComplexCondition(lastOperation, selector); } else if (StartOf(3)) { SelectorExpression nestedSelector = new SelectorExpression(selector.Field, ModifierTypes.Equals, selector.Path); MultiAdd(lastOperation, nestedSelector); Literal(nestedSelector); } else { SynErr(49); } if (la.kind == 9 || la.kind == 10) { Operation(out lastOperation); } else { lastOperation = null; } } Expect(7); }