Module parser

Source
Expand description

Parser with iterators

Parses string tokens into model entities (Account, Transaction, Post, Amount…)

The main idea here is to minimize memory allocations. The parsing is done in functions, not objects. Each parser will provide an iterator over the tokens it recognizes, i.e. Xact parser will iterate over the Xact header items: date, payee, note. Post parser provides an iterator over Account, Amount. Amount parser provides sign, quantity, symbol, price. Iterator returns None if a token is not present.

Tokens are then handled by lexer, which creates instances of Structs and populates the collections in the Journal. It also creates links among the models. This functionality is from finalize() function.

Constants§

ISO_DATE_FORMAT
ISO_TIME_FORMAT

Functions§

parse_amount
parse_amount_parts
Parse amount parts (quantity, commodity), i.e. “25”, “AUD”. Returns Amount. Panics if parsing fails.
parse_datetime
Create DateTime from date string only.