From 75853f590119b2f0fbd8f6b661123fd24bd3d8fe Mon Sep 17 00:00:00 2001 From: Shawn Smith Date: Mon, 15 Aug 2016 13:02:39 +0900 Subject: [PATCH] gofmt -s --- match/contains.go | 2 +- match/match_test.go | 8 +- match/max.go | 2 +- match/min.go | 2 +- match/row.go | 2 +- syntax/ast/parser_test.go | 124 +++++++++++++------------- syntax/lexer/lexer_test.go | 176 ++++++++++++++++++------------------- 7 files changed, 158 insertions(+), 158 deletions(-) diff --git a/match/contains.go b/match/contains.go index b4f57fc..0998e95 100644 --- a/match/contains.go +++ b/match/contains.go @@ -38,7 +38,7 @@ func (self Contains) Index(s string) (int, []int) { } segments := acquireSegments(len(s) + 1) - for i, _ := range s { + for i := range s { segments = append(segments, offset+i) } diff --git a/match/match_test.go b/match/match_test.go index 3b60a7c..4c1b83c 100644 --- a/match/match_test.go +++ b/match/match_test.go @@ -17,15 +17,15 @@ func TestAppendMerge(t *testing.T) { }{ { [2][]int{ - []int{0, 6, 7}, - []int{0, 1, 3}, + {0, 6, 7}, + {0, 1, 3}, }, []int{0, 1, 3, 6, 7}, }, { [2][]int{ - []int{0, 1, 3, 6, 7}, - []int{0, 1, 10}, + {0, 1, 3, 6, 7}, + {0, 1, 10}, }, []int{0, 1, 3, 6, 7, 10}, }, diff --git a/match/max.go b/match/max.go index 032ffbf..d72f69e 100644 --- a/match/max.go +++ b/match/max.go @@ -15,7 +15,7 @@ func NewMax(l int) Max { func (self Max) Match(s string) bool { var l int - for _ = range s { + for range s { l += 1 if l > self.Limit { return false diff --git a/match/min.go b/match/min.go index 96b34cb..db57ac8 100644 --- a/match/min.go +++ b/match/min.go @@ -15,7 +15,7 @@ func NewMin(l int) Min { func (self Min) Match(s string) bool { var l int - for _ = range s { + for range s { l += 1 if l >= self.Limit { return true diff --git a/match/row.go b/match/row.go index 820a60d..d0dcb35 100644 --- a/match/row.go +++ b/match/row.go @@ -43,7 +43,7 @@ func (self Row) matchAll(s string) bool { func (self Row) lenOk(s string) bool { var i int - for _ = range s { + for range s { i++ if i >= self.RunesLength { return true diff --git a/syntax/ast/parser_test.go b/syntax/ast/parser_test.go index d8440fd..292693b 100644 --- a/syntax/ast/parser_test.go +++ b/syntax/ast/parser_test.go @@ -28,8 +28,8 @@ func TestParseString(t *testing.T) { { //pattern: "abc", tokens: []lexer.Token{ - lexer.Token{lexer.Text, "abc"}, - lexer.Token{lexer.EOF, ""}, + {lexer.Text, "abc"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindText, Text{Text: "abc"}), @@ -38,10 +38,10 @@ func TestParseString(t *testing.T) { { //pattern: "a*c", tokens: []lexer.Token{ - lexer.Token{lexer.Text, "a"}, - lexer.Token{lexer.Any, "*"}, - lexer.Token{lexer.Text, "c"}, - lexer.Token{lexer.EOF, ""}, + {lexer.Text, "a"}, + {lexer.Any, "*"}, + {lexer.Text, "c"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindText, Text{Text: "a"}), @@ -52,10 +52,10 @@ func TestParseString(t *testing.T) { { //pattern: "a**c", tokens: []lexer.Token{ - lexer.Token{lexer.Text, "a"}, - lexer.Token{lexer.Super, "**"}, - lexer.Token{lexer.Text, "c"}, - lexer.Token{lexer.EOF, ""}, + {lexer.Text, "a"}, + {lexer.Super, "**"}, + {lexer.Text, "c"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindText, Text{Text: "a"}), @@ -66,10 +66,10 @@ func TestParseString(t *testing.T) { { //pattern: "a?c", tokens: []lexer.Token{ - lexer.Token{lexer.Text, "a"}, - lexer.Token{lexer.Single, "?"}, - lexer.Token{lexer.Text, "c"}, - lexer.Token{lexer.EOF, ""}, + {lexer.Text, "a"}, + {lexer.Single, "?"}, + {lexer.Text, "c"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindText, Text{Text: "a"}), @@ -80,13 +80,13 @@ func TestParseString(t *testing.T) { { //pattern: "[!a-z]", tokens: []lexer.Token{ - lexer.Token{lexer.RangeOpen, "["}, - lexer.Token{lexer.Not, "!"}, - lexer.Token{lexer.RangeLo, "a"}, - lexer.Token{lexer.RangeBetween, "-"}, - lexer.Token{lexer.RangeHi, "z"}, - lexer.Token{lexer.RangeClose, "]"}, - lexer.Token{lexer.EOF, ""}, + {lexer.RangeOpen, "["}, + {lexer.Not, "!"}, + {lexer.RangeLo, "a"}, + {lexer.RangeBetween, "-"}, + {lexer.RangeHi, "z"}, + {lexer.RangeClose, "]"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindRange, Range{Lo: 'a', Hi: 'z', Not: true}), @@ -95,10 +95,10 @@ func TestParseString(t *testing.T) { { //pattern: "[az]", tokens: []lexer.Token{ - lexer.Token{lexer.RangeOpen, "["}, - lexer.Token{lexer.Text, "az"}, - lexer.Token{lexer.RangeClose, "]"}, - lexer.Token{lexer.EOF, ""}, + {lexer.RangeOpen, "["}, + {lexer.Text, "az"}, + {lexer.RangeClose, "]"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindList, List{Chars: "az"}), @@ -107,12 +107,12 @@ func TestParseString(t *testing.T) { { //pattern: "{a,z}", tokens: []lexer.Token{ - lexer.Token{lexer.TermsOpen, "{"}, - lexer.Token{lexer.Text, "a"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.Text, "z"}, - lexer.Token{lexer.TermsClose, "}"}, - lexer.Token{lexer.EOF, ""}, + {lexer.TermsOpen, "{"}, + {lexer.Text, "a"}, + {lexer.Separator, ","}, + {lexer.Text, "z"}, + {lexer.TermsClose, "}"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindAnyOf, nil, @@ -128,14 +128,14 @@ func TestParseString(t *testing.T) { { //pattern: "/{z,ab}*", tokens: []lexer.Token{ - lexer.Token{lexer.Text, "/"}, - lexer.Token{lexer.TermsOpen, "{"}, - lexer.Token{lexer.Text, "z"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.Text, "ab"}, - lexer.Token{lexer.TermsClose, "}"}, - lexer.Token{lexer.Any, "*"}, - lexer.Token{lexer.EOF, ""}, + {lexer.Text, "/"}, + {lexer.TermsOpen, "{"}, + {lexer.Text, "z"}, + {lexer.Separator, ","}, + {lexer.Text, "ab"}, + {lexer.TermsClose, "}"}, + {lexer.Any, "*"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindText, Text{Text: "/"}), @@ -153,29 +153,29 @@ func TestParseString(t *testing.T) { { //pattern: "{a,{x,y},?,[a-z],[!qwe]}", tokens: []lexer.Token{ - lexer.Token{lexer.TermsOpen, "{"}, - lexer.Token{lexer.Text, "a"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.TermsOpen, "{"}, - lexer.Token{lexer.Text, "x"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.Text, "y"}, - lexer.Token{lexer.TermsClose, "}"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.Single, "?"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.RangeOpen, "["}, - lexer.Token{lexer.RangeLo, "a"}, - lexer.Token{lexer.RangeBetween, "-"}, - lexer.Token{lexer.RangeHi, "z"}, - lexer.Token{lexer.RangeClose, "]"}, - lexer.Token{lexer.Separator, ","}, - lexer.Token{lexer.RangeOpen, "["}, - lexer.Token{lexer.Not, "!"}, - lexer.Token{lexer.Text, "qwe"}, - lexer.Token{lexer.RangeClose, "]"}, - lexer.Token{lexer.TermsClose, "}"}, - lexer.Token{lexer.EOF, ""}, + {lexer.TermsOpen, "{"}, + {lexer.Text, "a"}, + {lexer.Separator, ","}, + {lexer.TermsOpen, "{"}, + {lexer.Text, "x"}, + {lexer.Separator, ","}, + {lexer.Text, "y"}, + {lexer.TermsClose, "}"}, + {lexer.Separator, ","}, + {lexer.Single, "?"}, + {lexer.Separator, ","}, + {lexer.RangeOpen, "["}, + {lexer.RangeLo, "a"}, + {lexer.RangeBetween, "-"}, + {lexer.RangeHi, "z"}, + {lexer.RangeClose, "]"}, + {lexer.Separator, ","}, + {lexer.RangeOpen, "["}, + {lexer.Not, "!"}, + {lexer.Text, "qwe"}, + {lexer.RangeClose, "]"}, + {lexer.TermsClose, "}"}, + {lexer.EOF, ""}, }, tree: NewNode(KindPattern, nil, NewNode(KindAnyOf, nil, diff --git a/syntax/lexer/lexer_test.go b/syntax/lexer/lexer_test.go index 26c8983..ec35f81 100644 --- a/syntax/lexer/lexer_test.go +++ b/syntax/lexer/lexer_test.go @@ -12,169 +12,169 @@ func TestLexGood(t *testing.T) { { pattern: "", items: []Token{ - Token{EOF, ""}, + {EOF, ""}, }, }, { pattern: "hello", items: []Token{ - Token{Text, "hello"}, - Token{EOF, ""}, + {Text, "hello"}, + {EOF, ""}, }, }, { pattern: "/{rate,[0-9]]}*", items: []Token{ - Token{Text, "/"}, - Token{TermsOpen, "{"}, - Token{Text, "rate"}, - Token{Separator, ","}, - Token{RangeOpen, "["}, - Token{RangeLo, "0"}, - Token{RangeBetween, "-"}, - Token{RangeHi, "9"}, - Token{RangeClose, "]"}, - Token{Text, "]"}, - Token{TermsClose, "}"}, - Token{Any, "*"}, - Token{EOF, ""}, + {Text, "/"}, + {TermsOpen, "{"}, + {Text, "rate"}, + {Separator, ","}, + {RangeOpen, "["}, + {RangeLo, "0"}, + {RangeBetween, "-"}, + {RangeHi, "9"}, + {RangeClose, "]"}, + {Text, "]"}, + {TermsClose, "}"}, + {Any, "*"}, + {EOF, ""}, }, }, { pattern: "hello,world", items: []Token{ - Token{Text, "hello,world"}, - Token{EOF, ""}, + {Text, "hello,world"}, + {EOF, ""}, }, }, { pattern: "hello\\,world", items: []Token{ - Token{Text, "hello,world"}, - Token{EOF, ""}, + {Text, "hello,world"}, + {EOF, ""}, }, }, { pattern: "hello\\{world", items: []Token{ - Token{Text, "hello{world"}, - Token{EOF, ""}, + {Text, "hello{world"}, + {EOF, ""}, }, }, { pattern: "hello?", items: []Token{ - Token{Text, "hello"}, - Token{Single, "?"}, - Token{EOF, ""}, + {Text, "hello"}, + {Single, "?"}, + {EOF, ""}, }, }, { pattern: "hellof*", items: []Token{ - Token{Text, "hellof"}, - Token{Any, "*"}, - Token{EOF, ""}, + {Text, "hellof"}, + {Any, "*"}, + {EOF, ""}, }, }, { pattern: "hello**", items: []Token{ - Token{Text, "hello"}, - Token{Super, "**"}, - Token{EOF, ""}, + {Text, "hello"}, + {Super, "**"}, + {EOF, ""}, }, }, { pattern: "[日-語]", items: []Token{ - Token{RangeOpen, "["}, - Token{RangeLo, "日"}, - Token{RangeBetween, "-"}, - Token{RangeHi, "語"}, - Token{RangeClose, "]"}, - Token{EOF, ""}, + {RangeOpen, "["}, + {RangeLo, "日"}, + {RangeBetween, "-"}, + {RangeHi, "語"}, + {RangeClose, "]"}, + {EOF, ""}, }, }, { pattern: "[!日-語]", items: []Token{ - Token{RangeOpen, "["}, - Token{Not, "!"}, - Token{RangeLo, "日"}, - Token{RangeBetween, "-"}, - Token{RangeHi, "語"}, - Token{RangeClose, "]"}, - Token{EOF, ""}, + {RangeOpen, "["}, + {Not, "!"}, + {RangeLo, "日"}, + {RangeBetween, "-"}, + {RangeHi, "語"}, + {RangeClose, "]"}, + {EOF, ""}, }, }, { pattern: "[日本語]", items: []Token{ - Token{RangeOpen, "["}, - Token{Text, "日本語"}, - Token{RangeClose, "]"}, - Token{EOF, ""}, + {RangeOpen, "["}, + {Text, "日本語"}, + {RangeClose, "]"}, + {EOF, ""}, }, }, { pattern: "[!日本語]", items: []Token{ - Token{RangeOpen, "["}, - Token{Not, "!"}, - Token{Text, "日本語"}, - Token{RangeClose, "]"}, - Token{EOF, ""}, + {RangeOpen, "["}, + {Not, "!"}, + {Text, "日本語"}, + {RangeClose, "]"}, + {EOF, ""}, }, }, { pattern: "{a,b}", items: []Token{ - Token{TermsOpen, "{"}, - Token{Text, "a"}, - Token{Separator, ","}, - Token{Text, "b"}, - Token{TermsClose, "}"}, - Token{EOF, ""}, + {TermsOpen, "{"}, + {Text, "a"}, + {Separator, ","}, + {Text, "b"}, + {TermsClose, "}"}, + {EOF, ""}, }, }, { pattern: "/{z,ab}*", items: []Token{ - Token{Text, "/"}, - Token{TermsOpen, "{"}, - Token{Text, "z"}, - Token{Separator, ","}, - Token{Text, "ab"}, - Token{TermsClose, "}"}, - Token{Any, "*"}, - Token{EOF, ""}, + {Text, "/"}, + {TermsOpen, "{"}, + {Text, "z"}, + {Separator, ","}, + {Text, "ab"}, + {TermsClose, "}"}, + {Any, "*"}, + {EOF, ""}, }, }, { pattern: "{[!日-語],*,?,{a,b,\\c}}", items: []Token{ - Token{TermsOpen, "{"}, - Token{RangeOpen, "["}, - Token{Not, "!"}, - Token{RangeLo, "日"}, - Token{RangeBetween, "-"}, - Token{RangeHi, "語"}, - Token{RangeClose, "]"}, - Token{Separator, ","}, - Token{Any, "*"}, - Token{Separator, ","}, - Token{Single, "?"}, - Token{Separator, ","}, - Token{TermsOpen, "{"}, - Token{Text, "a"}, - Token{Separator, ","}, - Token{Text, "b"}, - Token{Separator, ","}, - Token{Text, "c"}, - Token{TermsClose, "}"}, - Token{TermsClose, "}"}, - Token{EOF, ""}, + {TermsOpen, "{"}, + {RangeOpen, "["}, + {Not, "!"}, + {RangeLo, "日"}, + {RangeBetween, "-"}, + {RangeHi, "語"}, + {RangeClose, "]"}, + {Separator, ","}, + {Any, "*"}, + {Separator, ","}, + {Single, "?"}, + {Separator, ","}, + {TermsOpen, "{"}, + {Text, "a"}, + {Separator, ","}, + {Text, "b"}, + {Separator, ","}, + {Text, "c"}, + {TermsClose, "}"}, + {TermsClose, "}"}, + {EOF, ""}, }, }, } {