tesujimath / beancount-parser-lima

A Beancount parser in Rust
https://docs.rs/beancount-parser-lima/latest/beancount_parser_lima/
Other
9 stars 0 forks source link
beancount parser rust

beancount-parser-lima

A zero-copy parser for Beancount in Rust.

It is intended to be a complete implementation of the Beancount file format, except for those parts which are deprecated and other features as documented here (in a list which may not be comprehensive).

Currently under active development. APIs are subject to change, but I hope not majorly.

The slightly strange name is because of a somewhat careless failure on my part to notice the existing beancount-parser when starting this project, for which apologies.

Features

Example application error messages

Roadmap and Status

beancount-parser-lima v0.2.1 is able to parse the example.beancount file from the official Beancount repo.

Examples

dump

This simply parses a Beancount file and outputs the results of parsing, using the Display implementations for the parser output types. The special filename STDIN causes it to read instead from standard input and parse the resulting inline string.

cargo run --example dump -- ./examples/data/full.beancount

check

This is an example of reporting errors against source locations by the application rather than the parser. This is important as semantic errors are not the business of the core parser to detect and report.

cargo run --example check -- ./examples/data/full.beancount

Uncertainties / TODOs

Yeah, Beancount is complicated, and I may have made some mistakes here. Current list of uncertainties, which is certainly not comprehensive.

Unsupported

This is an incomplete list of what is currently unsupported.

Unsupported Options

Also, unary options are not supported.

Parser Tests

The parser test cases are based on the parser tests from Beancount itself, extracted into a language independent format. That is, all the original tests have been replicated here, with some additions.

Each test comprises a Beancount file and expected parse output formatted as Protobuf Text Format Language, using the Beancount Protobuf schema from the Beancount repo.

Error cases in this repo have been converted to match the expected error message output of this parser.

Behaviour which differs from original Beancount parser has been annotated in the test with ANOMALY.

Tests for features unsupported in the Lima parser are left in test-cases-unsupported.

Alpha Status Dependencies

Alternatives

beancount-parser is another parser for Beancount which predates this one, using nom instead of Chumsky.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.