Safe Haskell | None |
---|
An Error handling scheme that can be used with Boomerang
- data ErrorMsg
- messageString :: ErrorMsg -> String
- data ParserError pos = ParserError (Maybe pos) [ErrorMsg]
- mkParserError :: pos -> [ErrorMsg] -> [Either (ParserError pos) a]
- (<?>) :: Boomerang (ParserError p) tok a b -> String -> Boomerang (ParserError p) tok a b
- condenseErrors :: Ord pos => [ParserError pos] -> ParserError pos
- showErrorMessages :: String -> String -> String -> String -> String -> [ErrorMsg] -> String
- showParserError :: (pos -> String) -> ParserError pos -> String
Documentation
data ParserError pos Source
ParserError (Maybe pos) [ErrorMsg] |
Typeable1 ParserError | |
InitialPosition StringError | |
InitialPosition StringsError | |
InitialPosition TextsError | |
Eq pos => Eq (ParserError pos) | |
Data pos => Data (ParserError pos) | |
Ord pos => Ord (ParserError pos) | |
Show pos => Show (ParserError pos) | |
Error (ParserError p) | |
ErrorPosition (ParserError p) | |
~ * a b => IsString (Boomerang StringError String a b) | |
~ * a b => IsString (Boomerang StringsError [String] a b) | |
~ * a b => IsString (Boomerang TextsError [Text] a b) |
mkParserError :: pos -> [ErrorMsg] -> [Either (ParserError pos) a]Source
lift a pos
and '[ErrorMsg]' into a parse error
This is intended to be used inside a Parser
like this:
Parser $ \tok pos -> mkParserError pos [Message "just some error..."]
(<?>) :: Boomerang (ParserError p) tok a b -> String -> Boomerang (ParserError p) tok a bSource
annotate a parse error with an additional Expect
message
satisfy isUpper <?> 'an uppercase character'
condenseErrors :: Ord pos => [ParserError pos] -> ParserError posSource
condense the ParserError
s with the highest parse position into a single ParserError
showErrorMessages :: String -> String -> String -> String -> String -> [ErrorMsg] -> StringSource
Helper function for turning '[ErrorMsg]' into a user-friendly String
:: (pos -> String) | function to turn the error position into a |
-> ParserError pos | the |
-> String |
turn a parse error into a user-friendly error message