public override bool Visit(UnaryPlus node) { traverse(node.expr); if (node.expr.Value != null) { node.Value = node.expr.Value; } return(true); }
void CreateOperators() { // Only one of each operation Token needs to be created opAdd = new Add(workStack); opSubtract = new Subtract(workStack); opMultiply = new Multiply(workStack); opDivide = new Divide(workStack); opPower = new Power(workStack); opLeftBracket = new LeftBracket(); opRightBracket = new RightBracket(); opUnaryMinus = new UnaryMinus(workStack); opUnaryPlus = new UnaryPlus(); opFactorial = new Factorial(workStack); opSqrt = new Sqrt(workStack); opSin = new Sin(workStack); opCos = new Cos(workStack); opTan = new Tan(workStack); opLog = new Log(workStack); opAsin = new Asin(workStack); opAcos = new Acos(workStack); opAtan = new Atan(workStack); functions = new Dictionary <string, Function> { { "sqrt", opSqrt }, { "sin", opSin }, { "cos", opCos }, { "tan", opTan }, { "log", opLog }, { "asin", opAsin }, { "acos", opAcos }, { "atan", opAtan } }; binaryOperators = new Dictionary <char, BinaryOperator> { { plusChar, opAdd }, { minusChar, opSubtract }, { multiplyChar, opMultiply }, { divideChar, opDivide }, { powerChar, opPower } }; }
public static R Positive <T, R>(T value) => UnaryPlus <T, R> .Invoke(value);
public static T Positive <T>(T value) => UnaryPlus <T, T> .Invoke(value);
public virtual T Visit(UnaryPlus node) { return(Visit((SimpleUnaryExpression)node)); }
public override bool Visit(UnaryPlus node) { Visit((SimpleUnaryExpression)node); return(true); }
public override Value Visit(UnaryPlus node) { return(traverse(node.expr)); }
public override bool Visit(UnaryPlus node) { outputCode("+", false, false); Visit((SimpleUnaryExpression)node); return(true); }
void CreateOperators() { // Only one of each operation Token needs to be created opAdd = new Add(workStack); opSubtract = new Subtract(workStack); opMultiply = new Multiply(workStack); opDivide = new Divide(workStack); opPower = new Power(workStack); opBracket = new Bracket(); opUnaryMinus = new UnaryMinus(workStack); opUnaryPlus = new UnaryPlus(); opSqrt = new Sqrt(workStack); opSin = new Sin(workStack); opCos = new Cos(workStack); opTan = new Tan(workStack); opLog = new Log(workStack); opAsin = new Asin(workStack); opAcos = new Acos(workStack); opAtan = new Atan(workStack); functions = new Dictionary<string, Function> { {"sqr", opSqrt }, {"sin", opSin }, {"cos", opCos }, {"tan", opTan }, {"log", opLog }, {"asin", opAsin }, {"acos", opAcos }, {"atan", opAtan } }; binaryOperators = new Dictionary<char, BinaryOperator> { {'+', opAdd }, {'-', opSubtract }, {'*', opMultiply }, {'/', opDivide }, {'^',opPower } }; }
private Expression ParseUnaryExpression(TokenSet followers) { Expression result; switch (this.currentToken) { case Token.Addition: { SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.CurrentSourceLocation); this.GetNextToken(); result = new UnaryPlus(this.ParseSimpleExpression(followers), slb); break; } case Token.Not: { SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.CurrentSourceLocation); this.GetNextToken(); result = new LogicalNot(this.ParseRelationalExpression(followers), slb); break; } case Token.Subtraction: { SourceLocationBuilder slb = new SourceLocationBuilder(this.scanner.CurrentSourceLocation); this.GetNextToken(); result = new UnaryPlus(this.ParseSimpleExpression(followers), slb); break; } default: result = this.ParseSimpleExpression(followers); break; } return result; }