ast

package
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package ast declares the types used to represent syntax trees for kpr files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Amount

type Amount struct {
	Decimal *BasicValue // DECIMAL
	Unit    *BasicValue // USYMBOL
}

An Amount node represents an amount.

func (*Amount) End

func (a *Amount) End() token.Pos

func (*Amount) Pos

func (a *Amount) Pos() token.Pos

type AmountLine

type AmountLine struct {
	*Amount
}

An AmountLine node represents an amount line node.

type BadEntry

type BadEntry struct {
	From, To token.Pos
}

A BadEntry node is a placeholder for an entry containing syntax errors for which a correct entry node cannot be created.

func (*BadEntry) End

func (b *BadEntry) End() token.Pos

func (*BadEntry) Pos

func (b *BadEntry) Pos() token.Pos

type BadLine

type BadLine struct {
	From, To token.Pos
}

A BadLine node is a placeholder for a line containing syntax errors for which a correct line node cannot be created.

func (*BadLine) End

func (b *BadLine) End() token.Pos

func (*BadLine) Pos

func (b *BadLine) Pos() token.Pos

type BalanceHeader

type BalanceHeader struct {
	TokPos  token.Pos
	Token   token.Token
	Date    *BasicValue // DATE
	Account *BasicValue // ACCTNAME
}

A BalanceHeader contains the fields shared by balance entry nodes.

func (*BalanceHeader) End

func (b *BalanceHeader) End() token.Pos

func (*BalanceHeader) Pos

func (b *BalanceHeader) Pos() token.Pos

type BasicValue

type BasicValue struct {
	ValuePos token.Pos
	Kind     token.Token // STRING, USYMBOL, ACCTNAME, DECIMAL, DATE
	Value    string
}

A BasicValue node represents a basic single token value.

func (*BasicValue) End

func (v *BasicValue) End() token.Pos

func (*BasicValue) Pos

func (v *BasicValue) Pos() token.Pos

type Comment added in v0.17.0

type Comment struct {
	// Position of starting #
	TokPos token.Pos
	// Comment text, including # and excluding trailing newline.
	Text string
}

A Comment node represents a comment.

func (*Comment) End added in v0.17.0

func (c *Comment) End() token.Pos

func (*Comment) Pos added in v0.17.0

func (c *Comment) Pos() token.Pos

type CommentGroup added in v0.17.0

type CommentGroup struct {
	// Must be non-empty
	List []*Comment
}

A CommentGroup represents consecutive comments.

func (*CommentGroup) End added in v0.17.0

func (c *CommentGroup) End() token.Pos

func (*CommentGroup) Pos added in v0.17.0

func (c *CommentGroup) Pos() token.Pos

type DeclareAccount added in v0.15.0

type DeclareAccount struct {
	TokPos   token.Pos
	Account  *BasicValue // ACCTNAME
	Metadata []LineNode  // MetadataLine, BadLine
	EndTok   *End
}

A DeclareAccount node represents a declare account entry node.

func (*DeclareAccount) End added in v0.15.0

func (c *DeclareAccount) End() token.Pos

func (*DeclareAccount) Pos added in v0.15.0

func (c *DeclareAccount) Pos() token.Pos

type DisableAccount added in v0.13.0

type DisableAccount struct {
	TokPos  token.Pos
	Date    *BasicValue // DATE
	Account *BasicValue // ACCTNAME
}

A DisableAccount node represents a disable account entry node.

func (*DisableAccount) End added in v0.13.0

func (c *DisableAccount) End() token.Pos

func (*DisableAccount) Pos added in v0.13.0

func (c *DisableAccount) Pos() token.Pos

type End added in v0.5.0

type End struct {
	TokPos token.Pos
}

An End node represents an end keyword ending a multiple line entry.

func (*End) End added in v0.5.0

func (d *End) End() token.Pos

func (*End) Pos added in v0.5.0

func (d *End) Pos() token.Pos

type Entry

type Entry interface {
	Node
	// contains filtered or unexported methods
}

All entry nodes implement Entry.

type File added in v0.17.0

type File struct {
	Entries  []Entry
	Comments []*CommentGroup
}

A File represents a source file.

type LineNode

type LineNode interface {
	Node
	// contains filtered or unexported methods
}

All line nodes implement LineNode.

type MetadataLine added in v0.15.0

type MetadataLine struct {
	TokPos token.Pos
	Key    *BasicValue // STRING
	Val    *BasicValue // STRING
}

A MetadataLine node represents a metadata line.

func (*MetadataLine) End added in v0.15.0

func (v *MetadataLine) End() token.Pos

func (*MetadataLine) Pos added in v0.15.0

func (v *MetadataLine) Pos() token.Pos

type MultiBalance

type MultiBalance struct {
	BalanceHeader
	Amounts []LineNode // AmountLine, BadLine
	EndTok  *End
}

A MultiBalance node represents a balance entry node spanning multiple lines.

func (*MultiBalance) End

func (b *MultiBalance) End() token.Pos

type Node

type Node interface {
	Pos() token.Pos // position of first character belonging to the node
	End() token.Pos // position of first character immediately after the node
}

All node types implement the Node interface.

type SingleBalance

type SingleBalance struct {
	BalanceHeader
	Amount *Amount
}

A SingleBalance node represents a balance entry node on a single line.

func (*SingleBalance) End

func (b *SingleBalance) End() token.Pos

type SplitLine added in v0.10.0

type SplitLine struct {
	Account *BasicValue // STRING
	Amount  *Amount
}

A SplitLine node represents a split line node in a transaction.

func (*SplitLine) End added in v0.10.0

func (s *SplitLine) End() token.Pos

func (*SplitLine) Pos added in v0.10.0

func (s *SplitLine) Pos() token.Pos

type Transaction

type Transaction struct {
	TokPos      token.Pos
	Date        *BasicValue // DATE
	Description *BasicValue // STRING
	Splits      []LineNode  // SplitLine, BadLine
	EndTok      *End
}

A Transaction node represents a transaction entry node.

func (*Transaction) End

func (t *Transaction) End() token.Pos

func (*Transaction) Pos

func (t *Transaction) Pos() token.Pos

type UnitDecl

type UnitDecl struct {
	TokPos token.Pos
	Unit   *BasicValue // USYMBOL
	Scale  *BasicValue // DECIMAL
}

A UnitDecl node represents a unit declaration entry node.

func (*UnitDecl) End

func (u *UnitDecl) End() token.Pos

func (*UnitDecl) Pos

func (u *UnitDecl) Pos() token.Pos

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL