Skip to content

Commit

Permalink
graphviz try
Browse files Browse the repository at this point in the history
  • Loading branch information
s.kamardin committed Jan 12, 2016
1 parent df67a59 commit 0be4bc4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
8 changes: 4 additions & 4 deletions glob_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ func TestCompilePattern(t *testing.T) {
sep string
exp match.Matcher
}{
// {
// pattern: "{*,def,abc[a-z]*}ghi",
// exp: match.Raw{"t"},
// },
{
pattern: "a?*",
exp: match.Raw{"t"},
},
} {
glob, err := Compile(test.pattern, test.sep)
if err != nil {
Expand Down
19 changes: 18 additions & 1 deletion match/btree.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,23 @@ func (self BTree) Match(s string) bool {
return false
}

const tpl = `
"%p"[label="%s"]
"%p"[label="%s"]
"%p"[label="%s"]
"%p"->"%p"
"%p"->"%p"
`

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)
}
1 change: 1 addition & 0 deletions match/match.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Matcher interface {
Match(string) bool
Index(string) (int, []int)
Len() int
String() string
}

type Matchers []Matcher
Expand Down

0 comments on commit 0be4bc4

Please sign in to comment.