Copyright | (c) comp 2020 |
---|---|
License | MIT |
Maintainer | onecomputer00@gmail.com |
Stability | stable |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Hectoparsec.Error
Contents
Description
Data types for errors reported during parsing.
Hectoparsec itself does not come with error pretty printing, but errors can be formatted while prototyping with the functions from Hectoparsec.Debug. External libraries or your own error pretty printer can be used instead.
Synopsis
- data Unexpected s
- = UnexpectedToken (Token s)
- | UnexpectedChunk (Chunk s)
- | UnexpectedEnd
- | UnexpectedEmpty
- data Message e
- data ErrorItem s e l
- = ErrorItemLabels (Unexpected s) [l]
- | ErrorItemMessages [Message e]
- data ParseError s e l = ParseError {
- parseErrorPos :: !Pos
- parseErrorOffset :: !Int
- parseErrorItem :: ErrorItem s e l
Parse error data
data Unexpected s Source #
An unexpected item from the input stream.
Constructors
UnexpectedToken (Token s) | An unexpected token. |
UnexpectedChunk (Chunk s) | An unexpected chunk. |
UnexpectedEnd | An unexpected end of input. |
UnexpectedEmpty | An unexpected empty parser. |
Instances
Monoid (Unexpected s) Source # | |
Defined in Hectoparsec.Error Methods mempty :: Unexpected s Source # mappend :: Unexpected s -> Unexpected s -> Unexpected s Source # mconcat :: [Unexpected s] -> Unexpected s Source # | |
Semigroup (Unexpected s) Source # | Chooses between two unexpected items. |
Defined in Hectoparsec.Error Methods (<>) :: Unexpected s -> Unexpected s -> Unexpected s Source # sconcat :: NonEmpty (Unexpected s) -> Unexpected s Source # stimes :: Integral b => b -> Unexpected s -> Unexpected s Source # | |
(Show (Token s), Show (Chunk s)) => Show (Unexpected s) Source # | |
Defined in Hectoparsec.Error | |
(Eq (Token s), Eq (Chunk s)) => Eq (Unexpected s) Source # | |
Defined in Hectoparsec.Error Methods (==) :: Unexpected s -> Unexpected s -> Bool Source # (/=) :: Unexpected s -> Unexpected s -> Bool Source # |
An error message from the input stream.
Constructors
MessageCustom e | A custom error message. |
MessageFail String | A string error message. |
A possible error during parsing for a stream s
, with error type e
and label type l
.
Constructors
ErrorItemLabels (Unexpected s) [l] | An error generated through matching tokens. There is an unexpected item and a list of labels from parsers that make up the expected items. There may be duplicates in the list of expected labels, so it is up to you to deduplicate it if needed. |
ErrorItemMessages [Message e] | An error generated by |
Instances
Semigroup (ErrorItem s e l) Source # | Merges two error items. We prefer |
(Show (Token s), Show (Chunk s), Show e, Show l) => Show (ErrorItem s e l) Source # | |
(Eq (Token s), Eq (Chunk s), Eq e, Eq l) => Eq (ErrorItem s e l) Source # | |
data ParseError s e l Source #
A container for an error during parsing for a stream s
, with error type e
and label type l
.
Constructors
ParseError | |
Fields
|
Instances
Semigroup (ParseError s e l) Source # | Merges two errors together. Errors that occur later in the stream are preferred. When they occur at the same place, the error items are merged, with preference for the second parse error. |
Defined in Hectoparsec.Error Methods (<>) :: ParseError s e l -> ParseError s e l -> ParseError s e l Source # sconcat :: NonEmpty (ParseError s e l) -> ParseError s e l Source # stimes :: Integral b => b -> ParseError s e l -> ParseError s e l Source # | |
(Show (Token s), Show (Chunk s), Show e, Show l) => Show (ParseError s e l) Source # | |
Defined in Hectoparsec.Error | |
(Eq (Token s), Eq (Chunk s), Eq e, Eq l) => Eq (ParseError s e l) Source # | |
Defined in Hectoparsec.Error Methods (==) :: ParseError s e l -> ParseError s e l -> Bool Source # (/=) :: ParseError s e l -> ParseError s e l -> Bool Source # |