Documentation ¶
Index ¶
- Variables
- func Parse[T any](parser Parser[T], input []token.Token) (T, error)
- type Empty
- type Parser
- func All2[A any, B any](first Parser[A], second Parser[B]) Parser[Seq2[A, B]]
- func All3[A any, B any, C any](first Parser[A], second Parser[B], third Parser[C]) Parser[Seq3[A, B, C]]
- func ConsumeAtLeastOne[T any](parser Parser[T]) Parser[[]T]
- func Exactly(tok token.Token) Parser[Empty]
- func ManyOf[T any](parser Parser[T]) Parser[[]T]
- func Map[T any, U any](parser Parser[T], mapper func(T) U) Parser[U]
- func MatchesToken(matcher func(token.Token) bool) Parser[token.Token]
- func Nothing() Parser[Empty]
- func OneOf[T any](parsers ...Parser[T]) Parser[T]
- type Seq2
- type Seq3
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNoMatch indicates parsing failed against the token stream. ErrNoMatch = errors.New("no match") // ErrNonExhaustiveParse indicates parsing completed but there were // still tokens remaining in the input stream. ErrNonExhaustiveParse = errors.New("did not consume all tokens") )
Functions ¶
Types ¶
type Empty ¶
type Empty struct{}
Empty is an empty type to return when a parser successfully parsed the input stream and nothing should be returned.
type Parser ¶
Parser is a Parser function that can read an input token stream and produce the specified type or an error.
func All3 ¶
func All3[A any, B any, C any](first Parser[A], second Parser[B], third Parser[C]) Parser[Seq3[A, B, C]]
All3 requires all three parsers to succeed and it returns a tuple of the parsed objects.
func ConsumeAtLeastOne ¶
ConsumeAtLeastOne attempts to parse at least once with the given parser and then continues until it fails to parse.
func MatchesToken ¶
MatchesToken consumes the token from the input stream if matcher returns true.
Click to show internal directories.
Click to hide internal directories.