func (primary *Primary) Parse(tokens []string) (predicate.Predicate, []string, error) {
	return primary.parseFunc(tokens)
}
Parse parses a predicate from the given primary.
package primary
import (
	"fmt"
	"strings"
	"github.com/puppetlabs/wash/cmd/internal/find/parser/errz"
	"github.com/puppetlabs/wash/cmd/internal/find/parser/predicate"
	"github.com/puppetlabs/wash/cmd/internal/find/types"
	cmdutil "github.com/puppetlabs/wash/cmd/util"
)
func Get(name string) *Primary {
	return Parser.primaryMap[tokenize(name)]
}
func IsSet(p *Primary) bool {
	return Parser.SetPrimaries[p]
}
func Table() *cmdutil.Table {
	rows := make([][]string, len(Parser.primaries))
	for i, p := range Parser.primaries {
		rows[i] = make([]string, 2)
		padding := 6
		if p.shortName != "" {
			padding = 2
		}
		rows[i][0] = strings.Repeat(" ", padding) + p.Usage()
		rows[i][1] = p.Description
	}
	rows = append(
		[][]string{
			[]string{"Primaries:", ""},
		},
		rows...,
	)
	return cmdutil.NewTable(rows...)
}
var Parser = &parser{
	primaryMap:   make(map[string]*Primary),
	SetPrimaries: make(map[*Primary]bool),
}
type parser struct {
	SetPrimaries map[*Primary]bool
	primaryMap   map[string]*Primary
	primaries    []*Primary
}
func (parser *parser) IsPrimary(token string) bool {
	_, ok := parser.primaryMap[token]
	return ok
}
func (parser *parser) Parse(tokens []string) (predicate.Predicate, []string, error) {
	if len(tokens) == 0 {
		return nil, nil, errz.NewMatchError("expected a primary")
	}
	token := tokens[0]
	primary, ok := parser.primaryMap[token]
	if !ok {
		msg := fmt.Sprintf("%v: unknown primary", token)
		return nil, nil, errz.NewMatchError(msg)
	}
	tokens = tokens[1:]
	p, tokens, err := primary.Parse(tokens)
	if errz.IsSyntaxError(err) {
		return nil, nil, fmt.Errorf("%v: %v", token, err)
	}
	parser.SetPrimaries[primary] = true
	return p, tokens, err
}
func (parser *parser) add(p *Primary) *Primary {
	p.tokens = make(map[string]struct{})
	parser.primaries = append(parser.primaries, p)
	for _, name := range []string{p.name, p.shortName} {
		if name != "" {
			token := tokenize(name)
			p.tokens[token] = struct{}{}
			parser.primaryMap[token] = p
		}
	}
	return p
}
type Primary struct {
	Description         string
	DetailedDescription string
	args                string
	shortName           string
	name                string
	tokens              map[string]struct{}
	parseFunc           types.EntryPredicateParser
}
func (primary *Primary) Usage() string {
	nameTk := tokenize(primary.name)
	usage := fmt.Sprintf("%v", nameTk)
	if primary.shortName != "" {
		shortNameTk := tokenize(primary.shortName)
		usage = fmt.Sprintf("%v, %v", shortNameTk, nameTk)
	}
	if primary.args != "" {
		usage += " " + primary.args
	}
	return usage
}