hectoparsec-0.1.0.0: Flexible and powerful parser combinators
Copyright(c) comp 2020
LicenseMIT
Maintaineronecomputer00@gmail.com
Stabilitystable
Portabilityportable
Safe HaskellSafe-Inferred
LanguageHaskell2010

Hectoparsec.Error

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

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

Instances details
Monoid (Unexpected s) Source # 
Instance details

Defined in Hectoparsec.Error

Semigroup (Unexpected s) Source #

Chooses between two unexpected items. UnexpectedEmpty items are discarded in favor of more descriptive items. When choosing between other items, the second item is chosen.

Instance details

Defined in Hectoparsec.Error

(Show (Token s), Show (Chunk s)) => Show (Unexpected s) Source # 
Instance details

Defined in Hectoparsec.Error

(Eq (Token s), Eq (Chunk s)) => Eq (Unexpected s) Source # 
Instance details

Defined in Hectoparsec.Error

data Message e Source #

An error message from the input stream.

Constructors

MessageCustom e

A custom error message.

MessageFail String

A string error message.

Instances

Instances details
Show e => Show (Message e) Source # 
Instance details

Defined in Hectoparsec.Error

Eq e => Eq (Message e) Source # 
Instance details

Defined in Hectoparsec.Error

Methods

(==) :: Message e -> Message e -> Bool Source #

(/=) :: Message e -> Message e -> Bool Source #

data ErrorItem s e l Source #

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 fail and failure, and by custom errors, which can generally happen anywhere. These errors are preferred over the errors generated by matching tokens.

Instances

Instances details
Semigroup (ErrorItem s e l) Source #

Merges two error items. We prefer ErrorItemMessages over ErrorItemLabels. When two error items of the same variant are given, the two error items are merged together.

Instance details

Defined in Hectoparsec.Error

Methods

(<>) :: ErrorItem s e l -> ErrorItem s e l -> ErrorItem s e l Source #

sconcat :: NonEmpty (ErrorItem s e l) -> ErrorItem s e l Source #

stimes :: Integral b => b -> ErrorItem s e l -> ErrorItem s e l Source #

(Show (Token s), Show (Chunk s), Show e, Show l) => Show (ErrorItem s e l) Source # 
Instance details

Defined in Hectoparsec.Error

Methods

showsPrec :: Int -> ErrorItem s e l -> ShowS Source #

show :: ErrorItem s e l -> String Source #

showList :: [ErrorItem s e l] -> ShowS Source #

(Eq (Token s), Eq (Chunk s), Eq e, Eq l) => Eq (ErrorItem s e l) Source # 
Instance details

Defined in Hectoparsec.Error

Methods

(==) :: ErrorItem s e l -> ErrorItem s e l -> Bool Source #

(/=) :: ErrorItem s e l -> ErrorItem s e l -> Bool 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

Instances details
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.

Instance details

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 # 
Instance details

Defined in Hectoparsec.Error

Methods

showsPrec :: Int -> ParseError s e l -> ShowS Source #

show :: ParseError s e l -> String Source #

showList :: [ParseError s e l] -> ShowS Source #

(Eq (Token s), Eq (Chunk s), Eq e, Eq l) => Eq (ParseError s e l) Source # 
Instance details

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 #