Documentation ¶
Overview ¶
package parser provides abstract interfaces.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorIs ¶
func ErrorIs[T ParseError](err error, ty T) bool
ErrorIs checks the given error implements ParseError interface.
Types ¶
type IOReadSeeker ¶ added in v0.3.0
type IOReadSeeker struct {
// contains filtered or unexported fields
}
IOReadSeeker is the stream input. We should require io.Seeker because some parsers try to recover from failures.
func NewIOReadSeeker ¶ added in v0.3.0
func NewIOReadSeeker(r io.ReadSeeker) *IOReadSeeker
NewIOReadSeeker initializes an IOReadSeeker.
type NoLeftInputToParseError ¶
type NoLeftInputToParseError struct{}
NoLeftInputToParseError notifies the given input to parser is empty.
func (*NoLeftInputToParseError) Error ¶
func (e *NoLeftInputToParseError) Error() string
Error implements error interface.
type ParseError ¶
type ParseError interface { error }
ParseError represents the error of parsers in all parsers.
type ParseInput ¶
type ParseInput[E comparable] interface { // Read reads len(slice) and returns the length that the parser could read. Read([]E) (int, error) // Seek conditions the offset of the input. Seek(int, SeekMode) (int, error) }
ParseInput is the input of Parser interface.
type ParseOutput ¶
type ParseOutput interface{}
ParseOutput is the actual type of the parser's output. Note that this interface may be constrainted more in future.
type Parser ¶
type Parser[E comparable, O ParseOutput] func(input ParseInput[E]) (ParseInput[E], O, ParseError)
Parser is an abstract parser.
Click to show internal directories.
Click to hide internal directories.