Documentation ¶
Index ¶
- type Parser
- func AnyRune() Parser[rune]
- func AtLeastOnce[T any](parser Parser[T]) Parser[[]T]
- func Concat[T any](first, second Parser[[]T]) Parser[[]T]
- func Digit() Parser[rune]
- func End[T any](parser Parser[T]) Parser[T]
- func Except[T, U any](parser Parser[T], except Parser[U]) Parser[T]
- func IgnoreCase(c rune) Parser[rune]
- func IgnoreCaseString(s string) Parser[[]rune]
- func Letter() Parser[rune]
- func LetterOrDigit() Parser[rune]
- func Lower() Parser[rune]
- func Many[T any](parser Parser[T]) Parser[[]T]
- func Not[T any](parser Parser[T]) Parser[T]
- func Number() Parser[string]
- func Numeric() Parser[rune]
- func Once[T any](parser Parser[T]) Parser[[]T]
- func Or[T any](first Parser[T], second Parser[T]) Parser[T]
- func Return[T any](value T) Parser[T]
- func ReturnValue[T, U any](parser Parser[T], value U) Parser[U]
- func Rune(c rune) Parser[rune]
- func RuneExcept(c rune) Parser[rune]
- func RuneExceptFunc(predicate func(rune) bool, description string) Parser[rune]
- func RuneFunc(predicate func(rune) bool, description string) Parser[rune]
- func Runes(rs ...rune) Parser[rune]
- func RunesExcept(rs ...rune) Parser[rune]
- func RunesString(s string) Parser[rune]
- func RunesStringExcept(s string) Parser[rune]
- func Select[T any, U any](parser Parser[T], convert func(T) U) Parser[U]
- func SelectMany[T, U, V any](parser Parser[T], selector func(T) Parser[U], projector func(T, U) V) Parser[V]
- func SetExpectationIfError[T any](parser Parser[T], expectation string) Parser[T]
- func String(s string) Parser[[]rune]
- func Text(parser Parser[[]rune]) Parser[string]
- func Then[T, U any](first Parser[T], second func(T) Parser[U]) Parser[U]
- func Token[T any](parser Parser[T]) Parser[T]
- func Until[T, U any](parser Parser[T], until Parser[U]) Parser[[]T]
- func Upper() Parser[rune]
- func Where[T any](parser Parser[T], predicate func(T) bool) Parser[T]
- func WhiteSpace() Parser[rune]
- func XAtLeastOnce[T any](parser Parser[T]) Parser[[]T]
- func XMany[T any](parser Parser[T]) Parser[[]T]
- func XOr[T any](first Parser[T], second Parser[T]) Parser[T]
- type ParserInput
- func (p ParserInput) Advance() ParserInput
- func (p ParserInput) Column() int
- func (p ParserInput) Current() rune
- func (p ParserInput) Equal(other ParserInput) bool
- func (p ParserInput) IsEnd() bool
- func (p ParserInput) Line() int
- func (p ParserInput) Position() int
- func (p ParserInput) Source() string
- func (p ParserInput) String() string
- type ParserResult
- func IfFailure[T any](result ParserResult[T], next func(ParserResult[T]) ParserResult[T]) ParserResult[T]
- func IfSuccess[T any, U any](result ParserResult[T], next func(ParserResult[T]) ParserResult[U]) ParserResult[U]
- func NewFailureResult[T any](remainder ParserInput, message string, expectations []string) ParserResult[T]
- func NewSuccessResult[T any](value T, remainder ParserInput) ParserResult[T]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Parser ¶
type Parser[T any] func(ParserInput) ParserResult[T]
func AtLeastOnce ¶
TryParse a stream of elements with at least one item.
func IgnoreCase ¶
Parse a single character in a case-insensitive fashion.
func IgnoreCaseString ¶
Parse a string in a case-insensitive fashion.
func Not ¶
Constructs a parser that will fail if the given parser succeeds, and will succeed if the given parser fails. In any case, it won't consume any input. It's like a negative look-ahead in regex.
func ReturnValue ¶
Version of Return with simpler inline syntax.
func RuneExceptFunc ¶
Parse a single character except those matching 'predicate'
func RunesExcept ¶
Parses a single character except for those in rs
func RunesStringExcept ¶
Parses a single character except for those in s
func SelectMany ¶
func SelectMany[T, U, V any](parser Parser[T], selector func(T) Parser[U], projector func(T, U) V) Parser[V]
Monadic combinator Then, adapted for Linq comprehension syntax.
func SetExpectationIfError ¶
Names part of the grammar for help with error messages.
func Until ¶
Parse a sequence of items until a terminator is reached. Returns the sequence, discarding the terminator.
func XAtLeastOnce ¶
TryParse a stream of elements with at least one item. Except the first
type ParserInput ¶
type ParserInput struct {
// contains filtered or unexported fields
}
func NewParserInput ¶
func NewParserInput(source string) ParserInput
func (ParserInput) Advance ¶
func (p ParserInput) Advance() ParserInput
func (ParserInput) Column ¶
func (p ParserInput) Column() int
func (ParserInput) Current ¶
func (p ParserInput) Current() rune
func (ParserInput) Equal ¶
func (p ParserInput) Equal(other ParserInput) bool
func (ParserInput) IsEnd ¶
func (p ParserInput) IsEnd() bool
func (ParserInput) Line ¶
func (p ParserInput) Line() int
func (ParserInput) Position ¶
func (p ParserInput) Position() int
func (ParserInput) Source ¶
func (p ParserInput) Source() string
func (ParserInput) String ¶
func (p ParserInput) String() string
type ParserResult ¶
type ParserResult[T any] struct { Value T Remainder ParserInput Succeeded bool Message string Expectations []string }
func IfFailure ¶
func IfFailure[T any](result ParserResult[T], next func(ParserResult[T]) ParserResult[T]) ParserResult[T]
func IfSuccess ¶
func IfSuccess[T any, U any](result ParserResult[T], next func(ParserResult[T]) ParserResult[U]) ParserResult[U]
func NewFailureResult ¶
func NewFailureResult[T any](remainder ParserInput, message string, expectations []string) ParserResult[T]
func NewSuccessResult ¶
func NewSuccessResult[T any](value T, remainder ParserInput) ParserResult[T]