This is an example of a package for parsing the Ledger plain text accounting
format (https://www.ledger-cli.org). The parser itself is found in the parse
package and it uses the Pigeon Parsing Expression
Grammar (PEG) parser
generator. That should be installed using go get github.com/mna/pigeon
prior
to running go generate
. This was written to prepare my lightning talk given
at GopherCon 2019 in San Diego.
Note: This is really just a demonstration. I expect there to be bugs, and I'm not actually using this in anything at the moment. YMMV
Package parse
exposes three important functions for parsing ledger-formatted
text:
- Parse - parses the provided
[]byte
- ParseReader - parses the
io.Reader
provided - ParseFile - opens and parses the content of the filename provided