This commit is contained in:
s.kamardin 2016-01-14 18:38:16 +03:00
parent 3995275190
commit c65eb46cf3
18 changed files with 3 additions and 118 deletions

3
.gitignore vendored
View File

@ -1,2 +1,5 @@
glob.iml
.idea
*.cpu
*.mem
*.test

View File

@ -39,10 +39,6 @@ func (self Any) Len() int {
return lenNo
}
func (self Any) Kind() Kind {
return KindAny
}
func (self Any) String() string {
return fmt.Sprintf("<any:![%s]>", self.Separators)
}

View File

@ -79,10 +79,6 @@ func (self AnyOf) Len() (l int) {
return
}
func (self AnyOf) Kind() Kind {
return KindAnyOf
}
func (self AnyOf) String() string {
return fmt.Sprintf("<any_of:[%s]>", self.Matchers)
}

View File

@ -42,10 +42,6 @@ func NewBTree(Value, Left, Right Matcher) (tree BTree) {
return tree
}
func (self BTree) Kind() Kind {
return KindBTree
}
func (self BTree) Len() int {
return self.Length
}

View File

@ -56,10 +56,6 @@ func (self Contains) Len() int {
return lenNo
}
func (self Contains) Kind() Kind {
return KindContains
}
func (self Contains) String() string {
var not string
if self.Not {

View File

@ -74,10 +74,6 @@ func (self EveryOf) Match(s string) bool {
return true
}
func (self EveryOf) Kind() Kind {
return KindEveryOf
}
func (self EveryOf) String() string {
return fmt.Sprintf("<every_of:[%s]>", self.Matchers)
}

View File

@ -11,10 +11,6 @@ type List struct {
Not bool
}
func (self List) Kind() Kind {
return KindList
}
func (self List) Match(s string) bool {
inList := strings.Index(self.List, s) != -1
return inList == !self.Not

View File

@ -5,28 +5,6 @@ import (
"strings"
)
type Kind int
// todo use String for Kind, and self.Kind() in every matcher.String()
const (
KindRaw Kind = iota
KindEveryOf
KindAnyOf
KindAny
KindSuper
KindSingle
KindComposition
KindPrefix
KindSuffix
KindPrefixSuffix
KindRange
KindList
KindMin
KindMax
KindBTree
KindContains
)
const lenOne = 1
const lenNo = -1

View File

@ -44,14 +44,6 @@ func (self Max) Len() int {
return lenNo
}
func (self Max) Search(s string) (int, int, bool) {
return 0, 0, false
}
func (self Max) Kind() Kind {
return KindMax
}
func (self Max) String() string {
return fmt.Sprintf("<max:%d>", self.Limit)
}

View File

@ -44,14 +44,6 @@ func (self Min) Len() int {
return lenNo
}
func (self Min) Search(s string) (int, int, bool) {
return 0, 0, false
}
func (self Min) Kind() Kind {
return KindMin
}
func (self Min) String() string {
return fmt.Sprintf("<min:%d>", self.Limit)
}

View File

@ -10,10 +10,6 @@ type Prefix struct {
Prefix string
}
func (self Prefix) Kind() Kind {
return KindPrefix
}
func (self Prefix) Index(s string) (int, []int) {
idx := strings.Index(s, self.Prefix)
if idx == -1 {
@ -41,14 +37,6 @@ func (self Prefix) Len() int {
return lenNo
}
func (self Prefix) Search(s string) (i int, l int, ok bool) {
if self.Match(s) {
return 0, len(s), true
}
return
}
func (self Prefix) Match(s string) bool {
return strings.HasPrefix(s, self.Prefix)
}

View File

@ -9,10 +9,6 @@ type PrefixSuffix struct {
Prefix, Suffix string
}
func (self PrefixSuffix) Kind() Kind {
return KindPrefixSuffix
}
func (self PrefixSuffix) Index(s string) (int, []int) {
prefixIdx := strings.Index(s, self.Prefix)
if prefixIdx == -1 {
@ -47,14 +43,6 @@ func (self PrefixSuffix) Len() int {
return lenNo
}
func (self PrefixSuffix) Search(s string) (i int, l int, ok bool) {
if self.Match(s) {
return 0, len(s), true
}
return
}
func (self PrefixSuffix) Match(s string) bool {
return strings.HasPrefix(s, self.Prefix) && strings.HasSuffix(s, self.Suffix)
}

View File

@ -10,10 +10,6 @@ type Range struct {
Not bool
}
func (self Range) Kind() Kind {
return KindRange
}
func (self Range) Len() int {
return lenOne
}

View File

@ -27,10 +27,6 @@ func (self Raw) Len() int {
return self.Length
}
func (self Raw) Kind() Kind {
return KindRaw
}
func (self Raw) Index(s string) (index int, segments []int) {
index = strings.Index(s, self.Str)
if index == -1 {

View File

@ -57,10 +57,6 @@ func (self Row) Index(s string) (int, []int) {
return -1, nil
}
func (self Row) Kind() Kind {
return KindMin
}
func (self Row) String() string {
return fmt.Sprintf("<row_%d:[%s]>", self.Length, self.Matchers)
}

View File

@ -29,10 +29,6 @@ func (self Single) Index(s string) (int, []int) {
return -1, nil
}
func (self Single) Kind() Kind {
return KindSingle
}
func (self Single) String() string {
return fmt.Sprintf("<single:![%s]>", self.Separators)
}

View File

@ -9,10 +9,6 @@ type Suffix struct {
Suffix string
}
func (self Suffix) Kind() Kind {
return KindSuffix
}
func (self Suffix) Index(s string) (int, []int) {
idx := strings.Index(s, self.Suffix)
if idx == -1 {
@ -26,14 +22,6 @@ func (self Suffix) Len() int {
return lenNo
}
func (self Suffix) Search(s string) (i int, l int, ok bool) {
if self.Match(s) {
return 0, len(s), true
}
return
}
func (self Suffix) Match(s string) bool {
return strings.HasSuffix(s, self.Suffix)
}

View File

@ -26,10 +26,6 @@ func (self Super) Index(s string) (int, []int) {
return 0, segments
}
func (self Super) Kind() Kind {
return KindSuper
}
func (self Super) String() string {
return fmt.Sprintf("<super>")
}