Documentation ¶
Overview ¶
Package parse implements a low-level parser of ledger files.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AmountNode ¶
type AmountNode struct { NodeType Pos Raw string // Raw representation of the amount, like "- CAD 100.20", with spacing and all. Will be used for printing unless empty, in which case the string will be reconstructed based on the other values herein. Quantity string Negative bool Commodity string ValueExpr string // Mutually exclusive with "Quantity". Expression, to be evaluated by some engine.. // contains filtered or unexported fields }
func (*AmountNode) String ¶
func (n *AmountNode) String() string
type CommentNode ¶
func (*CommentNode) String ¶
func (n *CommentNode) String() string
type CommodityNode ¶
type DirectiveNode ¶
type DirectiveNode struct { NodeType Pos Raw string Directive string Args string // contains filtered or unexported fields }
func (*DirectiveNode) String ¶
func (n *DirectiveNode) String() string
type ListNode ¶
type ListNode struct { NodeType Pos Nodes []Node // The top-level element nodes in lexical order. // contains filtered or unexported fields }
ListNode holds a sequence of Entry Nodes
type Node ¶
type Node interface { Type() NodeType String() string // Copy does a deep copy of the Node and all its components. // To avoid type assertions, some XxxNodes also have specialized // CopyXxx methods that return *XxxNode. //Copy() Node Position() Pos // byte position of start of node in full original input string // contains filtered or unexported methods }
A Node is an element in the parse tree. The interface is trivial. The interface contains an unexported method so that only types local to this package can satisfy it.
type Pos ¶
type Pos int
Pos represents a byte position in the original input text from which this template was parsed.
type PostingNode ¶
type PostingNode struct { NodeType Pos IsPending bool IsCleared bool AccountPreSpace string Account string AccountPostSpace string // if non-empty, this must always be two spaces, one space and one tab, one tab, or more whitespace, as per specs. Amount *AmountNode BalanceAssertion *AmountNode BalanceAssignment *AmountNode Price *AmountNode PriceIsForWhole bool // false = per unit (@); true = price for the whole (@@), meaningful only if `Price` is defined. LotDate time.Time LotPrice *AmountNode NotePreSpace string Note string // contains filtered or unexported fields }
func (*PostingNode) String ¶
func (n *PostingNode) String() string
type Tree ¶
type Tree struct { FileName string // name of the template represented by the tree. Root *ListNode // top-level root of the tree. // contains filtered or unexported fields }
Tree is the representation of a single parsed Ledger file.
func New ¶
New creates a new Parse Tree for a Ledger file. Call .Parse() with parameter to retrieve an AST and parsed nodes.
func (*Tree) ErrorContext ¶
ErrorContext returns a textual representation of the location of the node in the input text. The receiver is only used when the node does not have a pointer to the tree inside, which can occur in old code.