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

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

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

            // Unreachable.
            return(null);
        }
示例#2
0
 public string VisitUnaryExpr(Expr.Unary expr)
 {
     return(Parenthesize(expr.Operator.Lexeme, expr.Right));
 }
示例#3
0
 public object VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(null);
 }