runes

package
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Feeder

type Feeder struct {
	sync.Mutex
	// contains filtered or unexported fields
}

feeder is a generic implementation of the output interfaces of Feeder

func NewFeeder

func NewFeeder(in io.Reader) *Feeder

NewFeeder creates a new Feeder using a Reader as input

func NewFeederBytes

func NewFeederBytes(b []byte) *Feeder

NewFeederBytes creates a new Feeder using an slice of bytes as input

func NewFeederString

func NewFeederString(s string) *Feeder

NewFeederString creates a new Feeder using a string as input

func (*Feeder) AtLeast

func (f *Feeder) AtLeast(n int) (out []rune, err error)

AtLeast blocks until there are at least n runes on the buffer, or an error or EOF has occurred

func (*Feeder) Buffered

func (f *Feeder) Buffered() int

Count of currently buffered runes

func (*Feeder) EOF

func (f *Feeder) EOF() bool

Feeder has reached EOF

func (*Feeder) Err

func (f *Feeder) Err() error

Feeder encountered an error

func (*Feeder) ReadRune

func (f *Feeder) ReadRune() (r rune, size int, err error)

ReadRune returns the next rune

func (*Feeder) Runes added in v0.1.1

func (f *Feeder) Runes() []rune

Currently buffered runes

func (*Feeder) Skip

func (f *Feeder) Skip(n int) (int, bool)

Skip drops n runes from the head of the buffer

type Probe

type Probe func([]rune) ([]rune, bool)

Probe is a func that returns a subset of the input and a success bool.

func And

func And(probes ...Probe) Probe

And returns a probe that accepts all probes in sequence.

func Any

func Any(probe Probe) Probe

Any returns a probe that accepts any number of occurrences of probe, including zero.

func AtLeast

func AtLeast(n int, probe Probe) Probe

AtLeast returns a probe that accepts probe at least n times.

func If

func If(condition func(rune) bool) Probe

If returns a probe that accepts the a rune if it satisfies the condition.

func Maybe

func Maybe(probe Probe) Probe

Maybe runs probe and returns true regardless of the output.

func N

func N(n int, probe Probe) Probe

N returns a probe that accepts probe exactly n times.

func Or

func Or(probes ...Probe) Probe

Or returns a probe that accepts the first successful probe in probes.

func Rune

func Rune(r rune) Probe

Rune returns a probe that accepts r.

func Space

func Space() Probe

Space returns a probe that accepts whitespace as defined in the unicode package.

Source Files

Jump to

Keyboard shortcuts

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