Exemple #1
0
        object Expr.IVisitor <object> .VisitUnaryExpr(Expr.Unary expr)
        {
            object right = Evaluate(expr.right);

            switch (expr.op.type)
            {
            case TokenType.BANG:
                return(!IsTruthy(right));

            case TokenType.MINUS:
                return(-(double)right);
            }

            return(null);
        }
Exemple #2
0
        public object VisitUnaryExpr(Expr.Unary expr)
        {
            var right = Evaluate(expr.Right);

            switch (expr.Op.Type)
            {
            case BANG:
                return(!IsTruthy(right));

            case MINUS:
                CheckNumberOperand(expr.Op, right);
                return(-(double)right);
            }

            return(null);
        }
Exemple #3
0
        public object VisitUnary(Expr.Unary expr)
        {
            var right = Evaluate(expr.Right);

            switch (expr.Op.Type)
            {
            case TokenType.Bang:
                return(!IsTruthy(right));

            case TokenType.Minus:
                AssertNumberOperand(expr.Op, right);
                return(-(double)right);
            }

            throw new NotSupportedException();
        }
Exemple #4
0
 public string VisitUnary(Expr.Unary expr)
 {
     return(Parenthesize(expr.Op.Lexeme, expr.Right));
 }
Exemple #5
0
 public object VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(null);
 }
Exemple #6
0
 public Unit VisitUnary(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(Unit.Default);
 }
Exemple #7
0
 public Void Visit(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(Void.Instance);
 }
Exemple #8
0
 object Expr.IVisitor <object> .VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.right);
     return(null);
 }