private AbstractSyntaxTree Multiplicative(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.Modulo: return(Multiplicative(new ModuloNode(e, Exponent()))); case TokenType.Times: return(Multiplicative(new MultiplyNode(e, Exponent()))); case TokenType.Divide: return(Multiplicative(new DivideNode(e, Exponent()))); case TokenType.X: case TokenType.Y: case TokenType.Z: case TokenType.Lexical: case TokenType.LBracket: case TokenType.LParen: scanner.PutBackToken(); return(Multiplicative(new MultiplyNode(e, Exponent()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree Exponent(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.Caret: return(Exponent(new ExponentNode(e, Primary()))); case TokenType.Number: if (e is VariableNode) { return(Exponent(new ExponentNode(e, new ConstantNumberNode(double.Parse((t as LexicalToken).Lex, NumberStyles.Number, CultureInfo.InvariantCulture))))); } else { scanner.PutBackToken(); return(e); } default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree ConditionalAnd(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.And: return(ConditionalAnd(new AndNode(e, Equality()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree NullCoalescing(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.DoubleQuestionMark: return(NullCoalescing(new NullCoalescingNode(e, ConditionalOr()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree ConditionalOr(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.Or: return(ConditionalOr(new OrNode(e, ConditionalAnd()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree Additive(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.Plus: return(Additive(new AddNode(e, Multiplicative()))); case TokenType.Minus: return(Additive(new SubtractNode(e, Multiplicative()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree Equality(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.DoubleEqual: return(Equality(new EqualNode(e, Relational()))); case TokenType.NotEqual: return(Equality(new NotEqualNode(e, Relational()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree Relational(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.LessThan: return(Relational(new LessThanNode(e, Additive()))); case TokenType.LessThanEqual: return(Relational(new LessThanEqualNode(e, Additive()))); case TokenType.GreaterThan: return(Relational(new GreaterThanNode(e, Additive()))); case TokenType.GreaterThanEqual: return(Relational(new GreaterThanEqualNode(e, Additive()))); default: scanner.PutBackToken(); return(e); } }
private AbstractSyntaxTree Conditional(AbstractSyntaxTree e) { var t = scanner.GetToken(); switch (t.TokenType) { case TokenType.QuestionMark: var then = ConditionalOr(); t = scanner.GetToken(); switch (t.TokenType) { case TokenType.Colon: return(Conditional(new TernaryNode(e, then, ConditionalOr()))); default: throw new ParsingException(scanner.Position, "Could not find the ':' to terminate the ternary ('?:') statement"); } default: scanner.PutBackToken(); return(e); } }
public ExponentNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public TernaryNode(AbstractSyntaxTree Condition, AbstractSyntaxTree Positive, AbstractSyntaxTree Negative) { this.Condition = Condition; this.Positive = Positive; this.Negative = Negative; }
public NotEqualNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
protected BinaryNode(AbstractSyntaxTree left, AbstractSyntaxTree right) { this.left = left; this.right = right; }
public DivideNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public NegativeNode(AbstractSyntaxTree node) { this.node = node; }
public FormulaNode2(string FormulaName, Func <object, object, object> formula, AbstractSyntaxTree arg1, AbstractSyntaxTree arg2) { this.FormulaName = FormulaName; this.formula = formula; this.arg1 = arg1; this.arg2 = arg2; }
public NegativeNode(AbstractSyntaxTree node) : base(node) { }
public UnaryNode(AbstractSyntaxTree node) { this.node = node; }
public LessThanEqualNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public GreaterThanEqualNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public MultiplyNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public NotNode(AbstractSyntaxTree node) : base(node) { }
public ModuloNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public FormulaNode1(string FormulaName, Func <object, object> formula, AbstractSyntaxTree input) { this.FormulaName = FormulaName; this.formula = formula; this.input = input; }
public NullCoalescingNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public SubtractNode(AbstractSyntaxTree left, AbstractSyntaxTree right) : base(left, right) { }
public NotNode(AbstractSyntaxTree node) { this.node = node; }