// term:
//	literal (number, string, nil, boolean)
//	function (identifier)
//	.
//	.Field
//	variable
//	'(' expression ')'
// A term is a simple "expression".
// A nil return means the next item is not a term.
336194
func (t *Template) term() Node {
	switch token := t.nextNonSpace(); token.typ {
	case itemError:
		t.errorf("%s", token.val)
	case itemIdentifier:
		return t.newIdentifier(token.val, token.pos, t.lex.lineNumber())
	case itemNil:
		return t.newNil(token.pos)
	case itemField:
		return t.newField(token.pos, token.val)
	case itemBool:
		return t.newBool(token.pos, token.val == "true")
	case itemCharConstant, itemComplex, itemNumber:
		number, err := t.newNumber(token.pos, token.val, token.typ)
		if err != nil {
			t.error(err)
		}
		return number
	case itemLeftParen:
		pipe := t.expression("parenthesized expression")
		if token := t.next(); token.typ != itemRightParen {
			t.errorf("unclosed right paren: unexpected %s", token)
		}
		return pipe
	case itemString, itemRawString:
		s, err := unquote(token.val)
		if err != nil {
			t.error(err)
		}
		return t.newString(token.pos, token.val, s)
	}
	t.backup()
	return nil
}
1266877
func (value Value) String() string {
	result := ""
	catchPanic(func() {
		result = value.string()
	})
	return result
}
403777
func (e *Entity) Literal(path ...string) (Literal, error) {
	var cur = e
	var ok bool
	var lit Literal
	for i, prop := range path {
		var val Object
		val, ok = cur.Objects[Property(prop)]
		if !ok {
			return nil, ErrPathNotFound
		}
		if i == len(path)-1 {
			lit, ok = val.(Literal)
			if !ok {
				return nil, errors.Wrapf(ErrNotALiteral, "%#v", cur)
			}
			return lit, nil
		}
		cur, ok = val.(*Entity)
		if !ok {
			return nil, ErrPathNotFound
		}
	}
	return nil, ErrEmptyPath
}
520332
func Term() error {
	if initVersionError != nil {
		return initVersionError
	}
	if initContextError != nil {
		return initContextError
	}
	return defaultCtx.Term()
}
371966
func (d *decodeState) literal(v reflect.Value) {
	start := d.takePos()
	op, end := d.takeRecord()
	if op != scanEndLiteral {
		d.error(errPhase)
	}
	d.literalStore(d.data[start:end+1], v, false)
}
888911
func (g *Group) Var() *Statement {
	// notest
	s := Var()
	g.items = append(g.items, s)
	return s
}
806694
func (e *FieldEntry) String() string {
	value := e.Value
	if s, ok := value.(fmt.Stringer); ok {
		value = s.String()
	}

	switch v := value.(type) {
	case string:
		return fmt.Sprintf("%q:%q", e.Key, v)

	case error:
		return fmt.Sprintf("%q:%q", e.Key, v.Error())

	default:
		return fmt.Sprintf("%q:%#v", e.Key, v)
	}
}
1008523
func (p *Parser) Variable() bool {

	c, _ := p.Byte()

	if c != '$' {
		p.UnreadByte()
		return false
	}

	c, _ = p.Byte()
	if c == '\\' {
		p.ev.Add("$")
		return true
	}

	p.UnreadByte()

	i := p.ev.Level()

	c, _ = p.Byte()
	if c == '(' {
		p.ev.Add(TypeExpression)
		p.ev.Inc()
		p.Expression()
		p.Space()
		p.Byte() // Should be ')'
	} else {
		p.ev.Add(TypePath)
		p.ev.Inc()
		if c != '{' {
			p.UnreadByte()
		} else {
			p.Space()
		}
		p.Path()

		if c == '{' {
			p.Space()
			p.Byte() // Should be '}'
		}
	}

	// Reset the level
	p.ev.SetLevel(i)

	return true

}
1089950
func (expr *Expr) Operands() []*Term {
	terms, ok := expr.Terms.([]*Term)
	if !ok {
		return nil
	}
	return terms[1:]
}
1100613
func (v *Variable) TypeString() string {
	if v == nilVariable {
		return "nil"
	}
	if v.DwarfType != nil {
		return v.DwarfType.Common().Name
	}
	return v.Kind.String()
}
1069988
func (v *Argument) String() string {
	if v == nil {
		return "<nil>"
	}

	var fields [2]string
	i := 0
	fields[i] = fmt.Sprintf("Name: %v", v.Name)
	i++
	fields[i] = fmt.Sprintf("Type: %v", v.Type)
	i++

	return fmt.Sprintf("Argument{%v}", strings.Join(fields[:i], ", "))
}
84083
func (d DataType) String() string {
	switch d {
	case Float:
		return "float"
	case Integer:
		return "integer"
	case Unsigned:
		return "unsigned"
	case String:
		return "string"
	case Boolean:
		return "boolean"
	case Time:
		return "time"
	case Duration:
		return "duration"
	case Tag:
		return "tag"
	case AnyField:
		return "field"
	}
	return "unknown"
}
50641
func (f *Field) Name() string {
	// Return alias, if set.
	if f.Alias != "" {
		return f.Alias
	}

	// Return the function name or variable name, if available.
	switch expr := f.Expr.(type) {
	case *Call:
		return expr.Name
	case *BinaryExpr:
		return BinaryExprName(expr)
	case *ParenExpr:
		f := Field{Expr: expr.Expr}
		return f.Name()
	case *VarRef:
		return expr.Val
	}

	// Otherwise return a blank name.
	return ""
}
450010
func (expr *Expr) Operator() Ref {
	terms, ok := expr.Terms.([]*Term)
	if !ok || len(terms) == 0 {
		return nil
	}
	return terms[0].Value.(Ref)
}
1141011
func (by *ByItems) String() string {
	if by.Desc {
		return fmt.Sprintf("%s true", by.Expr)
	}
	return by.Expr.String()
}
426980
func expression(res ...*regexp.Regexp) *regexp.Regexp {
	var s string
	for _, re := range res {
		s += re.String()
	}

	return match(s)
}
430079
func (t Term) Or(args ...interface{}) Term {
	return constructMethodTerm(t, "Or", p.Term_OR, args, map[string]interface{}{})
}