glob/match/match.go

48 lines
658 B
Go
Raw Normal View History

2015-12-24 17:54:54 +03:00
package match
2016-01-08 20:14:31 +03:00
import (
"fmt"
"strings"
)
2015-12-24 17:54:54 +03:00
type Kind int
2016-01-08 20:14:31 +03:00
// todo use String for Kind, and self.Kind() in every matcher.String()
const (
2015-12-24 17:54:54 +03:00
KindRaw Kind = iota
2016-01-08 20:14:31 +03:00
KindEveryOf
KindAnyOf
KindAny
KindSuper
2015-12-24 17:54:54 +03:00
KindSingle
2016-01-08 20:14:31 +03:00
KindComposition
2015-12-24 17:54:54 +03:00
KindPrefix
KindSuffix
KindPrefixSuffix
2016-01-08 20:14:31 +03:00
KindRange
KindList
KindMin
KindMax
KindBTree
KindContains
2015-12-24 17:54:54 +03:00
)
type Matcher interface {
Match(string) bool
2016-01-08 20:14:31 +03:00
}
type Primitive interface {
Index(string) (int, int, int)
}
type Matchers []Matcher
func (m Matchers) String() string {
var s []string
for _, matcher := range m {
s = append(s, fmt.Sprint(matcher))
}
return fmt.Sprintf("matchers[%s]", strings.Join(s, ","))
}