scanner

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const EOF = rune(0)

EOF is a rune representing the end of a file

Variables

This section is empty.

Functions

func ParseAccount

func ParseAccount(b *Scanner) (*accounts.Account, error)

ParseAccount parses an account

func ParseAccountType

func ParseAccountType(b *Scanner) (accounts.AccountType, error)

ParseAccountType parses an account type

func ParseCommodity

func ParseCommodity(p *Scanner) (*commodities.Commodity, error)

ParseCommodity parses a commodity

func ParseDate

func ParseDate(p *Scanner) (time.Time, error)

ParseDate parses a date as YYYY-MM-DD

func ParseDecimal

func ParseDecimal(p *Scanner) (decimal.Decimal, error)

ParseDecimal parses a decimal number

func ParseFloat

func ParseFloat(p *Scanner) (float64, error)

ParseFloat parses a floating point number

func ParseIdentifier

func ParseIdentifier(b *Scanner) (string, error)

ParseIdentifier parses an identifier

func ReadQuotedString

func ReadQuotedString(b *Scanner) (string, error)

ReadQuotedString parses a quoted string

func ReadString

func ReadString(p *Scanner, n int) (string, error)

ReadString reads a string with n runes

Types

type Scanner

type Scanner struct {

	// Path is the file path.
	Path string
	// contains filtered or unexported fields
}

Scanner is a backtracking reader.

func New

func New(r io.RuneReader, path string) (*Scanner, error)

New creates a new Scanner.

func (*Scanner) Advance

func (s *Scanner) Advance() error

Advance reads a rune.

func (*Scanner) ConsumeRune

func (s *Scanner) ConsumeRune(r rune) error

ConsumeRune consumes the given rune

func (*Scanner) ConsumeUntil

func (s *Scanner) ConsumeUntil(pred func(r rune) bool) error

ConsumeUntil advances the parser until the predicate holds

func (*Scanner) ConsumeWhile

func (s *Scanner) ConsumeWhile(pred func(r rune) bool) error

ConsumeWhile advances the parser while the predicate holds

func (*Scanner) Current

func (s *Scanner) Current() rune

Current returns the current rune.

func (*Scanner) ParseError added in v0.0.6

func (s *Scanner) ParseError(err error) error

ParseError creates a new parser error with the current position.

func (*Scanner) ParseString

func (s *Scanner) ParseString(str string) error

ParseString parses the given string

func (*Scanner) Position

func (s *Scanner) Position() model.FilePosition

Position returns the current position.

func (*Scanner) ReadRune

func (s *Scanner) ReadRune() (r rune, size int, err error)

ReadRune implements io.RuneReader.

func (*Scanner) ReadWhile

func (s *Scanner) ReadWhile(pred func(r rune) bool) (string, error)

ReadWhile reads runes into the builder while the predicate holds

Jump to

Keyboard shortcuts

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