Esempio n. 1
0
 public override bool Visit(UnaryPlus node)
 {
     traverse(node.expr);
     if (node.expr.Value != null)
     {
         node.Value = node.expr.Value;
     }
     return(true);
 }
Esempio n. 2
0
 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 }
     };
 }
Esempio n. 3
0
 public static R Positive <T, R>(T value)
 => UnaryPlus <T, R> .Invoke(value);
Esempio n. 4
0
 public static T Positive <T>(T value)
 => UnaryPlus <T, T> .Invoke(value);
Esempio n. 5
0
 public virtual T Visit(UnaryPlus node)
 {
     return(Visit((SimpleUnaryExpression)node));
 }
Esempio n. 6
0
 public override bool Visit(UnaryPlus node)
 {
     Visit((SimpleUnaryExpression)node);
     return(true);
 }
Esempio n. 7
0
 public override Value Visit(UnaryPlus node)
 {
     return(traverse(node.expr));
 }
Esempio n. 8
0
 public override bool Visit(UnaryPlus node)
 {
     outputCode("+", false, false);
     Visit((SimpleUnaryExpression)node);
     return(true);
 }
Esempio n. 9
0
 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 }
     };
 }
Esempio n. 10
0
    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;
    }