private Expr Unary()
        {
            if (Match(out Token op, BANG, MINUS))
            {
                Expr right = Unary();
                Expr expr  = new Expr.Unary(op, right);
                return(expr);
            }

            return(Call());
        }
Beispiel #2
0
        public object visitUnaryExpr(Expr.Unary expr)
        {
            object right = evaluate(expr.right);

            switch (expr.op.type)
            {
            case TokenType.MINUS:
                checkNumberOperand(expr.op, right);
                return(-(double)right);

            case TokenType.BANG:
                return(!isTruthy(right));
            }

            // Unreachable.
            return(null);
        }
Beispiel #3
0
        public object VisitUnaryExpr(Expr.Unary expr)
        {
            var right = Evaluate(expr.Right);

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

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

            // Unreachable
            return(null);
        }
        public object VisitUnaryExpr(Expr.Unary expr)
        {
            object right = Evaluate(expr.right);

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

            case MINUS:
                TypeCheckNumberOperand(expr.op, right);
                return(-(double)right);
            }

            // Unreachable.
            return(null);
        }
Beispiel #5
0
 public string VisitUnaryExpr(Expr.Unary expr)
 => Parenthesize(expr.Operator.Lexeme, expr.Right);
Beispiel #6
0
 public string VisitUnaryExpr(Expr.Unary expr)
 {
     return(Parenthesize([email protected], expr.right));
 }
Beispiel #7
0
 public string visitUnaryExpr(Expr.Unary expr)
 {
     return(parenthesize(expr.op.lexeme, expr.right));
 }
Beispiel #8
0
 public object VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.right);
     return(null);
 }
Beispiel #9
0
 public Void VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(null);
 }