hledger-lib-0.22: Core data types, parsers and utilities for the hledger accounting tool.

Safe Haskell | None

Hledger.Read.JournalReader

Contents

- Reader
- Parsers used elsewhere

Description

A reader for hledger's journal file format (http://hledger.org/MANUAL.html#the-journal-file). hledger's journal format is a compatible subset of c++ ledger's (http://ledger-cli.org/3.0/doc/ledger3.html#Journal-Format), so this reader should handle many ledger files as well. Example:

    2012/3/24 gift
        expenses:gifts  $10
        assets:cash

Synopsis

- reader :: Reader
- parseJournalWith :: GenParser Char JournalContext (JournalUpdate, JournalContext) -> FilePath -> String -> ErrorT String IO Journal
- getParentAccount :: GenParser tok JournalContext String
- journal :: GenParser Char JournalContext (JournalUpdate, JournalContext)
- directive :: GenParser Char JournalContext JournalUpdate
- defaultyeardirective :: GenParser Char JournalContext JournalUpdate
- historicalpricedirective :: GenParser Char JournalContext HistoricalPrice
- datetime :: GenParser Char JournalContext LocalTime
- code :: GenParser Char JournalContext String
- accountname :: GenParser Char st AccountName
- amountp :: GenParser Char JournalContext Amount
- amountp' :: String -> Amount
- mamountp' :: String -> MixedAmount
- emptyline :: GenParser Char JournalContext ()

# Reader

reader :: Reader Source

# Parsers used elsewhere

parseJournalWith :: GenParser Char JournalContext (JournalUpdate, JournalContext) -> FilePath -> String -> ErrorT String IO Journal Source

Given a JournalUpdate-generating parsec parser, file path and data string, parse and post-process a Journal so that it's ready to use, or give an error.

getParentAccount :: GenParser tok JournalContext String Source

journal :: GenParser Char JournalContext (JournalUpdate, JournalContext)Source

Top-level journal parser. Returns a single composite, I/O performing, error-raising JournalUpdate (and final JournalContext) which can be applied to an empty journal to get the final result.

directive :: GenParser Char JournalContext JournalUpdate Source

defaultyeardirective :: GenParser Char JournalContext JournalUpdate Source

historicalpricedirective :: GenParser Char JournalContext HistoricalPrice Source

datetime :: GenParser Char JournalContext LocalTime Source

Parse a date and time in YYYYMMDD HH:MM[:SS][+-ZZZZ] format. Any timezone will be ignored; the time is treated as local time. Fewer digits are allowed, except in the timezone. The year may be omitted if a default year has already been set.

code :: GenParser Char JournalContext String Source

accountname :: GenParser Char st AccountName Source

Parse an account name. Account names may have single spaces inside them, and are terminated by two or more spaces. They should have one or more components of at least one character, separated by the account separator char.

amountp :: GenParser Char JournalContext Amount Source

Parse a single-commodity amount, with optional symbol on the left or right, optional unit or total price, and optional (ignored) ledger-style balance assertion or fixed lot price declaration.

amountp' :: String -> Amount Source

Parse an amount from a string, or get an error.

mamountp' :: String -> MixedAmount Source

Parse a mixed amount from a string, or get an error.

emptyline :: GenParser Char JournalContext ()Source