Documentation ¶
Index ¶
- Variables
- func FormatRange[T stream.Token](r []T) string
- func FormatToken[T stream.Token](t T) string
- type EOI
- type ErrorInfo
- type Func
- func (f Func[T, O]) AndThen(fn func(O) (O, error)) Func[T, O]
- func (f Func[T, O]) Expected(msg string) Func[T, O]
- func (f Func[T, O]) Map(fn func(O) O) Func[T, O]
- func (f Func[T, O]) MapErr(fn func(error) error) Func[T, O]
- func (f Func[T, O]) Message(msg string) Func[T, O]
- func (f Func[T, O]) Parse(input []T) (out O, remaining []T, err error)
- func (f Func[T, O]) Spanned() Func[T, O]
- type MessageInfo
- type Parser
- type RangeInfo
- type Spanned
- type TokenInfo
- type UnexpectedErr
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExpected indicates an expected value. ErrExpected = errors.New("expected") // ErrUnexpected indicates a unexpected value. ErrUnexpected = errors.New("unexpected") )
Functions ¶
func FormatRange ¶
func FormatToken ¶
Types ¶
type Func ¶
Func is a function that it can be used to parse an input stream `S` of token `T` into a `O` value.
func Expected ¶
Expected parses with `parser` and if it fails without consuming any input any expected errors are replaced by `msg`. `msg` is then used in error messages as "Expected `msg`".
func (Func[T, O]) AndThen ¶
AndThen parses with `f` and applies `fn` on the result if `parser` parses successfully. `fn` may optionally fail with an error.
func (Func[T, O]) Expected ¶
Expected parses with `f` and if it fails without consuming any input any expected errors are replaced by `msg`. `msg` is then used in error messages as "Expected `msg`".
type MessageInfo ¶
type MessageInfo string
func (MessageInfo) ErrorInfo ¶
func (i MessageInfo) ErrorInfo() string
type Parser ¶
Parser is a type that it can be used to parse an input stream `S` of token `T` into a `O` value.
type UnexpectedErr ¶
type UnexpectedErr[E ErrorInfo] struct { Info E }
UnexpectedErr is an error that indicates an unexpected value.
func UnexpectedEOI ¶
func UnexpectedEOI() *UnexpectedErr[EOI]
Unexpected returns an error that indicates an unexpected EOI.
func UnexpectedMessage ¶
func UnexpectedMessage(msg string) *UnexpectedErr[MessageInfo]
Unexpected returns an error that indicates an unexpected message.
func UnexpectedRange ¶
func UnexpectedRange[T stream.Token](expected, actual []T) *UnexpectedErr[*RangeInfo[T]]
Unexpected returns an error that indicates an unexpected range.
func UnexpectedToken ¶
func UnexpectedToken[T stream.Token](actual T, x ...T) *UnexpectedErr[*TokenInfo[T]]
Unexpected returns an error that indicates an unexpected value.
func (*UnexpectedErr[E]) Err ¶
func (e *UnexpectedErr[E]) Err() error
func (*UnexpectedErr[E]) Error ¶
func (e *UnexpectedErr[E]) Error() string