| Safe Haskell | None |
|---|
Text.Boomerang.Error
Description
An Error handling scheme that can be used with PrinterParser
- data ErrorMsg
- messageString :: ErrorMsg -> String
- data ParserError pos = ParserError (Maybe pos) [ErrorMsg]
- mkParserError :: pos -> [ErrorMsg] -> [Either (ParserError pos) a]
- (<?>) :: PrinterParser (ParserError p) tok a b -> String -> PrinterParser (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
Constructors
| ParserError (Maybe pos) [ErrorMsg] |
Instances
| Typeable1 ParserError | |
| InitialPosition StringError | |
| InitialPosition StringsError | |
| 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 (PrinterParser StringError String a b) | |
| ~ * a b => IsString (PrinterParser StringsError [String] 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..."]
(<?>) :: PrinterParser (ParserError p) tok a b -> String -> PrinterParser (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 ParserErrors 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
Arguments
| :: (pos -> String) | function to turn the error position into a |
| -> ParserError pos | the |
| -> String |
turn a parse error into a user-friendly error message