glob/match/match.go

50 lines
675 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-09 02:34:41 +03:00
Len() int
2016-01-08 20:14:31 +03:00
}
type Primitive interface {
2016-01-09 02:34:41 +03:00
Matcher
Index(string) (int, []int)
2016-01-08 20:14:31 +03:00
}
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, ","))
}