From 7784031254cce80098826c6bd870de881063c1dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Sun, 16 Jun 2019 11:31:04 +0200 Subject: [PATCH 1/5] use Sprint instead of Sprintf --- debugon.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/debugon.go b/debugon.go index 9889dc4..dcb8678 100644 --- a/debugon.go +++ b/debugon.go @@ -45,7 +45,9 @@ func (dp *debugParser) logf(ps *State, result *Result, format string, args ...in buf.WriteString(fmt.Sprintf("%-15s", ps.Preview(15))) buf.WriteString(" | ") buf.WriteString(strings.Repeat(" ", len(activeParsers)-1)) - buf.WriteString(fmt.Sprint(append([]interface{}{format}, args...)...)) + //buf.WriteString(fmt.Sprintf(format, args...)) + buf.WriteString(format) + buf.WriteString(fmt.Sprint(args...)) if ps.Errored() { buf.WriteString(fmt.Sprintf(" did not find %s", ps.Error.expected)) } else if result != nil { From 68e6e3dab81254011e451775a54b3791d5bbc502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Sun, 16 Jun 2019 12:10:05 +0200 Subject: [PATCH 2/5] different tag for Chars and NotChars --- parser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parser.go b/parser.go index f008d33..489535c 100644 --- a/parser.go +++ b/parser.go @@ -197,13 +197,13 @@ func parseMatcher(matcher string) (alphabet string, ranges [][]rune) { // - min and max: Chars("a-z0-9", 4, 6) will match 4-6 lowercase alphanumeric characters // the above can be combined in any order func Chars(matcher string, repetition ...int) Parser { - return NewParser("["+matcher+"]", charsImpl(matcher, false, repetition...)) + return NewParser(fmt.Sprintf("Chars(%q)", matcher), charsImpl(matcher, false, repetition...)) } // NotChars accepts the full range of input from Chars, but it will stop when any // character matches. If you need to match until you see a sequence use Until instead func NotChars(matcher string, repetition ...int) Parser { - return NewParser("!["+matcher+"]", charsImpl(matcher, true, repetition...)) + return NewParser(fmt.Sprintf("!Chars(%q)", matcher), charsImpl(matcher, true, repetition...)) } func charsImpl(matcher string, stopOn bool, repetition ...int) Parser { From 6b9cd80df517fd7d85a256a950f3de726d7e619e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Sun, 16 Jun 2019 12:14:02 +0200 Subject: [PATCH 3/5] use Fprint instead of Fprintf in debug --- debugon.go | 4 ++-- parser.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/debugon.go b/debugon.go index dcb8678..49039c8 100644 --- a/debugon.go +++ b/debugon.go @@ -74,10 +74,10 @@ func (dp *debugParser) logStart(ps *State) { func (dp *debugParser) logEnd(ps *State, result *Result) { if log != nil { if pendingOpenLog != "" { - fmt.Fprintf(log, dp.logf(ps, result, dp.Name())) + fmt.Fprint(log, dp.logf(ps, result, dp.Name())) pendingOpenLog = "" } else { - fmt.Fprintf(log, dp.logf(ps, result, "}")) + fmt.Fprint(log, dp.logf(ps, result, "}")) } } } diff --git a/parser.go b/parser.go index 489535c..f008d33 100644 --- a/parser.go +++ b/parser.go @@ -197,13 +197,13 @@ func parseMatcher(matcher string) (alphabet string, ranges [][]rune) { // - min and max: Chars("a-z0-9", 4, 6) will match 4-6 lowercase alphanumeric characters // the above can be combined in any order func Chars(matcher string, repetition ...int) Parser { - return NewParser(fmt.Sprintf("Chars(%q)", matcher), charsImpl(matcher, false, repetition...)) + return NewParser("["+matcher+"]", charsImpl(matcher, false, repetition...)) } // NotChars accepts the full range of input from Chars, but it will stop when any // character matches. If you need to match until you see a sequence use Until instead func NotChars(matcher string, repetition ...int) Parser { - return NewParser(fmt.Sprintf("!Chars(%q)", matcher), charsImpl(matcher, true, repetition...)) + return NewParser("!["+matcher+"]", charsImpl(matcher, true, repetition...)) } func charsImpl(matcher string, stopOn bool, repetition ...int) Parser { From 7c62ed1a6b8f0397355d12298de09ab996764991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Tue, 18 Jun 2019 13:49:22 +0200 Subject: [PATCH 4/5] vektah -> oec to make it self-contained --- calc/calc.go | 2 +- go.mod | 10 ++++++++++ go.sum | 10 ++++++++++ html/html.go | 2 +- html/html_test.go | 2 +- json/json.go | 2 +- json/json_test.go | 2 +- json/profile/json.go | 4 ++-- 8 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/calc/calc.go b/calc/calc.go index a4d6f8a..1f7dc6a 100644 --- a/calc/calc.go +++ b/calc/calc.go @@ -3,7 +3,7 @@ package calc import ( "fmt" - . "github.com/vektah/goparsify" + . "github.com/oec/goparsify" ) var ( diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..4dea363 --- /dev/null +++ b/go.mod @@ -0,0 +1,10 @@ +module github.com/oec/goparsify + +go 1.12 + +require ( + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prataprc/goparsec v0.0.0-20170801142144-82de4f9400c2 + github.com/stretchr/testify v1.1.4 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..29b2c70 --- /dev/null +++ b/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prataprc/goparsec v0.0.0-20170801142144-82de4f9400c2 h1:JBQTPu1dlxC7Mp/lbF8WQMH206np5ZJYFbVyfjF9HL0= +github.com/prataprc/goparsec v0.0.0-20170801142144-82de4f9400c2/go.mod h1:YbpxZqbf10o5u96/iDpcfDQmbIOTX/iNCH/yBByTfaM= +github.com/stretchr/testify v1.1.4 h1:ToftOQTytwshuOSj6bDSolVUa3GINfJP/fg3OkkOzQQ= +github.com/stretchr/testify v1.1.4/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/vektah/goparsify v0.0.0-20180611020250-3e20a3b9244a h1:kjtLFYYtOh6EJz4svAJjY4apt9SJFQxe23e0mzTnlng= +github.com/vektah/goparsify v0.0.0-20180611020250-3e20a3b9244a/go.mod h1:DSfslQMj3gv774kof/dg5pwh62XUjimkRBoF2DgdyaY= diff --git a/html/html.go b/html/html.go index f6a715b..ce98d6c 100644 --- a/html/html.go +++ b/html/html.go @@ -1,7 +1,7 @@ package html import ( - . "github.com/vektah/goparsify" + . "github.com/oec/goparsify" ) func parse(input string) (result interface{}, err error) { diff --git a/html/html_test.go b/html/html_test.go index 79b0191..f0c2ac0 100644 --- a/html/html_test.go +++ b/html/html_test.go @@ -4,8 +4,8 @@ import ( "os" "testing" + "github.com/oec/goparsify" "github.com/stretchr/testify/require" - "github.com/vektah/goparsify" ) func TestParse(t *testing.T) { diff --git a/json/json.go b/json/json.go index 18f6870..ca1a905 100644 --- a/json/json.go +++ b/json/json.go @@ -1,7 +1,7 @@ package json import ( - . "github.com/vektah/goparsify" + . "github.com/oec/goparsify" ) var ( diff --git a/json/json_test.go b/json/json_test.go index 13f2e40..097bc34 100644 --- a/json/json_test.go +++ b/json/json_test.go @@ -6,9 +6,9 @@ import ( "os" + "github.com/oec/goparsify" parsecJson "github.com/prataprc/goparsec/json" "github.com/stretchr/testify/require" - "github.com/vektah/goparsify" ) func TestUnmarshal(t *testing.T) { diff --git a/json/profile/json.go b/json/profile/json.go index b7d9733..d02b5fa 100644 --- a/json/profile/json.go +++ b/json/profile/json.go @@ -7,8 +7,8 @@ import ( "runtime" "runtime/pprof" - "github.com/vektah/goparsify" - "github.com/vektah/goparsify/json" + "github.com/oec/goparsify" + "github.com/oec/goparsify/json" ) var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file") From 72355741026e72d12ac13a528adf20ed51e2131d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96zg=C3=BCr=20Kesim?= Date: Tue, 18 Jun 2019 13:51:23 +0200 Subject: [PATCH 5/5] cleanup files --- .circleci/config.yml | 13 ------------- .editorconfig | 9 --------- Gopkg.lock | 33 --------------------------------- Gopkg.toml | 7 ------- 4 files changed, 62 deletions(-) delete mode 100644 .circleci/config.yml delete mode 100644 .editorconfig delete mode 100644 Gopkg.lock delete mode 100644 Gopkg.toml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index bad883d..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,13 +0,0 @@ -version: 2 -jobs: - build: - docker: - - image: golang:1.9 - working_directory: /go/src/github.com/vektah/goparsify - steps: - - checkout - - run: go get -u github.com/golang/dep/cmd/dep github.com/alecthomas/gometalinter && gometalinter --install - - run: dep ensure --vendor-only - - run: go vet ./... - - run: go test -v ./... - - run: gometalinter . --disable gocyclo diff --git a/.editorconfig b/.editorconfig deleted file mode 100644 index eef10cc..0000000 --- a/.editorconfig +++ /dev/null @@ -1,9 +0,0 @@ -[*] -end_of_line = lf -insert_final_newline = true -charset = utf-8 -trim_trailing_whitespace = true - -[*.go] -indent_style = tab -indent_size = 4 \ No newline at end of file diff --git a/Gopkg.lock b/Gopkg.lock deleted file mode 100644 index 573ca3b..0000000 --- a/Gopkg.lock +++ /dev/null @@ -1,33 +0,0 @@ -# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. - - -[[projects]] - name = "github.com/davecgh/go-spew" - packages = ["spew"] - revision = "346938d642f2ec3594ed81d874461961cd0faa76" - version = "v1.1.0" - -[[projects]] - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - -[[projects]] - branch = "master" - name = "github.com/prataprc/goparsec" - packages = [".","json"] - revision = "82de4f9400c22ea84314f99bec5034895ae5eed9" - -[[projects]] - name = "github.com/stretchr/testify" - packages = ["assert","require"] - revision = "69483b4bd14f5845b5a1e55bca19e954e827f1d0" - version = "v1.1.4" - -[solve-meta] - analyzer-name = "dep" - analyzer-version = 1 - inputs-digest = "87eecb782b0100538dd03417f0dbedf48e19dec675ac73fb728f06da94d5606d" - solver-name = "gps-cdcl" - solver-version = 1 diff --git a/Gopkg.toml b/Gopkg.toml deleted file mode 100644 index 222c747..0000000 --- a/Gopkg.toml +++ /dev/null @@ -1,7 +0,0 @@ -[[constraint]] - branch = "master" - name = "github.com/prataprc/goparsec" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.1.4"