boomerang-1.4.0: Library for invertible parsing and printing

Safe HaskellNone



An Error handling scheme that can be used with Boomerang



messageString :: ErrorMsg -> StringSource

extract the String from an ErrorMsg. Note: the resulting String will not include any information about what constructor it came from.

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 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



:: (pos -> String)

function to turn the error position into a String

-> ParserError pos

the ParserError

-> String 

turn a parse error into a user-friendly error message