{-# LANGUAGE Trustworthy #-}
{-# LANGUAGE RecordWildCards, BangPatterns, NamedFieldPuns, CPP #-}
{-# OPTIONS_GHC -Wno-all-missed-specialisations #-}
{-# OPTIONS_HADDOCK hide #-}
#include "portable-unlifted.h"
module Text.Gigaparsec.Internal.Errors (
module Text.Gigaparsec.Internal.Errors,
CaretWidth(..), ExpectItem(..),
Error.presentationOffset, Error.isExpectedEmpty, DefuncHints(Blank)
) where
import Data.Set (Set)
import Text.Gigaparsec.Errors.ErrorBuilder (ErrorBuilder)
import Text.Gigaparsec.Internal.Errors.DefuncError (DefuncError)
import Text.Gigaparsec.Internal.Errors.DefuncError qualified as Error
import Text.Gigaparsec.Internal.Errors.DefuncHints (DefuncHints(Blank))
import Text.Gigaparsec.Internal.Errors.DefuncHints qualified as Hints
import Text.Gigaparsec.Internal.Errors.CaretControl (CaretWidth(FlexibleCaret, RigidCaret))
import Text.Gigaparsec.Internal.Errors.ErrorItem (ExpectItem(ExpectNamed, ExpectEndOfInput, ExpectRaw))
import Text.Gigaparsec.Internal.Errors.ParseError (fromParseError)
import Text.Gigaparsec.Internal.Errors.DefuncBuilders (asParseError)
CPP_import_PortableUnlifted
type Error :: UnliftedDatatype
type Error = DefuncError
type Hints :: UnliftedDatatype
type Hints = DefuncHints
{-# INLINE addError #-}
addError :: Hints -> Error -> Hints
addError :: Hints -> Error -> Hints
addError = Hints -> Error -> Hints
Hints.addError
{-# INLINE replaceHints #-}
replaceHints :: Set String -> Hints -> Hints
replaceHints :: Set String -> Hints -> Hints
replaceHints = Set String -> Hints -> Hints
Hints.replace
{-# INLINABLE fromError #-}
fromError :: forall err. ErrorBuilder err => Maybe FilePath -> String -> Error -> err
fromError :: forall err.
ErrorBuilder err =>
Maybe String -> String -> Error -> err
fromError Maybe String
fp String
inp Error
err = Maybe String -> String -> ParseError -> err
forall err.
ErrorBuilder err =>
Maybe String -> String -> ParseError -> err
fromParseError Maybe String
fp String
inp (String -> Error -> ParseError
asParseError String
inp Error
err)
{-# INLINE emptyErr #-}
emptyErr :: Word -> Word -> Word -> Word -> Error
emptyErr :: Word -> Word -> Word -> Word -> Error
emptyErr = Word -> Word -> Word -> Word -> Error
Error.emptyError
{-# INLINE expectedErr #-}
expectedErr :: String -> Word -> Word -> Word -> Set ExpectItem -> Word -> Error
expectedErr :: String -> Word -> Word -> Word -> Set ExpectItem -> Word -> Error
expectedErr String
_ = Word -> Word -> Word -> Set ExpectItem -> Word -> Error
Error.expectedError
{-# INLINE specialisedErr #-}
specialisedErr :: Word -> Word -> Word -> [String] -> CaretWidth -> Error
specialisedErr :: Word -> Word -> Word -> [String] -> CaretWidth -> Error
specialisedErr = Word -> Word -> Word -> [String] -> CaretWidth -> Error
Error.specialisedError
{-# INLINE unexpectedErr #-}
unexpectedErr :: Word -> Word -> Word -> Set ExpectItem -> String -> CaretWidth -> Error
unexpectedErr :: Word
-> Word -> Word -> Set ExpectItem -> String -> CaretWidth -> Error
unexpectedErr = Word
-> Word -> Word -> Set ExpectItem -> String -> CaretWidth -> Error
Error.unexpectedError
{-# INLINE labelErr #-}
labelErr :: Word -> Set String -> Error -> Error
labelErr :: Word -> Set String -> Error -> Error
labelErr = Word -> Set String -> Error -> Error
Error.label
{-# INLINABLE explainErr #-}
explainErr :: Word -> String -> Error -> Error
explainErr :: Word -> String -> Error -> Error
explainErr !Word
offset String
reason Error
err
| Word
offset Word -> Word -> Bool
forall a. Eq a => a -> a -> Bool
== Error -> Word
Error.presentationOffset Error
err = String -> Error -> Error
addReason String
reason Error
err
explainErr Word
_ String
_ Error
err = Error
err
{-# INLINE addReason #-}
addReason :: String -> Error -> Error
addReason :: String -> Error -> Error
addReason = String -> Error -> Error
Error.withReason
{-# INLINE amendErr #-}
amendErr :: Word -> Word -> Word -> Error -> Error
amendErr :: Word -> Word -> Word -> Error -> Error
amendErr = Bool -> Word -> Word -> Word -> Error -> Error
Error.amend Bool
False
{-# INLINE partialAmendErr #-}
partialAmendErr :: Word -> Word -> Word -> Error -> Error
partialAmendErr :: Word -> Word -> Word -> Error -> Error
partialAmendErr = Bool -> Word -> Word -> Word -> Error -> Error
Error.amend Bool
True
{-# INLINE entrenchErr #-}
entrenchErr :: Error -> Error
entrenchErr :: Error -> Error
entrenchErr = Error -> Error
Error.entrench
{-# INLINE dislodgeErr #-}
dislodgeErr :: Word -> Error -> Error
dislodgeErr :: Word -> Error -> Error
dislodgeErr !Word
w = Word32 -> Error -> Error
Error.dislodge (Word -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
w)
{-# INLINE setLexical #-}
setLexical :: Word -> Error -> Error
setLexical :: Word -> Error -> Error
setLexical = Word -> Error -> Error
Error.markAsLexical
{-# INLINE useHints #-}
useHints :: Hints -> Error -> Error
useHints :: Hints -> Error -> Error
useHints = Hints -> Error -> Error
Error.withHints
{-# INLINE mergeErr #-}
mergeErr :: Error -> Error -> Error
mergeErr :: Error -> Error -> Error
mergeErr = Error -> Error -> Error
Error.merge