graphviz try

This commit is contained in:
s.kamardin 2016-01-12 20:49:12 +03:00
parent df67a5925f
commit 0be4bc46d1
3 changed files with 23 additions and 5 deletions

View File

@ -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 {

View File

@ -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)
} }

View File

@ -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