Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Text.Boomerang.Error
Description
An Error handling scheme that can be used with Boomerang
Synopsis
- data ErrorMsg
- = SysUnExpect String
- | EOI String
- | UnExpect String
- | Expect String
- | Message String
- 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
Constructors
SysUnExpect String | |
EOI String | |
UnExpect String | |
Expect String | |
Message String |
Instances
Data ErrorMsg Source # | |
Defined in Text.Boomerang.Error Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ErrorMsg -> c ErrorMsg gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c ErrorMsg toConstr :: ErrorMsg -> Constr dataTypeOf :: ErrorMsg -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c ErrorMsg) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c ErrorMsg) gmapT :: (forall b. Data b => b -> b) -> ErrorMsg -> ErrorMsg gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ErrorMsg -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ErrorMsg -> r gmapQ :: (forall d. Data d => d -> u) -> ErrorMsg -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> ErrorMsg -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> ErrorMsg -> m ErrorMsg gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ErrorMsg -> m ErrorMsg gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ErrorMsg -> m ErrorMsg | |
Read ErrorMsg Source # | |
Defined in Text.Boomerang.Error | |
Show ErrorMsg Source # | |
Eq ErrorMsg Source # | |
Ord ErrorMsg Source # | |
Defined in Text.Boomerang.Error |
messageString :: ErrorMsg -> String Source #
extract the String
from an ErrorMsg
.
Note: the resulting String
will not include any information about what constructor it came from.
data ParserError pos Source #
Constructors
ParserError (Maybe pos) [ErrorMsg] |
Instances
InitialPosition StringError Source # | |
Defined in Text.Boomerang.String Methods initialPos :: Maybe StringError -> Pos StringError Source # | |
InitialPosition StringsError Source # | |
Defined in Text.Boomerang.Strings Methods initialPos :: Maybe StringsError -> Pos StringsError Source # | |
InitialPosition TextsError Source # | |
Defined in Text.Boomerang.Texts Methods initialPos :: Maybe TextsError -> Pos TextsError Source # | |
Data pos => Data (ParserError pos) Source # | |
Defined in Text.Boomerang.Error Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> ParserError pos -> c (ParserError pos) gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c (ParserError pos) toConstr :: ParserError pos -> Constr dataTypeOf :: ParserError pos -> DataType dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c (ParserError pos)) dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c (ParserError pos)) gmapT :: (forall b. Data b => b -> b) -> ParserError pos -> ParserError pos gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> ParserError pos -> r gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> ParserError pos -> r gmapQ :: (forall d. Data d => d -> u) -> ParserError pos -> [u] gmapQi :: Int -> (forall d. Data d => d -> u) -> ParserError pos -> u gmapM :: Monad m => (forall d. Data d => d -> m d) -> ParserError pos -> m (ParserError pos) gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> ParserError pos -> m (ParserError pos) gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> ParserError pos -> m (ParserError pos) | |
Show pos => Show (ParserError pos) Source # | |
Defined in Text.Boomerang.Error Methods showsPrec :: Int -> ParserError pos -> ShowS show :: ParserError pos -> String showList :: [ParserError pos] -> ShowS | |
ErrorPosition (ParserError p) Source # | |
Defined in Text.Boomerang.Error Methods getPosition :: ParserError p -> Maybe (Pos (ParserError p)) Source # | |
Eq pos => Eq (ParserError pos) Source # | |
Defined in Text.Boomerang.Error Methods (==) :: ParserError pos -> ParserError pos -> Bool (/=) :: ParserError pos -> ParserError pos -> Bool | |
Ord pos => Ord (ParserError pos) Source # | |
Defined in Text.Boomerang.Error Methods compare :: ParserError pos -> ParserError pos -> Ordering (<) :: ParserError pos -> ParserError pos -> Bool (<=) :: ParserError pos -> ParserError pos -> Bool (>) :: ParserError pos -> ParserError pos -> Bool (>=) :: ParserError pos -> ParserError pos -> Bool max :: ParserError pos -> ParserError pos -> ParserError pos min :: ParserError pos -> ParserError pos -> ParserError pos | |
a ~ b => IsString (Boomerang StringError String a b) | |
Defined in Text.Boomerang.String Methods fromString :: String -> Boomerang StringError String a b | |
a ~ b => IsString (Boomerang StringsError [String] a b) | |
Defined in Text.Boomerang.Strings Methods fromString :: String -> Boomerang StringsError [String] a b | |
a ~ b => IsString (Boomerang TextsError [Text] a b) | |
Defined in Text.Boomerang.Texts Methods fromString :: String -> Boomerang TextsError [Text] a b | |
type Pos (ParserError p) Source # | |
Defined in Text.Boomerang.Error |
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 b infix 0 Source #
annotate a parse error with an additional Expect
message
satisfy isUpper <?> 'an uppercase character'
condenseErrors :: Ord pos => [ParserError pos] -> ParserError pos Source #
condense the ParserError
s with the highest parse position into a single ParserError
showErrorMessages :: String -> String -> String -> String -> String -> [ErrorMsg] -> String Source #
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