Example #1
0
        public object visitUnaryExpr(Expr.UnaryExpr unaryExpr)
        {
            object right = evaluate(unaryExpr.right);

            switch (unaryExpr.operatorToken.type)
            {
            case TokenType.EXCLAMATION:
                return(!isTruthy(right));

            case TokenType.MINUS:
                checkNumberOperand(unaryExpr.operatorToken, right);
                return(-(double)right);

            case TokenType.MINUS_MINUS:
                checkNumberOperand(unaryExpr.operatorToken, right);
                return((double)right - 1.0);

            case TokenType.PLUS_PLUS:
                checkNumberOperand(unaryExpr.operatorToken, right);
                return((double)right + 1.0);
            }
            return(null);
        }
Example #2
0
 public object visitUnaryExpr(Expr.UnaryExpr unaryExpr)
 {
     resolve(unaryExpr.right);
     return(null);
 }
Example #3
0
 public string VisitUnaryExpr(Expr.UnaryExpr expr)
 {
     return(Parenthesize(expr.Operator.Lexeme, expr.Right));
 }
Example #4
0
 public string visitUnaryExpr(Expr.UnaryExpr expr)
 {
     return(parenthesize(expr.operatorToken.lexeme, new Expr[] { expr.right }));
 }
Example #5
0
 public object VisitUnaryExpr(Expr.UnaryExpr expr)
 {
     Resolve(expr.Right);
     return(null);
 }