示例#1
0
        public string VisitUnaryExpr(Expr.Unary expr)
        {
            var sb = new StringBuilder();

            sb.Append(expr.Accept(this));
            sb.Append(" !");
            return(sb.ToString());
        }
示例#2
0
        public object VisitUnaryExpr(Expr.Unary expr)
        {
            object right = Evaluate(expr.Right);

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

            case MINUS:
                CheckNumberOperand(expr.Opr, right);
                return(-(double)right);
            }
            // unreachable
            return(null);
        }
示例#3
0
 public string VisitUnaryExpr(Expr.Unary expr)
 {
     return(Parenthesise(expr.Opr.Lexeme, expr.Right));
 }
示例#4
0
 public Nothing VisitUnaryExpr(Expr.Unary expr)
 {
     Resolve(expr.Right);
     return(Nothing.AtAll);
 }