mirror of https://github.com/gobwas/glob.git
graphviz try
This commit is contained in:
parent
df67a5925f
commit
0be4bc46d1
|
@ -41,10 +41,10 @@ func TestCompilePattern(t *testing.T) {
|
||||||
sep string
|
sep string
|
||||||
exp match.Matcher
|
exp match.Matcher
|
||||||
}{
|
}{
|
||||||
// {
|
{
|
||||||
// pattern: "{*,def,abc[a-z]*}ghi",
|
pattern: "a?*",
|
||||||
// exp: match.Raw{"t"},
|
exp: match.Raw{"t"},
|
||||||
// },
|
},
|
||||||
} {
|
} {
|
||||||
glob, err := Compile(test.pattern, test.sep)
|
glob, err := Compile(test.pattern, test.sep)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -112,6 +112,23 @@ func (self BTree) Match(s string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const tpl = `
|
||||||
|
"%p"[label="%s"]
|
||||||
|
"%p"[label="%s"]
|
||||||
|
"%p"[label="%s"]
|
||||||
|
"%p"->"%p"
|
||||||
|
"%p"->"%p"
|
||||||
|
`
|
||||||
|
|
||||||
func (self BTree) String() string {
|
func (self BTree) String() string {
|
||||||
return fmt.Sprintf("[btree:%s<-%s->%s]", self.Left, self.Value, self.Right)
|
// return fmt.Sprintf("[btree:%s<-%s->%s]", self.Left, self.Value, self.Right)
|
||||||
|
|
||||||
|
l, r := "nil", "nil"
|
||||||
|
if self.Left != nil {
|
||||||
|
l = self.Left.String()
|
||||||
|
}
|
||||||
|
if self.Right != nil {
|
||||||
|
r = self.Right.String()
|
||||||
|
}
|
||||||
|
return fmt.Sprintf(tpl, &self, self.Value, &l, l, &r, r, &self, &l, &self, &r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ type Matcher interface {
|
||||||
Match(string) bool
|
Match(string) bool
|
||||||
Index(string) (int, []int)
|
Index(string) (int, []int)
|
||||||
Len() int
|
Len() int
|
||||||
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Matchers []Matcher
|
type Matchers []Matcher
|
||||||
|
|
Loading…
Reference in New Issue