-- SPDX-FileCopyrightText: 2020 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

-- |  Custom exceptions that can happen during parsing.

module Michelson.Parser.Error
  ( CustomParserException (..)
  , StringLiteralParserException (..)
  , ParseErrorBundle
  , ParserException (..)
  ) where

import Data.Data (Data(..))
import Fmt (Buildable(build), (+|), (|+))
import Text.Megaparsec (ParseErrorBundle, ShowErrorComponent(..), errorBundlePretty)
import qualified Text.Show (show)

import Util.Instances ()
import Util.Named ()
import Util.Positive

data CustomParserException
  = UnknownTypeException
  | StringLiteralException StringLiteralParserException
  | OddNumberBytesException
  | WrongTagArgs Natural Positive
  | WrongAccessArgs Natural Positive
  | WrongSetArgs Natural Positive
  | ExcessFieldAnnotation
  | MultiRootAnnotationException
  deriving stock (CustomParserException -> CustomParserException -> Bool
(CustomParserException -> CustomParserException -> Bool)
-> (CustomParserException -> CustomParserException -> Bool)
-> Eq CustomParserException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomParserException -> CustomParserException -> Bool
$c/= :: CustomParserException -> CustomParserException -> Bool
== :: CustomParserException -> CustomParserException -> Bool
$c== :: CustomParserException -> CustomParserException -> Bool
Eq, Typeable CustomParserException
DataType
Constr
Typeable CustomParserException =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> CustomParserException
 -> c CustomParserException)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c CustomParserException)
-> (CustomParserException -> Constr)
-> (CustomParserException -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c CustomParserException))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c CustomParserException))
-> ((forall b. Data b => b -> b)
    -> CustomParserException -> CustomParserException)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> CustomParserException
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> CustomParserException
    -> r)
-> (forall u.
    (forall d. Data d => d -> u) -> CustomParserException -> [u])
-> (forall u.
    Int -> (forall d. Data d => d -> u) -> CustomParserException -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> CustomParserException -> m CustomParserException)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CustomParserException -> m CustomParserException)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> CustomParserException -> m CustomParserException)
-> Data CustomParserException
CustomParserException -> DataType
CustomParserException -> Constr
(forall b. Data b => b -> b)
-> CustomParserException -> CustomParserException
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CustomParserException
-> c CustomParserException
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CustomParserException
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int -> (forall d. Data d => d -> u) -> CustomParserException -> u
forall u.
(forall d. Data d => d -> u) -> CustomParserException -> [u]
forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CustomParserException -> r
forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CustomParserException -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CustomParserException
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CustomParserException
-> c CustomParserException
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CustomParserException)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CustomParserException)
$cMultiRootAnnotationException :: Constr
$cExcessFieldAnnotation :: Constr
$cWrongSetArgs :: Constr
$cWrongAccessArgs :: Constr
$cWrongTagArgs :: Constr
$cOddNumberBytesException :: Constr
$cStringLiteralException :: Constr
$cUnknownTypeException :: Constr
$tCustomParserException :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
gmapMp :: (forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
gmapM :: (forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> CustomParserException -> m CustomParserException
gmapQi :: Int -> (forall d. Data d => d -> u) -> CustomParserException -> u
$cgmapQi :: forall u.
Int -> (forall d. Data d => d -> u) -> CustomParserException -> u
gmapQ :: (forall d. Data d => d -> u) -> CustomParserException -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> CustomParserException -> [u]
gmapQr :: (r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CustomParserException -> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r -> (forall d. Data d => d -> r') -> CustomParserException -> r
gmapQl :: (r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CustomParserException -> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r -> (forall d. Data d => d -> r') -> CustomParserException -> r
gmapT :: (forall b. Data b => b -> b)
-> CustomParserException -> CustomParserException
$cgmapT :: (forall b. Data b => b -> b)
-> CustomParserException -> CustomParserException
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CustomParserException)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c CustomParserException)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c CustomParserException)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c CustomParserException)
dataTypeOf :: CustomParserException -> DataType
$cdataTypeOf :: CustomParserException -> DataType
toConstr :: CustomParserException -> Constr
$ctoConstr :: CustomParserException -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CustomParserException
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c CustomParserException
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CustomParserException
-> c CustomParserException
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> CustomParserException
-> c CustomParserException
$cp1Data :: Typeable CustomParserException
Data, Eq CustomParserException
Eq CustomParserException =>
(CustomParserException -> CustomParserException -> Ordering)
-> (CustomParserException -> CustomParserException -> Bool)
-> (CustomParserException -> CustomParserException -> Bool)
-> (CustomParserException -> CustomParserException -> Bool)
-> (CustomParserException -> CustomParserException -> Bool)
-> (CustomParserException
    -> CustomParserException -> CustomParserException)
-> (CustomParserException
    -> CustomParserException -> CustomParserException)
-> Ord CustomParserException
CustomParserException -> CustomParserException -> Bool
CustomParserException -> CustomParserException -> Ordering
CustomParserException
-> CustomParserException -> CustomParserException
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: CustomParserException
-> CustomParserException -> CustomParserException
$cmin :: CustomParserException
-> CustomParserException -> CustomParserException
max :: CustomParserException
-> CustomParserException -> CustomParserException
$cmax :: CustomParserException
-> CustomParserException -> CustomParserException
>= :: CustomParserException -> CustomParserException -> Bool
$c>= :: CustomParserException -> CustomParserException -> Bool
> :: CustomParserException -> CustomParserException -> Bool
$c> :: CustomParserException -> CustomParserException -> Bool
<= :: CustomParserException -> CustomParserException -> Bool
$c<= :: CustomParserException -> CustomParserException -> Bool
< :: CustomParserException -> CustomParserException -> Bool
$c< :: CustomParserException -> CustomParserException -> Bool
compare :: CustomParserException -> CustomParserException -> Ordering
$ccompare :: CustomParserException -> CustomParserException -> Ordering
$cp1Ord :: Eq CustomParserException
Ord, Int -> CustomParserException -> ShowS
[CustomParserException] -> ShowS
CustomParserException -> String
(Int -> CustomParserException -> ShowS)
-> (CustomParserException -> String)
-> ([CustomParserException] -> ShowS)
-> Show CustomParserException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomParserException] -> ShowS
$cshowList :: [CustomParserException] -> ShowS
show :: CustomParserException -> String
$cshow :: CustomParserException -> String
showsPrec :: Int -> CustomParserException -> ShowS
$cshowsPrec :: Int -> CustomParserException -> ShowS
Show, (forall x. CustomParserException -> Rep CustomParserException x)
-> (forall x. Rep CustomParserException x -> CustomParserException)
-> Generic CustomParserException
forall x. Rep CustomParserException x -> CustomParserException
forall x. CustomParserException -> Rep CustomParserException x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomParserException x -> CustomParserException
$cfrom :: forall x. CustomParserException -> Rep CustomParserException x
Generic)

instance NFData CustomParserException

instance ShowErrorComponent CustomParserException where
  showErrorComponent :: CustomParserException -> String
showErrorComponent UnknownTypeException = "unknown type"
  showErrorComponent (StringLiteralException e :: StringLiteralParserException
e) = StringLiteralParserException -> String
forall a. ShowErrorComponent a => a -> String
showErrorComponent StringLiteralParserException
e
  showErrorComponent OddNumberBytesException = "odd number bytes"
  showErrorComponent ExcessFieldAnnotation = "excess field annotation"
  showErrorComponent MultiRootAnnotationException = "unexpected multiple root annotations"
  showErrorComponent (WrongTagArgs idx :: Natural
idx size :: Positive
size) =
    "TAG: too large index: " Builder -> Builder -> String
forall b. FromBuilder b => Builder -> Builder -> b
+| Natural
idx Natural -> Builder -> Builder
forall a b. (Buildable a, FromBuilder b) => a -> Builder -> b
|+ " \
           \exceedes union size " Builder -> Builder -> Builder
forall b. FromBuilder b => Builder -> Builder -> b
+| Positive
size Positive -> Builder -> Builder
forall a b. (Buildable a, FromBuilder b) => a -> Builder -> b
|+ ""
  showErrorComponent (WrongAccessArgs idx :: Natural
idx size :: Positive
size) =
    "ACCESS: too large index: " Builder -> Builder -> String
forall b. FromBuilder b => Builder -> Builder -> b
+| Natural
idx Natural -> Builder -> Builder
forall a b. (Buildable a, FromBuilder b) => a -> Builder -> b
|+ " \
           \exceedes tuple size " Builder -> Builder -> Builder
forall b. FromBuilder b => Builder -> Builder -> b
+| Positive
size Positive -> Builder -> Builder
forall a b. (Buildable a, FromBuilder b) => a -> Builder -> b
|+ ""
  showErrorComponent (WrongSetArgs idx :: Natural
idx size :: Positive
size) =
    "SET: too large index: " Builder -> Builder -> String
forall b. FromBuilder b => Builder -> Builder -> b
+| Natural
idx Natural -> Builder -> Builder
forall a b. (Buildable a, FromBuilder b) => a -> Builder -> b
|+ " \
           \exceedes tuple size " Builder -> Builder -> Builder
forall b. FromBuilder b => Builder -> Builder -> b
+| Positive
size Positive -> Builder -> Builder
forall a b. (Buildable a, FromBuilder b) => a -> Builder -> b
|+ ""

data StringLiteralParserException
  = InvalidEscapeSequence Char
  | InvalidChar Char
  deriving stock (StringLiteralParserException
-> StringLiteralParserException -> Bool
(StringLiteralParserException
 -> StringLiteralParserException -> Bool)
-> (StringLiteralParserException
    -> StringLiteralParserException -> Bool)
-> Eq StringLiteralParserException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringLiteralParserException
-> StringLiteralParserException -> Bool
$c/= :: StringLiteralParserException
-> StringLiteralParserException -> Bool
== :: StringLiteralParserException
-> StringLiteralParserException -> Bool
$c== :: StringLiteralParserException
-> StringLiteralParserException -> Bool
Eq, Typeable StringLiteralParserException
DataType
Constr
Typeable StringLiteralParserException =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g)
 -> StringLiteralParserException
 -> c StringLiteralParserException)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r)
    -> Constr
    -> c StringLiteralParserException)
-> (StringLiteralParserException -> Constr)
-> (StringLiteralParserException -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d))
    -> Maybe (c StringLiteralParserException))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e))
    -> Maybe (c StringLiteralParserException))
-> ((forall b. Data b => b -> b)
    -> StringLiteralParserException -> StringLiteralParserException)
-> (forall r r'.
    (r -> r' -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> StringLiteralParserException
    -> r)
-> (forall r r'.
    (r' -> r -> r)
    -> r
    -> (forall d. Data d => d -> r')
    -> StringLiteralParserException
    -> r)
-> (forall u.
    (forall d. Data d => d -> u)
    -> StringLiteralParserException -> [u])
-> (forall u.
    Int
    -> (forall d. Data d => d -> u)
    -> StringLiteralParserException
    -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d)
    -> StringLiteralParserException -> m StringLiteralParserException)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> StringLiteralParserException -> m StringLiteralParserException)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d)
    -> StringLiteralParserException -> m StringLiteralParserException)
-> Data StringLiteralParserException
StringLiteralParserException -> DataType
StringLiteralParserException -> Constr
(forall b. Data b => b -> b)
-> StringLiteralParserException -> StringLiteralParserException
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> StringLiteralParserException
-> c StringLiteralParserException
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StringLiteralParserException
forall a.
Typeable a =>
(forall (c :: * -> *).
 (forall d b. Data d => c (d -> b) -> d -> c b)
 -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u)
-> StringLiteralParserException
-> u
forall u.
(forall d. Data d => d -> u) -> StringLiteralParserException -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> StringLiteralParserException
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> StringLiteralParserException
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StringLiteralParserException
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> StringLiteralParserException
-> c StringLiteralParserException
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c StringLiteralParserException)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c StringLiteralParserException)
$cInvalidChar :: Constr
$cInvalidEscapeSequence :: Constr
$tStringLiteralParserException :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
gmapMp :: (forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
gmapM :: (forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> StringLiteralParserException -> m StringLiteralParserException
gmapQi :: Int
-> (forall d. Data d => d -> u)
-> StringLiteralParserException
-> u
$cgmapQi :: forall u.
Int
-> (forall d. Data d => d -> u)
-> StringLiteralParserException
-> u
gmapQ :: (forall d. Data d => d -> u) -> StringLiteralParserException -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u) -> StringLiteralParserException -> [u]
gmapQr :: (r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> StringLiteralParserException
-> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> StringLiteralParserException
-> r
gmapQl :: (r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> StringLiteralParserException
-> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> StringLiteralParserException
-> r
gmapT :: (forall b. Data b => b -> b)
-> StringLiteralParserException -> StringLiteralParserException
$cgmapT :: (forall b. Data b => b -> b)
-> StringLiteralParserException -> StringLiteralParserException
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c StringLiteralParserException)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c StringLiteralParserException)
dataCast1 :: (forall d. Data d => c (t d))
-> Maybe (c StringLiteralParserException)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c StringLiteralParserException)
dataTypeOf :: StringLiteralParserException -> DataType
$cdataTypeOf :: StringLiteralParserException -> DataType
toConstr :: StringLiteralParserException -> Constr
$ctoConstr :: StringLiteralParserException -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StringLiteralParserException
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c StringLiteralParserException
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> StringLiteralParserException
-> c StringLiteralParserException
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> StringLiteralParserException
-> c StringLiteralParserException
$cp1Data :: Typeable StringLiteralParserException
Data, Eq StringLiteralParserException
Eq StringLiteralParserException =>
(StringLiteralParserException
 -> StringLiteralParserException -> Ordering)
-> (StringLiteralParserException
    -> StringLiteralParserException -> Bool)
-> (StringLiteralParserException
    -> StringLiteralParserException -> Bool)
-> (StringLiteralParserException
    -> StringLiteralParserException -> Bool)
-> (StringLiteralParserException
    -> StringLiteralParserException -> Bool)
-> (StringLiteralParserException
    -> StringLiteralParserException -> StringLiteralParserException)
-> (StringLiteralParserException
    -> StringLiteralParserException -> StringLiteralParserException)
-> Ord StringLiteralParserException
StringLiteralParserException
-> StringLiteralParserException -> Bool
StringLiteralParserException
-> StringLiteralParserException -> Ordering
StringLiteralParserException
-> StringLiteralParserException -> StringLiteralParserException
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: StringLiteralParserException
-> StringLiteralParserException -> StringLiteralParserException
$cmin :: StringLiteralParserException
-> StringLiteralParserException -> StringLiteralParserException
max :: StringLiteralParserException
-> StringLiteralParserException -> StringLiteralParserException
$cmax :: StringLiteralParserException
-> StringLiteralParserException -> StringLiteralParserException
>= :: StringLiteralParserException
-> StringLiteralParserException -> Bool
$c>= :: StringLiteralParserException
-> StringLiteralParserException -> Bool
> :: StringLiteralParserException
-> StringLiteralParserException -> Bool
$c> :: StringLiteralParserException
-> StringLiteralParserException -> Bool
<= :: StringLiteralParserException
-> StringLiteralParserException -> Bool
$c<= :: StringLiteralParserException
-> StringLiteralParserException -> Bool
< :: StringLiteralParserException
-> StringLiteralParserException -> Bool
$c< :: StringLiteralParserException
-> StringLiteralParserException -> Bool
compare :: StringLiteralParserException
-> StringLiteralParserException -> Ordering
$ccompare :: StringLiteralParserException
-> StringLiteralParserException -> Ordering
$cp1Ord :: Eq StringLiteralParserException
Ord, Int -> StringLiteralParserException -> ShowS
[StringLiteralParserException] -> ShowS
StringLiteralParserException -> String
(Int -> StringLiteralParserException -> ShowS)
-> (StringLiteralParserException -> String)
-> ([StringLiteralParserException] -> ShowS)
-> Show StringLiteralParserException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StringLiteralParserException] -> ShowS
$cshowList :: [StringLiteralParserException] -> ShowS
show :: StringLiteralParserException -> String
$cshow :: StringLiteralParserException -> String
showsPrec :: Int -> StringLiteralParserException -> ShowS
$cshowsPrec :: Int -> StringLiteralParserException -> ShowS
Show, (forall x.
 StringLiteralParserException -> Rep StringLiteralParserException x)
-> (forall x.
    Rep StringLiteralParserException x -> StringLiteralParserException)
-> Generic StringLiteralParserException
forall x.
Rep StringLiteralParserException x -> StringLiteralParserException
forall x.
StringLiteralParserException -> Rep StringLiteralParserException x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StringLiteralParserException x -> StringLiteralParserException
$cfrom :: forall x.
StringLiteralParserException -> Rep StringLiteralParserException x
Generic)

instance NFData StringLiteralParserException

instance ShowErrorComponent StringLiteralParserException where
  showErrorComponent :: StringLiteralParserException -> String
showErrorComponent (InvalidEscapeSequence c :: Char
c) =
    "invalid escape sequence '\\" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char
c] String -> ShowS
forall a. Semigroup a => a -> a -> a
<> "'"
  showErrorComponent (InvalidChar c :: Char
c) =
    "invalid character '" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [Char
c] String -> ShowS
forall a. Semigroup a => a -> a -> a
<> "'"

data ParserException =
  ParserException (ParseErrorBundle Text CustomParserException)
  deriving stock (ParserException -> ParserException -> Bool
(ParserException -> ParserException -> Bool)
-> (ParserException -> ParserException -> Bool)
-> Eq ParserException
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ParserException -> ParserException -> Bool
$c/= :: ParserException -> ParserException -> Bool
== :: ParserException -> ParserException -> Bool
$c== :: ParserException -> ParserException -> Bool
Eq)

instance Show ParserException where
  show :: ParserException -> String
show (ParserException bundle :: ParseErrorBundle Text CustomParserException
bundle) = ParseErrorBundle Text CustomParserException -> String
forall s e.
(Stream s, ShowErrorComponent e) =>
ParseErrorBundle s e -> String
errorBundlePretty ParseErrorBundle Text CustomParserException
bundle

instance Exception ParserException where
  displayException :: ParserException -> String
displayException (ParserException bundle :: ParseErrorBundle Text CustomParserException
bundle) = ParseErrorBundle Text CustomParserException -> String
forall s e.
(Stream s, ShowErrorComponent e) =>
ParseErrorBundle s e -> String
errorBundlePretty ParseErrorBundle Text CustomParserException
bundle

instance Buildable ParserException where
  build :: ParserException -> Builder
build = Buildable String => String -> Builder
forall p. Buildable p => p -> Builder
build @String (String -> Builder)
-> (ParserException -> String) -> ParserException -> Builder
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserException -> String
forall b a. (Show a, IsString b) => a -> b
show