Documentation ¶
Index ¶
- func And[S any, B any, M any](x p.Combinator[byte, int, S], y p.Combinator[byte, int, B], ...) p.Combinator[byte, int, M]
- func Any() p.Combinator[byte, int, byte]
- func Between[T any, S any, B any](pre p.Combinator[byte, int, T], c p.Combinator[byte, int, S], ...) p.Combinator[byte, int, S]
- func Buffer(data []byte) *buffer
- func BufferFromFile(path string) (*buffer, error)
- func Cast[T any, S any](c p.Combinator[byte, int, T], f func(T) (S, error)) p.Combinator[byte, int, S]
- func Chainl[T any](c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T], def T) p.Combinator[byte, int, T]
- func Chainl1[T any](c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T]) p.Combinator[byte, int, T]
- func Chainr[T any](c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T], def T) p.Combinator[byte, int, T]
- func Chainr1[T any](c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T]) p.Combinator[byte, int, T]
- func Choice[T any](cs ...p.Combinator[byte, int, T]) p.Combinator[byte, int, T]
- func Concat[T any](cap int, cs ...p.Combinator[byte, int, []T]) p.Combinator[byte, int, []T]
- func Const[S any](value S) p.Combinator[byte, int, S]
- func Count[T any](n int, c p.Combinator[byte, int, T]) p.Combinator[byte, int, []T]
- func EOF() p.Combinator[byte, int, bool]
- func EndBy[T any, S any](cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func EndBy1[T any, S any](cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func Eq(t byte) p.Combinator[byte, int, byte]
- func Fail[S any](err error) p.Combinator[byte, int, S]
- func Gt(t byte) p.Combinator[byte, int, byte]
- func Gte(t byte) p.Combinator[byte, int, byte]
- func Lt(t byte) p.Combinator[byte, int, byte]
- func Lte(t byte) p.Combinator[byte, int, byte]
- func Many[T any](cap int, c p.Combinator[byte, int, T]) p.Combinator[byte, int, []T]
- func ManyTill[T any, S any](cap int, c p.Combinator[byte, int, T], end p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func Map[K comparable, V any](cases map[K]V, c p.Combinator[byte, int, K]) p.Combinator[byte, int, V]
- func NoneOf(data ...byte) p.Combinator[byte, int, byte]
- func NotEq(t byte) p.Combinator[byte, int, byte]
- func NotRange(from byte, to byte) p.Combinator[byte, int, byte]
- func OneOf(data ...byte) p.Combinator[byte, int, byte]
- func Optional[T any](c p.Combinator[byte, int, T], def T) p.Combinator[byte, int, T]
- func Or[T any](x p.Combinator[byte, int, T], y p.Combinator[byte, int, T]) p.Combinator[byte, int, T]
- func Padded[T any, S any](skip p.Combinator[byte, int, S], body p.Combinator[byte, int, T]) p.Combinator[byte, int, T]
- func Parse[T any](data []byte, parse common.Combinator[byte, int, T]) (T, error)
- func ParseFile[T any](path string, parse common.Combinator[byte, int, T]) (T, error)
- func Range(from byte, to byte) p.Combinator[byte, int, byte]
- func ReadAs[T Number](n int, order binary.ByteOrder) p.Combinator[byte, int, T]
- func Satisfy(greedy bool, f p.Condition[byte]) p.Combinator[byte, int, byte]
- func SepBy[T any, S any](cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func SepBy1[T any, S any](cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func SepEndBy[T any, S any](cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func SepEndBy1[T any, S any](cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S]) p.Combinator[byte, int, []T]
- func Sequence[T any](cap int, cs ...p.Combinator[byte, int, T]) p.Combinator[byte, int, []T]
- func SequenceOf(data ...byte) p.Combinator[byte, int, []byte]
- func Skip[T any, S any](skip p.Combinator[byte, int, S], body p.Combinator[byte, int, T]) p.Combinator[byte, int, T]
- func SkipAfter[T any, S any](skip p.Combinator[byte, int, S], body p.Combinator[byte, int, T]) p.Combinator[byte, int, T]
- func Some[T any](cap int, c p.Combinator[byte, int, T]) p.Combinator[byte, int, []T]
- func Trace[T any](l p.Logged, m string, c p.Combinator[rune, int, T]) p.Combinator[rune, int, T]
- func Try[T any](c p.Combinator[byte, int, T]) p.Combinator[byte, int, T]
- type Number
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
func And[S any, B any, M any]( x p.Combinator[byte, int, S], y p.Combinator[byte, int, B], compose p.Composer[S, B, M], ) p.Combinator[byte, int, M]
And - use x and y combinators to consume input bytes. Apply them result to compose function and return result of it.
func Between ¶
func Between[T any, S any, B any]( pre p.Combinator[byte, int, T], c p.Combinator[byte, int, S], suf p.Combinator[byte, int, B], ) p.Combinator[byte, int, S]
Between - parse sequence of input combinators, skip first and last results.
func Buffer ¶
func Buffer(data []byte) *buffer
Buffer - make buffer which can read bytes on input and use integer for positions.
func BufferFromFile ¶
Buffer - read file and make buffer which can read bytes on input and use integer for positions.
func Cast ¶
func Cast[T any, S any]( c p.Combinator[byte, int, T], f func(T) (S, error), ) p.Combinator[byte, int, S]
Cast - parse data by c combinator and apply to f function. Return result of f function.
func Chainl ¶
func Chainl[T any]( c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T], def T, ) p.Combinator[byte, int, T]
Chainl - read zero or more occurrences of byte readed by c combinator, separated by op combinator. Returns a value obtained by a left associative application of all functions returned by op combinator to the values returned by c combinator. If nothing read, the value def is returned.
func Chainl1 ¶
func Chainl1[T any]( c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T], ) p.Combinator[byte, int, T]
Chainl1 - read one or more occurrences of byte readed by c combinator, separated by data readed by op combinator. Returns a value obtained by a left associative application of all functions returned by op combinator to the values returned by c combinator. If nothing read, the value def is returned.
func Chainr ¶
func Chainr[T any]( c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T], def T, ) p.Combinator[byte, int, T]
Chainr - read zero or more occurrences of byte readed by c combinator, separated by op combinator. Returns a value obtained by a right associative application of all functions returned by op to the values returned by c combinator. If nothing read, the value def is returned.
func Chainr1 ¶
func Chainr1[T any]( c p.Combinator[byte, int, T], op p.Combinator[byte, int, func(T, T) T], ) p.Combinator[byte, int, T]
Chainr - read one or more occurrences of byte readed by c combinator, separated by op combinator. Returns a value obtained by a right associative application of all functions returned by op to the values returned by c combinator. If nothing read, the value def is returned.
func Choice ¶
func Choice[T any]( cs ...p.Combinator[byte, int, T], ) p.Combinator[byte, int, T]
Choice - searches for a combinator that works successfully on the input data. if one is not found, it returns an NothingMatched error.
func Concat ¶
func Concat[T any]( cap int, cs ...p.Combinator[byte, int, []T], ) p.Combinator[byte, int, []T]
Concat - use cs combinators to parse slices step by step, concatenate all result to one big slice and returns it.
func Const ¶
func Const[S any](value S) p.Combinator[byte, int, S]
Const - doesn't read anything, just return the input value.
func Count ¶
func Count[T any]( n int, c p.Combinator[byte, int, T], ) p.Combinator[byte, int, []T]
Count - try to read X item by c combinator. Stop on first error.
func EndBy ¶
func EndBy[T any, S any]( cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
EndBy - read zero or more occurrences of byte readed by c combinator, separated and ended by data readed by sep combinator. Returns a slice of values returned by p.
func EndBy1 ¶
func EndBy1[T any, S any]( cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
EndBy1 - read one or more occurrences of byte readed by c combinator, separated and ended by data readed by sep combinator. Returns a slice of values returned by c combinator.
func Eq ¶
Eq - succeeds for any byte which equal input t. Returns the byte that is actually readed from input buffer. Greedy by default - keep position after reading.
func Gt ¶
Gt - succeeds for any byte which greater than input value. Returns the byte that is actually readed from input buffer. Greedy by default - keep position after reading.
func Gte ¶
Gte - succeeds for any byte which greater than or equal input value. Returns the byte that is actually readed from input buffer. Greedy by default - keep position after reading.
func Lt ¶
Lt - succeeds for any byte which less than input value. Returns the byte that is actually readed from input buffer. Greedy by default - keep position after reading.
func Lte ¶
Lte - succeeds for any byte which less than or equal input byte. Returns the byte that is actually readed from input buffer. Greedy by default - keep position after reading.
func Many ¶
func Many[T any]( cap int, c p.Combinator[byte, int, T], ) p.Combinator[byte, int, []T]
Many - read bytes and accumulate data which returned by c consumer until it possible. Stop on first error or end of buffer. Returns an empty slice even if nothing could be parsed.
func ManyTill ¶
func ManyTill[T any, S any]( cap int, c p.Combinator[byte, int, T], end p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
ManyTill - accumulate data readed by c combinator until combinantor end succeeds. Returns a slice of values returned by body combinator.
func Map ¶
func Map[K comparable, V any]( cases map[K]V, c p.Combinator[byte, int, K], ) p.Combinator[byte, int, V]
Map - Reads one element from the bytes buffer using the combinator, then uses the resulting element to obtain a value from the map cases and returns it. If the value is not found then it returns NothingMatched error.
func NoneOf ¶
NoneOf - succeeds for any byte which not included in input data. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func NotEq ¶
NotEq - succeeds for any byte which not equal input t. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func NotRange ¶
NotRange - succeeds for any byte which not included in input range. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func OneOf ¶
OneOf - succeeds for any byte which included in input data. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Optional ¶
func Optional[T any]( c p.Combinator[byte, int, T], def T, ) p.Combinator[byte, int, T]
Optional - use c combinator to consume input byte from buffer. If it failed, than return def value.
func Or ¶
func Or[T any]( x p.Combinator[byte, int, T], y p.Combinator[byte, int, T], ) p.Combinator[byte, int, T]
Or - returns the result of the first combinator, if it fails, uses the second combinator.
func Padded ¶
func Padded[T any, S any]( skip p.Combinator[byte, int, S], body p.Combinator[byte, int, T], ) p.Combinator[byte, int, T]
Padded - skip sequence of items parsed by first combinator before and after body combinator.
func Range ¶
Range - succeeds for any bytes which include in input range. Returns the byte that is actually readed from input buffer. Greedy by default - keep position after reading.
func ReadAs ¶
ReadAs - read n of bytes, decode it in binary order passed by second argument and return it.
func Satisfy ¶
Satisfy - succeeds for any byte for which the supplied function f returns true. Returns the byte that is actually readed from input buffer. if greedy buffer keep position after reading.
func SepBy ¶
func SepBy[T any, S any]( cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
SepBy - read zero or more occurrences of byte readed by c combinator, separated by sep combinator. Returns a slice of values returned by p.
func SepBy1 ¶
func SepBy1[T any, S any]( cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
SepBy1 - read one or more occurrences of byte readed by c combinator, separated by sep combinator. Returns a slice of values returned by p.
func SepEndBy ¶
func SepEndBy[T any, S any]( cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
SepEndBy - read zero or more occurrences of byte readed by body combinator, separated and optionally ended by data readed by sep combinator. Returns a slice of values returned by body combinator.
func SepEndBy1 ¶
func SepEndBy1[T any, S any]( cap int, body p.Combinator[byte, int, T], sep p.Combinator[byte, int, S], ) p.Combinator[byte, int, []T]
SepEndBy1 - read one or more occurrences of byte readed by body combinator, separated and optionally ended by data readed by sep combinator. Returns a slice of values returned by body combinator.
func Sequence ¶
func Sequence[T any]( cap int, cs ...p.Combinator[byte, int, T], ) p.Combinator[byte, int, []T]
Sequence - reads input elements one by one using cs combinators. If any of them fails, it returns an error.
func SequenceOf ¶
SequenceOf - expects a sequence of bytes in the buffer equal to the input data sequence. If expectations are not met, returns NothingMatched error.
func Skip ¶
func Skip[T any, S any]( skip p.Combinator[byte, int, S], body p.Combinator[byte, int, T], ) p.Combinator[byte, int, T]
Skip - ignores the result of the first combinator and returns only the result of the second.
func SkipAfter ¶
func SkipAfter[T any, S any]( skip p.Combinator[byte, int, S], body p.Combinator[byte, int, T], ) p.Combinator[byte, int, T]
SkipAfter - ignores the result of the first combinator and returns only the result of the second. Use body combinator at first.
func Some ¶
func Some[T any]( cap int, c p.Combinator[byte, int, T], ) p.Combinator[byte, int, []T]
Some - read bytes and accumulate data which returned by c consumer until it possible. Stop on first error or end of buffer. Returns an error if at least one element could not be read.
Types ¶
type Number ¶
type Number interface { constraints.Integer | constraints.Float }