goparsify [![CircleCI](https://circleci.com/gh/Vektah/goparsify/tree/master.svg?style=shield)](https://circleci.com/gh/Vektah/goparsify/tree/master) [![godoc](http://b.repl.ca/v1/godoc-reference-blue.png)](https://godoc.org/github.com/Vektah/goparsify) ========= A parser-combinator library for building easy to test, read and maintain parsers using functional composition. ### benchmarks I dont have many benchmarks set up yet, but the json parser is very promising. Nearly keeping up with the stdlib for raw speed: ``` $ go test -bench=. -benchtime=2s -benchmem ./json BenchmarkUnmarshalParsec-8 50000 71447 ns/op 50464 B/op 1318 allocs/op BenchmarkUnmarshalParsify-8 50000 56414 ns/op 43887 B/op 334 allocs/op BenchmarkUnmarshalStdlib-8 50000 50187 ns/op 13949 B/op 262 allocs/op PASS ok github.com/vektah/goparsify/json 10.840s ``` ### debugging parsers When a parser isnt working as you intended you can build with debugging and enable logging to get a detailed log of exactly what the parser is doing. 1. First build with debug using `-tags debug` 2. enable logging by passing a runtime flag -parselogs or calling `EnableLogging(os.Stdout)` in your code. This works great with tests, eg in the goparsify source tree ``` $ cd html $ go test -tags debug -parselogs html.go:50 |
hellohello
hello
hello
hello
hello
hello
| > html.go:26 | hello
| < | < html.go:20 | color="blue">w | p | identifier html.go:35 | color="blue">w | | attrs html.go:34 | color="blue">w | | attr html.go:20 | ="blue">world | color | identifier html.go:34 | "blue">world
worldworldworld | > html.go:26 | world