//used internally to create an gte comparison BooleanExpression
550413
func gte(lhs Expression, rhs interface{}) BooleanExpression {
	return boolean{op: GTE_OP, lhs: lhs, rhs: rhs}
}
315480
func (b ValExprBuilder) NotRegExp(val interface{}) BoolExprBuilder {
	return b.makeComparisonExpr(astNotRegExp, makeValExpr(val))
}
834884
func _boolf(i interface{}) (bool, bool) {

	if i2, ok := i.(*Graph); ok {
		// i2 can still be nil (of type *Graph!)
		if i2 == nil {
			return false, false
		}
		i = i2.This
	}

	switch v := i.(type) {
	case []byte:
		s := string(v)

		if falseStr == s {
			return false, true
		}
		if trueStr == s {
			return true, true
		}
		return false, false
	case string:
		if falseStr == v {
			return false, true
		}
		if trueStr == v {
			return true, true
		}
		return false, false
	case bool:
		return v, true
	}

	return false, false
}
738405
func (env *Zlisp) EvalExpressions(xs []Sexp) (Sexp, error) {
	//P("inside EvalExpressions with env %p: xs[0] = %s", env, xs[0].SexpString(0))
	err := env.LoadExpressions(xs)
	if err != nil {
		return SexpNull, err
	}
	return env.Run()
}
230510
func (n *Namespace) Conditional(condition bool, a, b interface{}) interface{} {
	if condition {
		return a
	}
	return b
}
928969
func (m *qryconn) DeleteExpression(p interface{}, where expr.Node) (int, error) {

	return -1, schema.ErrNotImplemented
	/*
		_, ok := p.(*plan.Delete)
		if !ok {
			return 0, plan.ErrNoPlan
		}

		deletedKeys := make([]*Key, 0)
		m.bt.Ascend(func(a btree.Item) bool {
			di, ok := a.(*DriverItem)
			if !ok {
				u.Warnf("wat?  %T   %#v", a, a)
				return false
			}
			msgCtx := di.SqlDriverMessageMap
			whereValue, ok := vm.Eval(msgCtx, where)
			if !ok {
				u.Debugf("could not evaluate where: %v", msgCtx.Values())
				//return deletedCt, fmt.Errorf("Could not evaluate where clause")
				return true
			}
			switch whereVal := whereValue.(type) {
			case value.BoolValue:
				if whereVal.Val() == false {
					//this means do NOT delete
				} else {
					// Delete!
					indexVal := msgCtx.Values()[m.indexCol]
					deletedKeys = append(deletedKeys, NewKey(makeId(indexVal)))
				}
			case nil:
				// ??
			default:
				if whereVal.Nil() {
					// Doesn't match, so don't delete
				} else {
					u.Warnf("unknown type? %T", whereVal)
				}
			}
			return true
		})

		for _, deleteKey := range deletedKeys {
			if ct, err := m.Delete(deleteKey); err != nil {
				u.Errorf("Could not delete key: %v", deleteKey)
			} else if ct != 1 {
				u.Errorf("delete should have removed 1 key %v", deleteKey)
			}
		}
		return len(deletedKeys), nil
	*/
}
1049781
func checkBoolExpType(op BooleanOperation, lhs Expression, rhs interface{}, invert bool) BooleanExpression {
	if rhs == nil {
		op = IS_OP
	} else {
		switch reflect.Indirect(reflect.ValueOf(rhs)).Kind() {
		case reflect.Bool:
			op = IS_OP
		case reflect.Slice:
			//if its a slice of bytes dont treat as an IN
			if _, ok := rhs.([]byte); !ok {
				op = IN_OP
			}
		case reflect.Struct:
			switch rhs.(type) {
			case SqlExpression:
				op = IN_OP
			case *regexp.Regexp:
				return checkLikeExp(LIKE_OP, lhs, rhs, invert)
			}
		}
	}
	if invert {
		op = operator_inversions[op]
	}
	return boolean{op: op, lhs: lhs, rhs: rhs}
}
132721
func lte(lhs Expression, rhs interface{}) BooleanExpression {
	return boolean{op: LTE_OP, lhs: lhs, rhs: rhs}
}
1173503
func (e *Expect) Boolean(value bool) *Boolean {
	return NewBoolean(e.config.Reporter, value)
}
345840
func gt(arg1, arg2 interface{}) (bool, error) {
	// > is the inverse of <=.
	lessOrEqual, err := le(arg1, arg2)
	if err != nil {
		return false, err
	}
	return !lessOrEqual, nil
}
908864
func IsValidExpression(expr string) bool {
	_, err := parseExpression(expr)
	return err == nil
}
148738
func (obj *Doc) CheckExpression(ctx context.Context, expr string, labels []string) (string, []*NxRange, []*NxRange, error) {
	result := &struct {
		ErrorMsg string	`json:"qErrorMsg"`
		BadFieldNames []*NxRange	`json:"qBadFieldNames"`
		DangerousFieldNames []*NxRange	`json:"qDangerousFieldNames"`
	} {}
	err := obj.rpc(ctx, "CheckExpression", result, expr, labels)
	return result.ErrorMsg, result.BadFieldNames, result.DangerousFieldNames, err 
}
450387
func Gte(field string, v interface{}) Matcher {
	return NewFieldMatcher(field, &cmp{value: v, token: token.GEQ})
}
164449
func in(lhs Expression, vals ...interface{}) BooleanExpression {
	if len(vals) == 1 && reflect.Indirect(reflect.ValueOf(vals[0])).Kind() == reflect.Slice {
		return boolean{op: IN_OP, lhs: lhs, rhs: vals[0]}
	}
	return boolean{op: IN_OP, lhs: lhs, rhs: vals}
}
699133
func (v *Value) Boolean() (bool, error) {
	var valid bool

	// Check the type of this data
	switch v.data.(type) {
	case bool:
		valid = true
		break
	}

	if valid {
		return v.data.(bool), nil
	}

	return false, ErrNotBool
}
79467
func (me *DefaultAdapter) BooleanExpressionSql(buf *SqlBuilder, operator BooleanExpression) error {
	buf.WriteRune(left_paren_rune)
	if err := me.Literal(buf, operator.Lhs()); err != nil {
		return err
	}
	buf.WriteRune(space_rune)
	operatorOp := operator.Op()
	if operator.Rhs() == nil {
		switch operatorOp {
		case EQ_OP:
			operatorOp = IS_OP
		case NEQ_OP:
			operatorOp = IS_NOT_OP
		}
	}
	if val, ok := me.BooleanOperatorLookup[operatorOp]; ok {
		buf.Write(val)
	} else {
		return NewGoquError("Boolean operator %+v not supported", operatorOp)
	}
	rhs := operator.Rhs()
	if (operatorOp == IS_OP || operatorOp == IS_NOT_OP) && me.UseLiteralIsBools {
		if rhs == true {
			rhs = L("TRUE")
		} else if rhs == false {
			rhs = L("FALSE")
		}
	}
	buf.WriteRune(space_rune)
	if err := me.Literal(buf, rhs); err != nil {
		return err
	}
	buf.WriteRune(right_paren_rune)
	return nil
}
1223572
func Gte(left, right interface{}) Condition {
	return Condition{
		Type:  ConditionGte,
		Left:  NewOperand(left),
		Right: NewOperand(right),
	}
}