Documentation
¶
Index ¶
- func And[S any, B any, M any](x common.Combinator[rune, Position, S], y common.Combinator[rune, Position, B], ...) common.Combinator[rune, Position, M]
- func Angles[T any](body common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func Any() common.Combinator[rune, Position, rune]
- func Between[T any, S any, B any](pre common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, S]
- func Braces[T any](body common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func Buffer(data []rune, newLineRunes ...rune) *buffer
- func Cast[T any, S any](c common.Combinator[rune, Position, T], f func(T) (S, error)) common.Combinator[rune, Position, S]
- func Chainl[T any](def T, c common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, T]
- func Chainl1[T any](c common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, T]
- func Chainr[T any](def T, c common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, T]
- func Chainr1[T any](c common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, T]
- func Choice[T any](cs ...common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func Colon() common.Combinator[rune, Position, rune]
- func Comma() common.Combinator[rune, Position, rune]
- func Concat[T any](cap int, cs ...common.Combinator[rune, Position, []T]) common.Combinator[rune, Position, []T]
- func Const[S any](value S) common.Combinator[rune, Position, S]
- func Control(errMessage string) common.Combinator[rune, Position, rune]
- func Count[T any](cap int, errMessage string, c common.Combinator[rune, Position, T]) common.Combinator[rune, Position, []T]
- func Digit(errMessage string) common.Combinator[rune, Position, rune]
- func Dot() common.Combinator[rune, Position, rune]
- func EOF() common.Combinator[rune, Position, bool]
- func EndBy[T any, S any](cap int, body common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func EndBy1[T any, S any](cap int, errMessage string, body common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func Eq(errMessage string, t rune) common.Combinator[rune, Position, rune]
- func Fail[S any](errMessage string) common.Combinator[rune, Position, S]
- func Graphic(errMessage string) common.Combinator[rune, Position, rune]
- func Gt(errMessage string, t rune) common.Combinator[rune, Position, rune]
- func Gte(errMessage string, t rune) common.Combinator[rune, Position, rune]
- func Letter(errMessage string) common.Combinator[rune, Position, rune]
- func Lower(errMessage string) common.Combinator[rune, Position, rune]
- func Lt(errMessage string, t rune) common.Combinator[rune, Position, rune]
- func Lte(errMessage string, t rune) common.Combinator[rune, Position, rune]
- func Many[T any](cap int, c common.Combinator[rune, Position, T]) common.Combinator[rune, Position, []T]
- func ManyTill[T any, S any](cap int, errMessage string, c common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func Map[K comparable, V any](errMessage string, cases map[K]V, c common.Combinator[rune, Position, K]) common.Combinator[rune, Position, V]
- func MapStrings[V any](errMessage string, cases map[string]V) common.Combinator[rune, Position, V]
- func Mark(errMessage string) common.Combinator[rune, Position, rune]
- func NoneOf(errMessage string, data ...rune) common.Combinator[rune, Position, rune]
- func NotEq(errMessage string, r rune) common.Combinator[rune, Position, rune]
- func NotRange(errMessage string, from, to rune) common.Combinator[rune, Position, rune]
- func Number(errMessage string) common.Combinator[rune, Position, rune]
- func OneOf(errMessage string, data ...rune) common.Combinator[rune, Position, rune]
- func Optional[T any](c common.Combinator[rune, Position, T], def T) common.Combinator[rune, Position, T]
- func Or[T any](errMessage string, x common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, T]
- func Padded[T any, S any](skip common.Combinator[rune, Position, S], ...) common.Combinator[rune, Position, T]
- func Parens[T any](body common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func Parse[T any](data []rune, parse common.Combinator[rune, Position, T]) (T, common.Error[Position])
- func ParseString[T any](str string, parse common.Combinator[rune, Position, T]) (T, common.Error[Position])
- func Print(errMessage string) common.Combinator[rune, Position, rune]
- func Punct(errMessage string) common.Combinator[rune, Position, rune]
- func Range(errMessage string, from, to rune) common.Combinator[rune, Position, rune]
- func RangeTable(errMessage string, tbl *unicode.RangeTable) common.Combinator[rune, Position, rune]
- func Satisfy(errMessage string, greedy bool, f common.Condition[rune]) common.Combinator[rune, Position, rune]
- func Semi() common.Combinator[rune, Position, rune]
- func SepBy[T any, S any](cap int, body common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func SepBy1[T any, S any](cap int, errMessage string, body common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func SepEndBy[T any, S any](cap int, body common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func SepEndBy1[T any, S any](cap int, errMessage string, body common.Combinator[rune, Position, T], ...) common.Combinator[rune, Position, []T]
- func Sequence[T any](cap int, cs ...common.Combinator[rune, Position, T]) common.Combinator[rune, Position, []T]
- func SequenceOf(errMessage string, data ...rune) common.Combinator[rune, Position, []rune]
- func Skip[T any, S any](skip common.Combinator[rune, Position, S], ...) common.Combinator[rune, Position, T]
- func SkipAfter[T any, S any](skip common.Combinator[rune, Position, S], ...) common.Combinator[rune, Position, T]
- func SkipMany[T any, S any](skip common.Combinator[rune, Position, S], ...) common.Combinator[rune, Position, T]
- func Some[T any](cap int, errMessage string, c common.Combinator[rune, Position, T]) common.Combinator[rune, Position, []T]
- func Space(errMessage string) common.Combinator[rune, Position, rune]
- func Squares[T any](body common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func String(errMessage, str string) common.Combinator[rune, Position, string]
- func Symbol(errMessage string) common.Combinator[rune, Position, rune]
- func TimeZone(locations ...*time.Location) common.Combinator[rune, Position, *time.Location]
- func TimeZoneByNames(locationNames ...string) (common.Combinator[rune, Position, *time.Location], error)
- func Title(errMessage string) common.Combinator[rune, Position, rune]
- func Trace[T any](l common.Logged, m string, c common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func Try[T any](c common.Combinator[rune, Position, T]) common.Combinator[rune, Position, T]
- func Unsigned[T constraints.Integer]() common.Combinator[rune, Position, T]
- func UnsignedN[T constraints.Integer](n int, errMessage string) common.Combinator[rune, Position, T]
- func Upper(errMessage string) common.Combinator[rune, Position, rune]
- type Position
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func And ¶
func And[S any, B any, M any]( x common.Combinator[rune, Position, S], y common.Combinator[rune, Position, B], compose common.Composer[S, B, M], ) common.Combinator[rune, Position, M]
And - use x and y combinators to consume input data. Apply them result to compose function and return result of it.
func Angles ¶
func Angles[T any]( body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Angles - parse something between angels characters - '<' and '>'.
func Between ¶
func Between[T any, S any, B any]( pre common.Combinator[rune, Position, T], c common.Combinator[rune, Position, S], suf common.Combinator[rune, Position, B], ) common.Combinator[rune, Position, S]
Between - parse sequence of input combinators, skip first and last results.
func Braces ¶
func Braces[T any]( body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Braces - parse something between braces characters - '{' and '}'.
func Cast ¶
func Cast[T any, S any]( c common.Combinator[rune, Position, T], f func(T) (S, error), ) common.Combinator[rune, Position, S]
Cast - parse data by c combinator and apply to f function. Return result of f function.
func Chainl ¶
func Chainl[T any]( def T, c common.Combinator[rune, Position, T], op common.Combinator[rune, Position, common.BinaryOp[T]], ) common.Combinator[rune, Position, T]
Chainl - read zero or more occurrences of data 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 common.Combinator[rune, Position, T], op common.Combinator[rune, Position, common.BinaryOp[T]], ) common.Combinator[rune, Position, T]
Chainl1 - read one or more occurrences of data 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]( def T, c common.Combinator[rune, Position, T], op common.Combinator[rune, Position, common.BinaryOp[T]], ) common.Combinator[rune, Position, T]
Chainr - read zero or more occurrences of data 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 common.Combinator[rune, Position, T], op common.Combinator[rune, Position, common.BinaryOp[T]], ) common.Combinator[rune, Position, T]
Chainr - read one or more occurrences of data 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 ...common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Choice - searches for a combinator that works successfully on the input data. if one is not found, it returns an ParseError error.
func Concat ¶
func Concat[T any]( cap int, cs ...common.Combinator[rune, Position, []T], ) common.Combinator[rune, Position, []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) common.Combinator[rune, Position, S]
Const - doesn't read anything, just return the input value.
func Control ¶
Control - parse control UTF-8 characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Count ¶
func Count[T any]( cap int, errMessage string, c common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, []T]
Count - try to read X item by c combinator. Stop on first error.
func Digit ¶
Digit - parse decimal digit UTF-8 characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func EOF ¶
func EOF() common.Combinator[rune, Position, bool]
EOF - checks that buffer reading has finished.
func EndBy ¶
func EndBy[T any, S any]( cap int, body common.Combinator[rune, Position, T], sep common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []T]
EndBy - read zero or more occurrences of data 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, errMessage string, body common.Combinator[rune, Position, T], sep common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []T]
EndBy1 - read one or more occurrences of data 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 item which equal input t. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Graphic ¶
Graphic - parse graphic UTF-8 characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Gt ¶
Gt - succeeds for any item which greater than input value. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Gte ¶
Gte - succeeds for any item which greater than or equal input value. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Letter ¶
Letter - parse letter UTF-8 characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Lower ¶
Lower - parse UTF-8 character in lower case. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Lt ¶
Lt - succeeds for any item which less than input value. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Lte ¶
Lte - succeeds for any item which less than or equal input value. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Many ¶
func Many[T any]( cap int, c common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, []T]
Many - 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, errMessage string, c common.Combinator[rune, Position, T], end common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []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]( errMessage string, cases map[K]V, c common.Combinator[rune, Position, K], ) common.Combinator[rune, Position, V]
Map - Reads one element from the input buffer using the combinator, then uses the resulting element to obtain a value from the map cases and try to match it in cases map passed by first argument. If the value is not found then it returns ParseError error.
func MapStrings ¶
func MapStrings[V any]( errMessage string, cases map[string]V, ) common.Combinator[rune, Position, V]
MapStrings - Reads text from the input buffer using the combinator and match it in on the fly by cases map passed by first argument. If the value is not found then it returns ParseError error. This combinator use special trie-like structure for text matching.
func Mark ¶
Lower - parse mark UTF-8 characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func NoneOf ¶
NoneOf - succeeds for any item 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 item 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 item which not included in input range. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func Number ¶
Number - parse UTF-8 number characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func OneOf ¶
OneOf - succeeds for any item 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 common.Combinator[rune, Position, T], def T, ) common.Combinator[rune, Position, T]
Optional - use c combinator to consume input data from buffer. If it failed, than return def value.
func Or ¶
func Or[T any]( errMessage string, x common.Combinator[rune, Position, T], y common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, 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 common.Combinator[rune, Position, S], body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Padded - skip sequence of items parsed by first combinator before and after body combinator.
func Parens ¶
func Parens[T any]( body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Parens - parse something between parens characters - '(' and ')'.
func Parse ¶
func Parse[T any]( data []rune, parse common.Combinator[rune, Position, T], ) (T, common.Error[Position])
Parse - parse text by c combinator.
func ParseString ¶
func ParseString[T any]( str string, parse common.Combinator[rune, Position, T], ) (T, common.Error[Position])
ParseString - parse text by c combinator.
func Print ¶
Print - parse printable UTF-8 characters. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Punct ¶
Punct - parse UTF-8 punctuation character. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Range ¶
Range - succeeds for any item which include in input range. Returns the item that is actually readed from input buffer. Greedy by default - keep position after reading.
func RangeTable ¶
func RangeTable( errMessage string, tbl *unicode.RangeTable, ) common.Combinator[rune, Position, rune]
RangeTable - parse UTF-8 character in upper case. Read more about utf characters tables - https://pkg.go.dev/unicode
func Satisfy ¶
func Satisfy( errMessage string, greedy bool, f common.Condition[rune], ) common.Combinator[rune, Position, rune]
Satisfy - succeeds for any item for which the supplied function f returns true. Returns the item 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 common.Combinator[rune, Position, T], sep common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []T]
SepBy - read zero or more occurrences of data 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, errMessage string, body common.Combinator[rune, Position, T], sep common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []T]
SepBy1 - read one or more occurrences of data 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 common.Combinator[rune, Position, T], sep common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []T]
SepEndBy - read zero or more occurrences of data 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, errMessage string, body common.Combinator[rune, Position, T], sep common.Combinator[rune, Position, S], ) common.Combinator[rune, Position, []T]
SepEndBy1 - read one or more occurrences of data 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 ...common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, []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 elements in the buffer equal to the input data sequence. If expectations are not met, returns ParseError error.
func Skip ¶
func Skip[T any, S any]( skip common.Combinator[rune, Position, S], body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, 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 common.Combinator[rune, Position, S], body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
SkipAfter - ignores the result of the first combinator and returns only the result of the second. Use body combinator at first.
func SkipMany ¶
func SkipMany[T any, S any]( skip common.Combinator[rune, Position, S], body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
SkipMany - skip sequence of items parsed by first combinator before body combinator.
func Some ¶
func Some[T any]( cap int, errMessage string, c common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, []T]
Some - 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.
func Space ¶
Space - parse UTF-8 space character. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Squares ¶
func Squares[T any]( body common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Squares - parse something between squares characters - '[' and ']'.
func String ¶
String - read input text and match with string passed by first argument. If the text not matched then it returns ParseError error.
func Symbol ¶
Space - parse UTF-8 symbolic character. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func TimeZoneByNames ¶
func TimeZoneByNames( locationNames ...string, ) (common.Combinator[rune, Position, *time.Location], error)
TimeZoneByNames - parse one of time zones from passed arguments.
func Title ¶
Title - parse UTF-8 character in title case. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants
func Trace ¶
func Trace[T any]( l common.Logged, m string, c common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Trace - writes messages to the log about the state of the buffer before and after using the combinator, the result of the cobinator and its error.
func Try ¶
func Try[T any]( c common.Combinator[rune, Position, T], ) common.Combinator[rune, Position, T]
Try - try to use c combinator, if it falls, it returns buffer to the previous position.
func Unsigned ¶
func Unsigned[T constraints.Integer]() common.Combinator[rune, Position, T]
Unsigned - parse unsigned integer.
func UnsignedN ¶
func UnsignedN[T constraints.Integer](n int, errMessage string) common.Combinator[rune, Position, T]
UnsignedN - parse unsigned integer with N count of digits.
func Upper ¶
Lower - parse UTF-8 character in upper case. Read more about utf characters tables - https://pkg.go.dev/unicode#pkg-constants