void Literal(SingleNodeTree parent) { if (la.kind == 2) { Get(); parent.SetChild(new LiteralExpression(t.val)); } else if (la.kind == 3) { Get(); parent.SetChild(new LiteralExpression(t.val.Substring(1, t.val.Length - 2), true)); } else if (la.kind == 4) { Get(); parent.SetChild(new ValueExpression(Int32.Parse(t.val.Substring(1)))); } else if (la.kind == 1) { Get(); parent.SetChild(new LiteralExpression(t.val)); } else { SynErr(50); } }
void Condition(SingleNodeTree parent) { SelectorTypes selectorType; ModifierTypes modifierType; if (FollowedByColon()) { Selector(out selectorType, out modifierType); SelectorExpression selector = new SelectorExpression(selectorType, modifierType, t.val); if (la.kind == 6) { ComplexCondition(parent, selector); } else if (StartOf(3)) { parent.SetChild(selector); Literal(selector); } else { SynErr(45); } } else if (StartOf(3)) { SelectorExpression nestedSelector = new SelectorExpression(SelectorTypes.Unspecified, ModifierTypes.Equals, t.val); parent.SetChild(nestedSelector); Literal(nestedSelector); } else { SynErr(46); } }
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); }
void Literal(SingleNodeTree parent) { if (la.kind == 2) { Get(); parent.SetChild(new LiteralExpression(t.val)); } else if (la.kind == 3) { Get(); parent.SetChild(new LiteralExpression(t.val.Substring(1, t.val.Length - 2), true)); } else if (la.kind == 4) { Get(); parent.SetChild(new ValueExpression(Int32.Parse(t.val.Substring(1)))); } else if (la.kind == 1) { Get(); parent.SetChild(new LiteralExpression(t.val)); } else SynErr(50); }
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); }
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 Condition(SingleNodeTree parent) { SelectorTypes selectorType; ModifierTypes modifierType; if (FollowedByColon()) { Selector(out selectorType, out modifierType); SelectorExpression selector = new SelectorExpression(selectorType, modifierType, t.val); if (la.kind == 6) { ComplexCondition(parent, selector); } else if (StartOf(3)) { parent.SetChild(selector); Literal(selector); } else SynErr(45); } else if (StartOf(3)) { SelectorExpression nestedSelector = new SelectorExpression(SelectorTypes.Unspecified, ModifierTypes.Equals, t.val); parent.SetChild(nestedSelector); Literal(nestedSelector); } else SynErr(46); }