示例#1
0
        private Expr And()
        {
            var expr = Equality();

            while (Match(TokenType.And))
            {
                var op    = Previous();
                var right = Equality();
                expr = new LogicalExpr(expr, op, right);
            }

            return(expr);
        }
示例#2
0
        private Expr Or()
        {
            var expr = And();

            while (Match(TokenType.Or))
            {
                var op    = Previous();
                var right = And();
                expr = new LogicalExpr(expr, op, right);
            }

            return(expr);
        }
        public object VisitLogicalExpr(LogicalExpr expr)
        {
            var left = Evaluate(expr.Left);

            if (expr.Operator.Type == TokenType.Or)
            {
                if (IsTruthy(left))
                {
                    return(left);
                }
            }
            else
            {
                if (!IsTruthy(left))
                {
                    return(left);
                }
            }

            return(Evaluate(expr.Right));
        }
示例#4
0
 public void VisitLogicalExpr(LogicalExpr expr)
 {
     Resolve(expr.Left);
     Resolve(expr.Right);
 }
 public string VisitLogicalExpr(LogicalExpr expr)
 {
     throw new System.NotImplementedException();
 }