It's peg grammars for go plus even more.
The grammar files must be generated by peg:
go get github.com/pointlander/peg
go generate github.com/heyitsanthony/grammars
go get github.com/heyitsanthony/grammarsRun the grammar binary to parse some go into an AST:
grammars <main.goThe parse trees try to match specification BNF grammars. Each line is usually annotated with the original BNF. To ensure the PEG is well-formed, left recursion is regretfully eliminated.
Annotate these grammars with actions and compare against source grammars to ensure the parsing hasn't changed. Here pegcanon canonicalizes equivalent peg grammars by removing actions and whitespace:
go generate github.com/heyitsanthony/grammars/cmd/pegcanon
go get github.com/heyitsanthony/grammars/cmd/pegcanon
pegcanon <peg/peg.peg >1.peg
pegcanon <cmd/pegcanon/peg.peg >2.peg
diff 1.peg 2.pegUse the issue tracker
grammars is under the AGPLv3 license. See LICENSE for details.