Expand description
Beancount parser built on a Logos lexer + structured CST.
parse tokenizes via logos_lexer, constructs a lossless
CST through parse_structured, and walks it via the
converter in cst::convert to produce a ParseResult with
the typed AST plus errors, options, includes, plugins,
comments, and currency occurrences.
§Features
- Full Beancount syntax support (all 12 directive types)
- Error recovery (continues parsing after errors)
- Precise source locations for error reporting
- Support for includes, options, plugins
§Example
ⓘ
use rustledger_parser::parse;
let source = r#"
2024-01-15 * "Coffee Shop" "Morning coffee"
Expenses:Food:Coffee 5.00 USD
Assets:Cash
"#;
let result = parse(source);
assert!(result.errors.is_empty());
assert_eq!(result.directives.len(), 1);Re-exports§
pub use cst::BeancountLanguage;pub use cst::SyntaxElement;pub use cst::SyntaxKind;pub use cst::SyntaxNode;pub use cst::SyntaxToken;pub use cst::lossless_kind_tokens;pub use cst::parse_flat;pub use cst::parse_structured;pub use cst::parse_via_cst;
Modules§
- bom
- Canonical UTF-8 BOM handling — single source of truth.
- cst
- Lossless concrete syntax tree (CST) for Beancount.
- format
- Opinionated CST-backed formatter entries.
- logos_
lexer - SIMD-accelerated lexer using Logos.
Structs§
- Interned
Str - An interned string reference.
- Parse
Error - A parse error with location information.
- Parse
Result - Result of parsing a beancount file.
- Parse
Warning - A warning from the parser (non-fatal).
- Span
- A span in the source code, represented as a byte range.
- Spanned
- A value with an associated source location (span and file).
- Text
Range - A range in text, represented as a pair of
TextSize. - Text
Size - A measure of text length. Also, equivalently, an index into text.
Enums§
- Direction
- Node
OrToken - Parse
Error Kind - Kinds of parse errors.
- Token
AtOffset - There might be zero, one or two leaves at a given offset.
- Walk
Event WalkEventdescribes tree walking process.
Constants§
- SYNTHESIZED_
FILE_ ID - Sentinel
file_idindicating a directive was synthesized by a plugin rather than parsed from a source file.
Functions§
- parse
- Parse beancount source code.
- parse_
directives - Parse beancount source code, returning only directives and errors.