示例#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);
        }
示例#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);
        }
示例#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();
        }
示例#4
0
 public string VisitUnary(Expr.Unary expr)
 {
     return(Parenthesize(expr.Op.Lexeme, expr.Right));
 }
示例#5
0
 public object VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(null);
 }
示例#6
0
 public Unit VisitUnary(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(Unit.Default);
 }
示例#7
0
文件: Resolver.cs 项目: leddt/cslox
 public Void Visit(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(Void.Instance);
 }
示例#8
0
 object Expr.IVisitor <object> .VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.right);
     return(null);
 }