func (parser *parser) IsOp(token string) bool {
	_, ok := parser.opTokens[token]
	return ok
}
IsOp returns true if the given token represents the parentheses operator,
the not operator, or a binary operator.
package expression
import (
	"fmt"
	"github.com/golang-collections/collections/stack"
	"github.com/puppetlabs/wash/cmd/internal/find/parser/errz"
	"github.com/puppetlabs/wash/cmd/internal/find/parser/predicate"
)
type Parser interface {
	predicate.Parser
	IsOp(token string) bool
	SetUnknownTokenErrFunc(func(string) string)
	SetEmptyExpressionErrMsg(string)
	atom() *predicate.CompositeParser
	stack() *evalStack
	setStack(s *evalStack)
	insideParens() bool
	openParens()
	closeParens()
}
type parser struct {
	binaryOps             map[string]*BinaryOp
	Atom                  *predicate.CompositeParser
	Stack                 *evalStack
	numOpenParens         int
	opTokens              map[string]struct{}
	unknownTokenErrFunc   func(string) string
	emptyExpressionErrMsg string
}
func NewParser(predicateParser predicate.Parser, andOp predicate.BinaryOp, orOp predicate.BinaryOp) Parser {
	p := &parser{}
	p.binaryOps = make(map[string]*BinaryOp)
	p.opTokens = map[string]struct{}{
		"!":    struct{}{},
		"-not": struct{}{},
		"(":    struct{}{},
		")":    struct{}{},
	}
	for _, op := range []*BinaryOp{newAndOp(andOp), newOrOp(orOp)} {
		for _, token := range op.tokens {
			p.binaryOps[token] = op
			p.opTokens[token] = struct{}{}
		}
	}
	p.Atom = &predicate.CompositeParser{
		MatchErrMsg: "expected an atom",
		Parsers: []predicate.Parser{
			notOpParser(p),
			Parenthesize(p),
			predicateParser,
		},
	}
	p.SetEmptyExpressionErrMsg("empty expression")
	p.SetUnknownTokenErrFunc(func(token string) string {
		return fmt.Sprintf("unknown token %v", token)
	})
	return p
}
func (parser *parser) atom() *predicate.CompositeParser {
	return parser.Atom
}
func (parser *parser) stack() *evalStack {
	return parser.Stack
}
func (parser *parser) setStack(stack *evalStack) {
	parser.Stack = stack
}
func (parser *parser) insideParens() bool {
	return parser.numOpenParens > 0
}
func (parser *parser) openParens() {
	parser.numOpenParens++
}
func (parser *parser) closeParens() {
	parser.numOpenParens--
}