// F -> v | "(" O ")" | "!" O | "-" O | "NOT" C | "EXISTS" v | "IS" O | "AND (" O ")" | "OR (" O ")"
195103
func (t *tree) F(depth int) Node {
	debugf(depth, "F: %v", t.Cur())

	// Urnary operations
	switch cur := t.Cur(); cur.T {
	case lex.TokenNegate, lex.TokenMinus:

		t.Next() // consume NOT, !, Minus

		debugf(depth, "start:%v cur: %v   peek:%v", cur, t.Cur(), t.Peek())
		var arg Node

		switch t.Peek().T {
		case lex.TokenIN, lex.TokenLike, lex.TokenContains, lex.TokenBetween,
			lex.TokenIntersects:
			// TODO:  this is a bug.  An old version of generator was saving these
			//  NOT news INTERSECTS ("a")    which is invalid it should be
			//  news NOT INTERSECTS ("a")  OR NOT (news INTERSECTS ("a"))
			//
			// NOT <expr> LIKE <expr>
			// NOT <expr> INTERSECTS <expr>
			// NOT <expr> BETWEEN <expr> AND <expr>
			// NOT <expr> CONTAINS <expr>
			// NOT <expr> IN <expr>
			//
			// NOT identity > 7

			arg = t.C(depth + 1)
		default:

			switch t.Cur().T {
			case lex.TokenUdfExpr:
				arg = t.v(depth + 1)
			default:
				arg = t.C(depth + 1)
			}
		}
		n := NewUnary(cur, arg)
		debugf(depth, "f urnary: %s   arg: %#v", n, arg)
		return n
	case lex.TokenExists:
		// Urnary operations:  require right side value node
		t.Next() // Consume "EXISTS"
		debugf(depth, "F PRE  EXISTS:%v   cur:%v", cur, t.Cur())
		n := NewUnary(cur, t.v(depth+1))
		debugf(depth, "F POST EXISTS: %s  cur:%v", n, t.Cur())
		return n
	case lex.TokenIs:
		nxt := t.Next()
		if nxt.T == lex.TokenNegate {
			return NewUnary(cur, t.F(depth+1))
		}
		return NewUnary(cur, t.F(depth+1))
	case lex.TokenLogicAnd, lex.TokenLogicOr:
		debugf(depth, "found boolean and/or (O)? %v", cur)
		t.Next() // consume AND/OR
		t.discardNewLinesAndComments()
		switch t.Cur().T {
		case lex.TokenLeftParenthesis:
			t.Next() // Consume Left Paren
			t.discardNewLinesAndComments()
			n := NewBooleanNode(cur)
			t.boolean = true
			args, err, wasBoolean := nodeArray(t, depth)
			if err != nil {
				panic(fmt.Errorf("Unexpected %v", err))
			}
			n.Args = args
			if !wasBoolean {
				// Whoops, binary not boolean, there are some ambiguous ones:
				// binary:   x = y OR ( stuff > 5)
				// boolean:  AND (x = y, OR ( stuff > 5, x = 9))
				u.Warnf("not handled was boolean")
			}

			t.expect(lex.TokenRightParenthesis, "input")
			t.boolean = false
			t.Next()
			//debugf(depth, "found boolean expression %v", n.Collapse())
			return n.Collapse()
		}
		t.unexpected(t.Cur(), "Expected Left Paren after AND/OR ()")
	default:
		return t.v(depth)
	}
	panic("unreachable")
}
1227939
func (fs *fsImpl) Check() {
	fs.mu.Lock()
	defer fs.mu.Unlock()

	for k, v := range fs.inodes {
		if v.lookupCount != 0 {
			panic(fmt.Sprintf("Inode %v has lookup count %v", k, v.lookupCount))
		}
	}
}
976050
func (f Filter) LessThan(val interface{}) Filter {
	f.Op = "<"
	f.Val = val
	return f
}
1262729
func (t *T) Equalf(have, want interface{}, spec string, args ...interface{}) {
	t.EqualWithIgnoresf(have, want, nil, spec, args...)
}
20754
func ExistsIgnoreCase(set []string, find string) bool {
	find = strings.ToLower(find)
	for _, s := range set {
		if strings.ToLower(s) == find {
			return true
		}
	}
	return false
}
519494
func substringFunc(arg1, arg2, arg3 query) func(query, iterator) interface{} {
	return func(q query, t iterator) interface{} {
		var m string
		switch typ := arg1.Evaluate(t).(type) {
		case string:
			m = typ
		case query:
			node := typ.Select(t)
			if node == nil {
				return ""
			}
			m = node.Value()
		}

		var start, length float64
		var ok bool

		if start, ok = arg2.Evaluate(t).(float64); !ok {
			panic(errors.New("substring() function first argument type must be int"))
		} else if start < 1 {
			panic(errors.New("substring() function first argument type must be >= 1"))
		}
		start--
		if arg3 != nil {
			if length, ok = arg3.Evaluate(t).(float64); !ok {
				panic(errors.New("substring() function second argument type must be int"))
			}
		}
		if (len(m) - int(start)) < int(length) {
			panic(errors.New("substring() function start and length argument out of range"))
		}
		if length > 0 {
			return m[int(start):int(length+start)]
		}
		return m[int(start):]
	}
}
238924
func (f Flag) String(name string) (string, error) {
	return f.value(name)
}
519143
func Errorf(str string, vals ...interface{}) {
	log.di(fnLevelDiPlus1).Errorf(str, vals...)
}
579740
func (v *Bools) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [2]string
	i := 0
	if v.ImTrue != nil {
		fields[i] = fmt.Sprintf("ImTrue: %v", *(v.ImTrue))
		i++
	}
	if v.ImFalse != nil {
		fields[i] = fmt.Sprintf("ImFalse: %v", *(v.ImFalse))
		i++
	}

	return fmt.Sprintf("Bools{%v}", strings.Join(fields[:i], ", "))
}
117332
func (s Set) ContainsFunc(f func(string) bool) bool {
	for k := range s {
		if f(k) {
			return true
		}
	}
	return false
}
477488
func prec(op string) (result int) {
	if op == "-" || op == "+" {
		result = 1
	} else if op == "*" || op == "/" {
		result = 2
	} else if op == "^" || op == "%" || op == "**" {
		result = 3
	} else if op == "@" {
		result = 4
	} else if functions_rx.MatchString(op) {
		result = 5
	} else {
		result = 0
	}
	return
}
1268259
func (b Bool) If(fn func(bool)) {
	if b.Present() {
		fn(*b.value)
	}
}
980868
func (f verbFlag) Matches(v verbFlag) bool {
	if v == 0 {
		return false
	}
	return f&v == v
}
260617
func _() {
	var _ Event = (*Absolute)(nil)        // assert *Absolute implements Event
	var _ Event = (*FAbsolute)(nil)       // assert *FAbsolute implements Event
	var _ Event = (*Gauge)(nil)           // assert *Gauge implements Event
	var _ Event = (*FGauge)(nil)          // assert *FGauge implements Event
	var _ Event = (*GaugeDelta)(nil)      // assert *GaugeDelta implements Event
	var _ Event = (*FGaugeDelta)(nil)     // assert *FGaugeDelta implements Event
	var _ Event = (*Increment)(nil)       // assert *Increment implements Event
	var _ Event = (*PrecisionTiming)(nil) // assert *PrecisionTiming implements Event
	var _ Event = (*Timing)(nil)          // assert *Timing implements Event
	var _ Event = (*Total)(nil)           // assert *Total implements Event
}
258793
func (f *FlagSet) parseOne() (bool, error) {
	if len(f.args) == 0 {
		return false, nil
	}
	s := f.args[0]
	if len(s) == 0 || s[0] != '-' || len(s) == 1 {
		return false, nil
	}
	numMinuses := 1
	if s[1] == '-' {
		numMinuses++
		if len(s) == 2 { // "--" terminates the flags
			f.args = f.args[1:]
			return false, nil
		}
	}
	name := s[numMinuses:]
	if len(name) == 0 || name[0] == '-' || name[0] == '=' {
		return false, f.failf("bad flag syntax: %s", s)
	}

	// ignore go test flags
	if strings.HasPrefix(name, "test.") {
		return false, nil
	}

	// it's a flag. does it have an argument?
	f.args = f.args[1:]
	hasValue := false
	value := ""
	for i := 1; i < len(name); i++ { // equals cannot be first
		if name[i] == '=' {
			value = name[i+1:]
			hasValue = true
			name = name[0:i]
			break
		}
	}
	m := f.formal
	flag, alreadythere := m[name] // BUG
	if !alreadythere {
		if name == "help" || name == "h" { // special case for nice help message.
			f.usage()
			return false, ErrHelp
		}
		return false, f.failf("flag provided but not defined: -%s", name)
	}
	if fv, ok := flag.Value.(boolFlag); ok && fv.IsBoolFlag() { // special case: doesn't need an arg
		if hasValue {
			if err := fv.Set(value); err != nil {
				return false, f.failf("invalid boolean value %q for -%s: %v", value, name, err)
			}
		} else {
			if err := fv.Set("true"); err != nil {
				return false, f.failf("invalid boolean flag %s: %v", name, err)
			}
		}
	} else {
		// It must have a value, which might be the next argument.
		if !hasValue && len(f.args) > 0 {
			// value is the next arg
			hasValue = true
			value, f.args = f.args[0], f.args[1:]
		}
		if !hasValue {
			return false, f.failf("flag needs an argument: -%s", name)
		}
		if err := flag.Value.Set(value); err != nil {
			return false, f.failf("invalid value %q for flag -%s: %v", value, name, err)
		}
	}
	if f.actual == nil {
		f.actual = make(map[string]*Flag)
	}
	f.actual[name] = flag
	return true, nil
}
400173
func (self *Commands) Exists(value interface{}) error {
	if typeutil.V(value).String() != `` {
		return nil
	} else {
		return fmt.Errorf("Expected non-empty value")
	}
}
1256444
func (fv FlagValues) String(name string, defaultValue string) string {
	value, found := fv[name]
	if !found {
		return defaultValue
	}
	return value
}