Beispiel #1
0
        public object VisitUnaryExpr(Expr.Unary expr)
        {
            object right = Evaluate(expr.Right);

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (expr.Operator.Type)
            {
            case MINUS:
                CheckNumberOperand(expr.Operator, right);
                return(-(double)right);

            case BANG:
                return(!IsTruthy(right));
            }

            return(null);
        }
Beispiel #2
0
 public object VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(null);
 }
Beispiel #3
0
 public string Visit(Expr.Unary expr)
 {
     return(Parenthesise(expr.Operator.Lexeme, expr.Right));
 }