diff --git a/cmd/globdraw/main.go b/cmd/globdraw/main.go index 585880d..c80609e 100644 --- a/cmd/globdraw/main.go +++ b/cmd/globdraw/main.go @@ -3,12 +3,13 @@ package main import ( "flag" "fmt" - "github.com/gobwas/glob" - "github.com/gobwas/glob/match" - "github.com/gobwas/glob/match/debug" "os" "strings" "unicode/utf8" + + "git.internal/re/glob" + "git.internal/re/glob/match" + "git.internal/re/glob/match/debug" ) func main() { diff --git a/cmd/globtest/main.go b/cmd/globtest/main.go index 95c102f..ddc00e6 100644 --- a/cmd/globtest/main.go +++ b/cmd/globtest/main.go @@ -3,11 +3,12 @@ package main import ( "flag" "fmt" - "github.com/gobwas/glob" "os" "strings" "testing" "unicode/utf8" + + "git.internal/re/glob" ) func benchString(r testing.BenchmarkResult) string { diff --git a/compiler/compiler.go b/compiler/compiler.go index 02e7de8..a527b12 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -7,9 +7,9 @@ import ( "fmt" "reflect" - "github.com/gobwas/glob/match" - "github.com/gobwas/glob/syntax/ast" - "github.com/gobwas/glob/util/runes" + "git.internal/re/glob/match" + "git.internal/re/glob/syntax/ast" + "git.internal/re/glob/util/runes" ) func optimizeMatcher(matcher match.Matcher) match.Matcher { diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index b58b1eb..840ce41 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -1,11 +1,12 @@ package compiler import ( - "github.com/gobwas/glob/match" - "github.com/gobwas/glob/match/debug" - "github.com/gobwas/glob/syntax/ast" "reflect" "testing" + + "git.internal/re/glob/match" + "git.internal/re/glob/match/debug" + "git.internal/re/glob/syntax/ast" ) var separators = []rune{'.'} diff --git a/glob.go b/glob.go index 2afde34..9f6f3a1 100644 --- a/glob.go +++ b/glob.go @@ -1,8 +1,8 @@ package glob import ( - "github.com/gobwas/glob/compiler" - "github.com/gobwas/glob/syntax" + "git.internal/re/glob/compiler" + "git.internal/re/glob/syntax" ) // Glob represents compiled glob pattern. @@ -13,29 +13,28 @@ type Glob interface { // Compile creates Glob for given pattern and strings (if any present after pattern) as separators. // The pattern syntax is: // -// pattern: -// { term } +// pattern: +// { term } // -// term: -// `*` matches any sequence of non-separator characters -// `**` matches any sequence of characters -// `?` matches any single non-separator character -// `[` [ `!` ] { character-range } `]` -// character class (must be non-empty) -// `{` pattern-list `}` -// pattern alternatives -// c matches character c (c != `*`, `**`, `?`, `\`, `[`, `{`, `}`) -// `\` c matches character c +// term: +// `*` matches any sequence of non-separator characters +// `**` matches any sequence of characters +// `?` matches any single non-separator character +// `[` [ `!` ] { character-range } `]` +// character class (must be non-empty) +// `{` pattern-list `}` +// pattern alternatives +// c matches character c (c != `*`, `**`, `?`, `\`, `[`, `{`, `}`) +// `\` c matches character c // -// character-range: -// c matches character c (c != `\\`, `-`, `]`) -// `\` c matches character c -// lo `-` hi matches character c for lo <= c <= hi -// -// pattern-list: -// pattern { `,` pattern } -// comma-separated (without spaces) patterns +// character-range: +// c matches character c (c != `\\`, `-`, `]`) +// `\` c matches character c +// lo `-` hi matches character c for lo <= c <= hi // +// pattern-list: +// pattern { `,` pattern } +// comma-separated (without spaces) patterns func Compile(pattern string, separators ...rune) (Glob, error) { ast, err := syntax.Parse(pattern) if err != nil { diff --git a/match/any.go b/match/any.go index 514a9a5..db4bcca 100644 --- a/match/any.go +++ b/match/any.go @@ -2,7 +2,8 @@ package match import ( "fmt" - "github.com/gobwas/glob/util/strings" + + "git.internal/re/glob/util/strings" ) type Any struct { diff --git a/match/debug/debug.go b/match/debug/debug.go index 5c5dbc1..1704ce6 100644 --- a/match/debug/debug.go +++ b/match/debug/debug.go @@ -3,8 +3,9 @@ package debug import ( "bytes" "fmt" - "github.com/gobwas/glob/match" "math/rand" + + "git.internal/re/glob/match" ) func Graphviz(pattern string, m match.Matcher) string { diff --git a/match/list.go b/match/list.go index 7fd763e..d11a8c5 100644 --- a/match/list.go +++ b/match/list.go @@ -2,8 +2,9 @@ package match import ( "fmt" - "github.com/gobwas/glob/util/runes" "unicode/utf8" + + "git.internal/re/glob/util/runes" ) type List struct { diff --git a/match/prefix_any.go b/match/prefix_any.go index 8ee58fe..c625ca4 100644 --- a/match/prefix_any.go +++ b/match/prefix_any.go @@ -5,7 +5,7 @@ import ( "strings" "unicode/utf8" - sutil "github.com/gobwas/glob/util/strings" + sutil "git.internal/re/glob/util/strings" ) type PrefixAny struct { diff --git a/match/single.go b/match/single.go index ee6e395..986581b 100644 --- a/match/single.go +++ b/match/single.go @@ -2,8 +2,9 @@ package match import ( "fmt" - "github.com/gobwas/glob/util/runes" "unicode/utf8" + + "git.internal/re/glob/util/runes" ) // single represents ? diff --git a/match/suffix_any.go b/match/suffix_any.go index c5106f8..471249d 100644 --- a/match/suffix_any.go +++ b/match/suffix_any.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - sutil "github.com/gobwas/glob/util/strings" + sutil "git.internal/re/glob/util/strings" ) type SuffixAny struct { diff --git a/readme.md b/readme.md index 682f0d6..b12c4b9 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ ## Install ```shell - go get github.com/gobwas/glob + go get git.internal/re/glob ``` ## Example @@ -16,7 +16,7 @@ package main -import "github.com/gobwas/glob" +import "git.internal/re/glob" func main() { var g glob.Glob @@ -137,8 +137,8 @@ Pattern | Fixture | Match | Speed (ns/op) `^ab.*ef$` | `abcdef` | `true` | 375 `^ab.*ef$` | `af` | `false` | 145 -[godoc-image]: https://godoc.org/github.com/gobwas/glob?status.svg -[godoc-url]: https://godoc.org/github.com/gobwas/glob +[godoc-image]: https://godoc.org/git.internal/re/glob?status.svg +[godoc-url]: https://godoc.org/git.internal/re/glob [travis-image]: https://travis-ci.org/gobwas/glob.svg?branch=master [travis-url]: https://travis-ci.org/gobwas/glob diff --git a/syntax/ast/parser.go b/syntax/ast/parser.go index 429b409..0cce1a7 100644 --- a/syntax/ast/parser.go +++ b/syntax/ast/parser.go @@ -3,8 +3,9 @@ package ast import ( "errors" "fmt" - "github.com/gobwas/glob/syntax/lexer" "unicode/utf8" + + "git.internal/re/glob/syntax/lexer" ) type Lexer interface { diff --git a/syntax/ast/parser_test.go b/syntax/ast/parser_test.go index a469d38..c3adc1c 100644 --- a/syntax/ast/parser_test.go +++ b/syntax/ast/parser_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/gobwas/glob/syntax/lexer" + "git.internal/re/glob/syntax/lexer" ) type stubLexer struct { @@ -27,7 +27,7 @@ func TestParseString(t *testing.T) { tree *Node }{ { - //pattern: "abc", + // pattern: "abc", tokens: []lexer.Token{ {lexer.Text, "abc"}, {lexer.EOF, ""}, @@ -37,7 +37,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "a*c", + // pattern: "a*c", tokens: []lexer.Token{ {lexer.Text, "a"}, {lexer.Any, "*"}, @@ -51,7 +51,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "a**c", + // pattern: "a**c", tokens: []lexer.Token{ {lexer.Text, "a"}, {lexer.Super, "**"}, @@ -65,7 +65,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "a?c", + // pattern: "a?c", tokens: []lexer.Token{ {lexer.Text, "a"}, {lexer.Single, "?"}, @@ -79,7 +79,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "[!a-z]", + // pattern: "[!a-z]", tokens: []lexer.Token{ {lexer.RangeOpen, "["}, {lexer.Not, "!"}, @@ -94,7 +94,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "[az]", + // pattern: "[az]", tokens: []lexer.Token{ {lexer.RangeOpen, "["}, {lexer.Text, "az"}, @@ -106,7 +106,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "{a,z}", + // pattern: "{a,z}", tokens: []lexer.Token{ {lexer.TermsOpen, "{"}, {lexer.Text, "a"}, @@ -127,7 +127,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "/{z,ab}*", + // pattern: "/{z,ab}*", tokens: []lexer.Token{ {lexer.Text, "/"}, {lexer.TermsOpen, "{"}, @@ -152,7 +152,7 @@ func TestParseString(t *testing.T) { ), }, { - //pattern: "{a,{x,y},?,[a-z],[!qwe]}", + // pattern: "{a,{x,y},?,[a-z],[!qwe]}", tokens: []lexer.Token{ {lexer.TermsOpen, "{"}, {lexer.Text, "a"}, diff --git a/syntax/lexer/lexer.go b/syntax/lexer/lexer.go index a1c8d19..570c005 100644 --- a/syntax/lexer/lexer.go +++ b/syntax/lexer/lexer.go @@ -3,8 +3,9 @@ package lexer import ( "bytes" "fmt" - "github.com/gobwas/glob/util/runes" "unicode/utf8" + + "git.internal/re/glob/util/runes" ) const ( @@ -146,8 +147,10 @@ func (l *lexer) termsLeave() { l.termsLevel-- } -var inTextBreakers = []rune{char_single, char_any, char_range_open, char_terms_open} -var inTermsBreakers = append(inTextBreakers, char_terms_close, char_comma) +var ( + inTextBreakers = []rune{char_single, char_any, char_range_open, char_terms_open} + inTermsBreakers = append(inTextBreakers, char_terms_close, char_comma) +) func (l *lexer) fetchItem() { r := l.read() diff --git a/syntax/syntax.go b/syntax/syntax.go index 1d168b1..2716a8b 100644 --- a/syntax/syntax.go +++ b/syntax/syntax.go @@ -1,8 +1,8 @@ package syntax import ( - "github.com/gobwas/glob/syntax/ast" - "github.com/gobwas/glob/syntax/lexer" + "git.internal/re/glob/syntax/ast" + "git.internal/re/glob/syntax/lexer" ) func Parse(s string) (*ast.Node, error) {