{-# LANGUAGE Safe #-}
{-# LANGUAGE DataKinds, ConstraintKinds, AllowAmbiguousTypes, KindSignatures, MonoLocalBinds #-}
{-# OPTIONS_GHC -Wno-incomplete-record-updates #-}
{-# OPTIONS_HADDOCK hide #-}
module Text.Gigaparsec.Internal.Token.Numeric (module Text.Gigaparsec.Internal.Token.Numeric) where
import Text.Gigaparsec (Parsec, unit, void, atomic, (<|>), ($>))
import Text.Gigaparsec.Char (char, oneOf)
import Text.Gigaparsec.Combinator (optional, optionalAs)
import Text.Gigaparsec.Token.Descriptions
( BreakCharDesc(BreakCharSupported, NoBreakChar),
NumericDesc( NumericDesc, positiveSign, literalBreakChar
, integerNumbersCanBeHexadecimal, integerNumbersCanBeOctal
, integerNumbersCanBeBinary
, hexadecimalLeads, octalLeads, binaryLeads
),
PlusSignPresence(PlusIllegal, PlusRequired, PlusOptional) )
import Text.Gigaparsec.Internal.Token.Generic (
GenericNumeric(plainDecimal, plainHexadecimal, plainOctal, plainBinary)
)
import Text.Gigaparsec.Internal.Token.BitBounds (
CanHoldUnsigned, CanHoldSigned,
BitBounds(upperSigned, upperUnsigned, lowerSigned),
Bits(B8, B16, B32, B64), bits
)
import Text.Gigaparsec.Token.Errors (
ErrorConfig (filterIntegerOutOfBounds, labelIntegerSignedDecimal, labelIntegerUnsignedDecimal,
labelIntegerSignedHexadecimal, labelIntegerUnsignedHexadecimal,
labelIntegerSignedOctal, labelIntegerUnsignedOctal, labelIntegerSignedBinary,
labelIntegerUnsignedBinary, labelIntegerSignedNumber, labelIntegerUnsignedNumber,
labelIntegerDecimalEnd, labelIntegerHexadecimalEnd, labelIntegerOctalEnd,
labelIntegerBinaryEnd, labelIntegerNumberEnd)
)
import Data.Kind (Constraint)
import Data.Proxy (Proxy(Proxy))
import Control.Monad (when, unless)
import Text.Gigaparsec.Internal.Token.Errors (mapMaybeS, LabelWithExplainConfig, annotate)
type IntegerParsers :: (Bits -> * -> Constraint) -> *
data IntegerParsers canHold = IntegerParsers {
forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
decimal :: Parsec Integer
, forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: Parsec Integer
, forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: Parsec Integer
, forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: Parsec Integer
, forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: Parsec Integer
, forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded :: forall (bits :: Bits) t. canHold bits t
=> Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
}
decimalBounded :: forall (bits :: Bits) canHold t. canHold bits t => IntegerParsers canHold -> Parsec t
decimalBounded :: forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
decimalBounded IntegerParsers{Parsec Integer
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
_bounded :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..} = Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded (forall {k} (t :: k). Proxy t
forall (t :: Bits). Proxy t
Proxy @bits) Parsec Integer
decimal Int
10 ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label
where label :: ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label !ErrorConfig
err Bool
True = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedDecimal ErrorConfig
err
label ErrorConfig
err Bool
False = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedDecimal ErrorConfig
err
hexadecimalBounded :: forall (bits :: Bits) canHold t. canHold bits t => IntegerParsers canHold -> Parsec t
hexadecimalBounded :: forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
hexadecimalBounded IntegerParsers{Parsec Integer
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
_bounded :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..} = Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded (forall {k} (t :: k). Proxy t
forall (t :: Bits). Proxy t
Proxy @bits) Parsec Integer
hexadecimal Int
16 ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label
where label :: ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label !ErrorConfig
err Bool
True = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedHexadecimal ErrorConfig
err
label ErrorConfig
err Bool
False = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedHexadecimal ErrorConfig
err
octalBounded :: forall (bits :: Bits) canHold t. canHold bits t => IntegerParsers canHold -> Parsec t
octalBounded :: forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
octalBounded IntegerParsers{Parsec Integer
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
_bounded :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..} = Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded (forall {k} (t :: k). Proxy t
forall (t :: Bits). Proxy t
Proxy @bits) Parsec Integer
octal Int
8 ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label
where label :: ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label !ErrorConfig
err Bool
True = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedOctal ErrorConfig
err
label ErrorConfig
err Bool
False = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedOctal ErrorConfig
err
binaryBounded :: forall (bits :: Bits) canHold t. canHold bits t => IntegerParsers canHold -> Parsec t
binaryBounded :: forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
binaryBounded IntegerParsers{Parsec Integer
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
_bounded :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..} = Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded (forall {k} (t :: k). Proxy t
forall (t :: Bits). Proxy t
Proxy @bits) Parsec Integer
binary Int
2 ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label
where label :: ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label !ErrorConfig
err Bool
True = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedBinary ErrorConfig
err
label ErrorConfig
err Bool
False = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedBinary ErrorConfig
err
numberBounded :: forall (bits :: Bits) canHold t. canHold bits t => IntegerParsers canHold -> Parsec t
numberBounded :: forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
numberBounded IntegerParsers{Parsec Integer
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
_bounded :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..} = Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded (forall {k} (t :: k). Proxy t
forall (t :: Bits). Proxy t
Proxy @bits) Parsec Integer
number Int
10 ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label
where label :: ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label !ErrorConfig
err Bool
True = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedNumber ErrorConfig
err
label ErrorConfig
err Bool
False = ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedNumber ErrorConfig
err
decimal8 :: forall a canHold. canHold 'B8 a => IntegerParsers canHold -> Parsec a
decimal8 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B8 a =>
IntegerParsers canHold -> Parsec a
decimal8 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
decimalBounded @'B8
hexadecimal8 :: forall a canHold. canHold 'B8 a => IntegerParsers canHold -> Parsec a
hexadecimal8 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B8 a =>
IntegerParsers canHold -> Parsec a
hexadecimal8 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
hexadecimalBounded @'B8
octal8 :: forall a canHold. canHold 'B8 a => IntegerParsers canHold -> Parsec a
octal8 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B8 a =>
IntegerParsers canHold -> Parsec a
octal8 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
octalBounded @'B8
binary8 :: forall a canHold. canHold 'B8 a => IntegerParsers canHold -> Parsec a
binary8 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B8 a =>
IntegerParsers canHold -> Parsec a
binary8 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
binaryBounded @'B8
number8 :: forall a canHold. canHold 'B8 a => IntegerParsers canHold -> Parsec a
number8 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B8 a =>
IntegerParsers canHold -> Parsec a
number8 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
numberBounded @'B8
decimal16 :: forall a canHold. canHold 'B16 a => IntegerParsers canHold -> Parsec a
decimal16 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B16 a =>
IntegerParsers canHold -> Parsec a
decimal16 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
decimalBounded @'B16
hexadecimal16 :: forall a canHold. canHold 'B16 a => IntegerParsers canHold -> Parsec a
hexadecimal16 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B16 a =>
IntegerParsers canHold -> Parsec a
hexadecimal16 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
hexadecimalBounded @'B16
octal16 :: forall a canHold. canHold 'B16 a => IntegerParsers canHold -> Parsec a
octal16 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B16 a =>
IntegerParsers canHold -> Parsec a
octal16 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
octalBounded @'B16
binary16 :: forall a canHold. canHold 'B16 a => IntegerParsers canHold -> Parsec a
binary16 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B16 a =>
IntegerParsers canHold -> Parsec a
binary16 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
binaryBounded @'B16
number16 :: forall a canHold. canHold 'B16 a => IntegerParsers canHold -> Parsec a
number16 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B16 a =>
IntegerParsers canHold -> Parsec a
number16 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
numberBounded @'B16
decimal32 :: forall a canHold. canHold 'B32 a => IntegerParsers canHold -> Parsec a
decimal32 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B32 a =>
IntegerParsers canHold -> Parsec a
decimal32 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
decimalBounded @'B32
hexadecimal32 :: forall a canHold. canHold 'B32 a => IntegerParsers canHold -> Parsec a
hexadecimal32 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B32 a =>
IntegerParsers canHold -> Parsec a
hexadecimal32 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
hexadecimalBounded @'B32
octal32 :: forall a canHold. canHold 'B32 a => IntegerParsers canHold -> Parsec a
octal32 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B32 a =>
IntegerParsers canHold -> Parsec a
octal32 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
octalBounded @'B32
binary32 :: forall a canHold. canHold 'B32 a => IntegerParsers canHold -> Parsec a
binary32 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B32 a =>
IntegerParsers canHold -> Parsec a
binary32 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
binaryBounded @'B32
number32 :: forall a canHold. canHold 'B32 a => IntegerParsers canHold -> Parsec a
number32 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B32 a =>
IntegerParsers canHold -> Parsec a
number32 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
numberBounded @'B32
decimal64 :: forall a canHold. canHold 'B64 a => IntegerParsers canHold -> Parsec a
decimal64 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B64 a =>
IntegerParsers canHold -> Parsec a
decimal64 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
decimalBounded @'B64
hexadecimal64 :: forall a canHold. canHold 'B64 a => IntegerParsers canHold -> Parsec a
hexadecimal64 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B64 a =>
IntegerParsers canHold -> Parsec a
hexadecimal64 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
hexadecimalBounded @'B64
octal64 :: forall a canHold. canHold 'B64 a => IntegerParsers canHold -> Parsec a
octal64 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B64 a =>
IntegerParsers canHold -> Parsec a
octal64 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
octalBounded @'B64
binary64 :: forall a canHold. canHold 'B64 a => IntegerParsers canHold -> Parsec a
binary64 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B64 a =>
IntegerParsers canHold -> Parsec a
binary64 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
binaryBounded @'B64
number64 :: forall a canHold. canHold 'B64 a => IntegerParsers canHold -> Parsec a
number64 :: forall a (canHold :: Bits -> * -> Constraint).
canHold 'B64 a =>
IntegerParsers canHold -> Parsec a
number64 = forall (bits :: Bits) (canHold :: Bits -> * -> Constraint) t.
canHold bits t =>
IntegerParsers canHold -> Parsec t
numberBounded @'B64
mkUnsigned :: NumericDesc -> GenericNumeric -> ErrorConfig -> IntegerParsers CanHoldUnsigned
mkUnsigned :: NumericDesc
-> GenericNumeric -> ErrorConfig -> IntegerParsers CanHoldUnsigned
mkUnsigned desc :: NumericDesc
desc@NumericDesc{Bool
Set Char
PlusSignPresence
BreakCharDesc
positiveSign :: NumericDesc -> PlusSignPresence
literalBreakChar :: NumericDesc -> BreakCharDesc
integerNumbersCanBeHexadecimal :: NumericDesc -> Bool
integerNumbersCanBeOctal :: NumericDesc -> Bool
integerNumbersCanBeBinary :: NumericDesc -> Bool
hexadecimalLeads :: NumericDesc -> Set Char
octalLeads :: NumericDesc -> Set Char
binaryLeads :: NumericDesc -> Set Char
literalBreakChar :: BreakCharDesc
positiveSign :: PlusSignPresence
integerNumbersCanBeHexadecimal :: Bool
integerNumbersCanBeOctal :: Bool
integerNumbersCanBeBinary :: Bool
hexadecimalLeads :: Set Char
octalLeads :: Set Char
binaryLeads :: Set Char
..} !GenericNumeric
gen !ErrorConfig
err = IntegerParsers {Parsec Integer
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
CanHoldUnsigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
CanHoldUnsigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded :: forall (bits :: Bits) t.
CanHoldUnsigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
..}
where _bounded :: forall (b :: Bits) t. CanHoldUnsigned b t
=> Proxy b -> Parsec Integer -> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded :: forall (bits :: Bits) t.
CanHoldUnsigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded Proxy b
_ Parsec Integer
num Int
radix ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label = LabelWithExplainConfig -> Parsec t -> Parsec t
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label ErrorConfig
err Bool
False (Bits -> Maybe Bits
forall a. a -> Maybe a
Just (forall (b :: Bits). BitBounds b => Bits
bits @b))) (Parsec t -> Parsec t) -> Parsec t -> Parsec t
forall a b. (a -> b) -> a -> b
$
FilterConfig Integer
-> (Integer -> Maybe t) -> Parsec Integer -> Parsec t
forall a b.
FilterConfig a -> (a -> Maybe b) -> Parsec a -> Parsec b
forall (config :: * -> *) a b.
Filter config =>
config a -> (a -> Maybe b) -> Parsec a -> Parsec b
mapMaybeS (ErrorConfig -> Integer -> Integer -> Int -> FilterConfig Integer
filterIntegerOutOfBounds ErrorConfig
err Integer
0 (forall (b :: Bits). BitBounds b => Integer
upperUnsigned @b) Int
radix)
(\Integer
n -> if Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= Integer
0 Bool -> Bool -> Bool
&& Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= forall (b :: Bits). BitBounds b => Integer
upperUnsigned @b then t -> Maybe t
forall a. a -> Maybe a
Just (Integer -> t
forall a. Num a => Integer -> a
fromInteger Integer
n) else Maybe t
forall a. Maybe a
Nothing)
Parsec Integer
num
leadingBreakChar :: Parsec ()
leadingBreakChar = case BreakCharDesc
literalBreakChar of
BreakCharDesc
NoBreakChar -> Parsec ()
unit
BreakCharSupported Char
breakChar Bool
allowedAfterNonDecimalPrefix ->
Bool -> Parsec () -> Parsec ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
allowedAfterNonDecimalPrefix (Parsec Char -> Parsec ()
forall a. Parsec a -> Parsec ()
optional (Char -> Parsec Char
char Char
breakChar))
noZeroHexadecimal :: Parsec Integer
noZeroHexadecimal = do
Bool -> Parsec () -> Parsec ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Set Char -> Bool
forall a. Set a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Set Char
hexadecimalLeads) (Parsec Char -> Parsec ()
forall a. Parsec a -> Parsec ()
void (Set Char -> Parsec Char
oneOf Set Char
hexadecimalLeads))
Parsec ()
leadingBreakChar
LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerHexadecimalEnd ErrorConfig
err) (GenericNumeric -> NumericDesc -> LabelConfig -> Parsec Integer
plainHexadecimal GenericNumeric
gen NumericDesc
desc (ErrorConfig -> LabelConfig
labelIntegerHexadecimalEnd ErrorConfig
err))
noZeroOctal :: Parsec Integer
noZeroOctal = do
Bool -> Parsec () -> Parsec ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Set Char -> Bool
forall a. Set a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Set Char
octalLeads) (Parsec Char -> Parsec ()
forall a. Parsec a -> Parsec ()
void (Set Char -> Parsec Char
oneOf Set Char
octalLeads))
Parsec ()
leadingBreakChar
LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerOctalEnd ErrorConfig
err) (GenericNumeric -> NumericDesc -> LabelConfig -> Parsec Integer
plainOctal GenericNumeric
gen NumericDesc
desc (ErrorConfig -> LabelConfig
labelIntegerOctalEnd ErrorConfig
err))
noZeroBinary :: Parsec Integer
noZeroBinary = do
Bool -> Parsec () -> Parsec ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Set Char -> Bool
forall a. Set a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Set Char
binaryLeads) (Parsec Char -> Parsec ()
forall a. Parsec a -> Parsec ()
void (Set Char -> Parsec Char
oneOf Set Char
binaryLeads))
Parsec ()
leadingBreakChar
LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerBinaryEnd ErrorConfig
err) (GenericNumeric -> NumericDesc -> LabelConfig -> Parsec Integer
plainBinary GenericNumeric
gen NumericDesc
desc (ErrorConfig -> LabelConfig
labelIntegerBinaryEnd ErrorConfig
err))
decimal :: Parsec Integer
decimal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedDecimal ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$ GenericNumeric -> NumericDesc -> LabelConfig -> Parsec Integer
plainDecimal GenericNumeric
gen NumericDesc
desc (ErrorConfig -> LabelConfig
labelIntegerDecimalEnd ErrorConfig
err)
hexadecimal :: Parsec Integer
hexadecimal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedHexadecimal ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$ Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Char -> Parsec Char
char Char
'0' Parsec Char -> Parsec Integer -> Parsec Integer
forall a b. Parsec a -> Parsec b -> Parsec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec Integer
noZeroHexadecimal)
octal :: Parsec Integer
octal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedOctal ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$ Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Char -> Parsec Char
char Char
'0' Parsec Char -> Parsec Integer -> Parsec Integer
forall a b. Parsec a -> Parsec b -> Parsec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec Integer
noZeroOctal)
binary :: Parsec Integer
binary = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedBinary ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$ Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Char -> Parsec Char
char Char
'0' Parsec Char -> Parsec Integer -> Parsec Integer
forall a b. Parsec a -> Parsec b -> Parsec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec Integer
noZeroBinary)
number :: Parsec Integer
number
| Bool -> Bool
not Bool
integerNumbersCanBeBinary
, Bool -> Bool
not Bool
integerNumbersCanBeHexadecimal
, Bool -> Bool
not Bool
integerNumbersCanBeOctal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedNumber ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) Parsec Integer
decimal
| Bool
otherwise = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerUnsignedNumber ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$ Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Parsec Integer
zeroLead Parsec Integer -> Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a -> Parsec a
<|> Parsec Integer
decimal)
where zeroLead :: Parsec Integer
zeroLead = Char -> Parsec Char
char Char
'0' Parsec Char -> Parsec Integer -> Parsec Integer
forall a b. Parsec a -> Parsec b -> Parsec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec Integer -> Parsec Integer
addHex (Parsec Integer -> Parsec Integer
addOct (Parsec Integer -> Parsec Integer
addBin (Parsec Integer
decimal Parsec Integer -> Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a -> Parsec a
<|> Integer -> Parsec Integer
forall a. a -> Parsec a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Integer
0)))
addHex :: Parsec Integer -> Parsec Integer
addHex
| Bool
integerNumbersCanBeHexadecimal = (Parsec Integer
noZeroHexadecimal Parsec Integer -> Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a -> Parsec a
<|>)
| Bool
otherwise = Parsec Integer -> Parsec Integer
forall a. a -> a
id
addOct :: Parsec Integer -> Parsec Integer
addOct
| Bool
integerNumbersCanBeOctal = (Parsec Integer
noZeroOctal Parsec Integer -> Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a -> Parsec a
<|>)
| Bool
otherwise = Parsec Integer -> Parsec Integer
forall a. a -> a
id
addBin :: Parsec Integer -> Parsec Integer
addBin
| Bool
integerNumbersCanBeBinary = (Parsec Integer
noZeroBinary Parsec Integer -> Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a -> Parsec a
<|>)
| Bool
otherwise = Parsec Integer -> Parsec Integer
forall a. a -> a
id
mkSigned :: NumericDesc -> IntegerParsers c -> ErrorConfig -> IntegerParsers CanHoldSigned
mkSigned :: forall (c :: Bits -> * -> Constraint).
NumericDesc
-> IntegerParsers c -> ErrorConfig -> IntegerParsers CanHoldSigned
mkSigned NumericDesc{Bool
Set Char
PlusSignPresence
BreakCharDesc
positiveSign :: NumericDesc -> PlusSignPresence
literalBreakChar :: NumericDesc -> BreakCharDesc
integerNumbersCanBeHexadecimal :: NumericDesc -> Bool
integerNumbersCanBeOctal :: NumericDesc -> Bool
integerNumbersCanBeBinary :: NumericDesc -> Bool
hexadecimalLeads :: NumericDesc -> Set Char
octalLeads :: NumericDesc -> Set Char
binaryLeads :: NumericDesc -> Set Char
literalBreakChar :: BreakCharDesc
positiveSign :: PlusSignPresence
integerNumbersCanBeHexadecimal :: Bool
integerNumbersCanBeOctal :: Bool
integerNumbersCanBeBinary :: Bool
hexadecimalLeads :: Set Char
octalLeads :: Set Char
binaryLeads :: Set Char
..} !IntegerParsers c
unsigned !ErrorConfig
err = IntegerParsers {
decimal :: Parsec Integer
decimal = Parsec Integer
_decimal,
hexadecimal :: Parsec Integer
hexadecimal = Parsec Integer
_hexadecimal,
octal :: Parsec Integer
octal = Parsec Integer
_octal,
binary :: Parsec Integer
binary = Parsec Integer
_binary,
number :: Parsec Integer
number = Parsec Integer
_number,
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
CanHoldSigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded :: forall (bits :: Bits) t.
CanHoldSigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded :: forall (bits :: Bits) t.
CanHoldSigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..
}
where _bounded :: forall (b :: Bits) t. CanHoldSigned b t
=> Proxy b -> Parsec Integer -> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded :: forall (bits :: Bits) t.
CanHoldSigned bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded Proxy b
_ Parsec Integer
num Int
radix ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label = LabelWithExplainConfig -> Parsec t -> Parsec t
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label ErrorConfig
err Bool
True (Bits -> Maybe Bits
forall a. a -> Maybe a
Just (forall (b :: Bits). BitBounds b => Bits
bits @b))) (Parsec t -> Parsec t) -> Parsec t -> Parsec t
forall a b. (a -> b) -> a -> b
$
FilterConfig Integer
-> (Integer -> Maybe t) -> Parsec Integer -> Parsec t
forall a b.
FilterConfig a -> (a -> Maybe b) -> Parsec a -> Parsec b
forall (config :: * -> *) a b.
Filter config =>
config a -> (a -> Maybe b) -> Parsec a -> Parsec b
mapMaybeS (ErrorConfig -> Integer -> Integer -> Int -> FilterConfig Integer
filterIntegerOutOfBounds ErrorConfig
err (forall (b :: Bits). BitBounds b => Integer
lowerSigned @b) (forall (b :: Bits). BitBounds b => Integer
upperSigned @b) Int
radix)
(\Integer
n -> if Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
>= forall (b :: Bits). BitBounds b => Integer
lowerSigned @b Bool -> Bool -> Bool
&& Integer
n Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= forall (b :: Bits). BitBounds b => Integer
upperSigned @b
then t -> Maybe t
forall a. a -> Maybe a
Just (Integer -> t
forall a. Num a => Integer -> a
fromInteger Integer
n)
else Maybe t
forall a. Maybe a
Nothing)
Parsec Integer
num
sign :: Parsec (Integer -> Integer)
sign :: Parsec (Integer -> Integer)
sign = case PlusSignPresence
positiveSign of
PlusSignPresence
PlusRequired -> Char -> Parsec Char
char Char
'+' Parsec Char -> (Integer -> Integer) -> Parsec (Integer -> Integer)
forall a b. Parsec a -> b -> Parsec b
$> Integer -> Integer
forall a. a -> a
id Parsec (Integer -> Integer)
-> Parsec (Integer -> Integer) -> Parsec (Integer -> Integer)
forall a. Parsec a -> Parsec a -> Parsec a
<|> Char -> Parsec Char
char Char
'-' Parsec Char -> (Integer -> Integer) -> Parsec (Integer -> Integer)
forall a b. Parsec a -> b -> Parsec b
$> Integer -> Integer
forall a. Num a => a -> a
negate
PlusSignPresence
PlusOptional -> Char -> Parsec Char
char Char
'-' Parsec Char -> (Integer -> Integer) -> Parsec (Integer -> Integer)
forall a b. Parsec a -> b -> Parsec b
$> Integer -> Integer
forall a. Num a => a -> a
negate Parsec (Integer -> Integer)
-> Parsec (Integer -> Integer) -> Parsec (Integer -> Integer)
forall a. Parsec a -> Parsec a -> Parsec a
<|> (Integer -> Integer) -> Parsec Char -> Parsec (Integer -> Integer)
forall b a. b -> Parsec a -> Parsec b
optionalAs Integer -> Integer
forall a. a -> a
id (Char -> Parsec Char
char Char
'+')
PlusSignPresence
PlusIllegal -> (Integer -> Integer) -> Parsec (Integer -> Integer)
forall a. a -> Parsec a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Integer -> Integer
forall a. a -> a
id
_decimal :: Parsec Integer
_decimal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedDecimal ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$
Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Parsec (Integer -> Integer)
sign Parsec (Integer -> Integer) -> Parsec Integer -> Parsec Integer
forall a b. Parsec (a -> b) -> Parsec a -> Parsec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerDecimalEnd ErrorConfig
err) (IntegerParsers c -> Parsec Integer
forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
decimal IntegerParsers c
unsigned))
_hexadecimal :: Parsec Integer
_hexadecimal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedHexadecimal ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$
Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Parsec (Integer -> Integer)
sign Parsec (Integer -> Integer) -> Parsec Integer -> Parsec Integer
forall a b. Parsec (a -> b) -> Parsec a -> Parsec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerHexadecimalEnd ErrorConfig
err) (IntegerParsers c -> Parsec Integer
forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal IntegerParsers c
unsigned))
_octal :: Parsec Integer
_octal = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedOctal ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$
Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Parsec (Integer -> Integer)
sign Parsec (Integer -> Integer) -> Parsec Integer -> Parsec Integer
forall a b. Parsec (a -> b) -> Parsec a -> Parsec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerOctalEnd ErrorConfig
err) (IntegerParsers c -> Parsec Integer
forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal IntegerParsers c
unsigned))
_binary :: Parsec Integer
_binary = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedBinary ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$
Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Parsec (Integer -> Integer)
sign Parsec (Integer -> Integer) -> Parsec Integer -> Parsec Integer
forall a b. Parsec (a -> b) -> Parsec a -> Parsec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerBinaryEnd ErrorConfig
err) (IntegerParsers c -> Parsec Integer
forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary IntegerParsers c
unsigned))
_number :: Parsec Integer
_number = LabelWithExplainConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelWithExplainConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> Maybe Bits -> LabelWithExplainConfig
labelIntegerSignedNumber ErrorConfig
err Maybe Bits
forall a. Maybe a
Nothing) (Parsec Integer -> Parsec Integer)
-> Parsec Integer -> Parsec Integer
forall a b. (a -> b) -> a -> b
$
Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
atomic (Parsec (Integer -> Integer)
sign Parsec (Integer -> Integer) -> Parsec Integer -> Parsec Integer
forall a b. Parsec (a -> b) -> Parsec a -> Parsec b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> LabelConfig -> Parsec Integer -> Parsec Integer
forall config a. Annotate config => config -> Parsec a -> Parsec a
forall a. LabelConfig -> Parsec a -> Parsec a
annotate (ErrorConfig -> LabelConfig
labelIntegerNumberEnd ErrorConfig
err) (IntegerParsers c -> Parsec Integer
forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number IntegerParsers c
unsigned))
lexemeInteger :: (forall a. Parsec a -> Parsec a) -> IntegerParsers c -> IntegerParsers c
lexemeInteger :: forall (c :: Bits -> * -> Constraint).
(forall a. Parsec a -> Parsec a)
-> IntegerParsers c -> IntegerParsers c
lexemeInteger forall a. Parsec a -> Parsec a
lexe IntegerParsers{Parsec Integer
forall (bits :: Bits) t.
c bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
hexadecimal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
octal :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
binary :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
number :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold -> Parsec Integer
_bounded :: forall (canHold :: Bits -> * -> Constraint).
IntegerParsers canHold
-> forall (bits :: Bits) t.
canHold bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
decimal :: Parsec Integer
hexadecimal :: Parsec Integer
octal :: Parsec Integer
binary :: Parsec Integer
number :: Parsec Integer
_bounded :: forall (bits :: Bits) t.
c bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
..} = IntegerParsers {
decimal :: Parsec Integer
decimal = Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
lexe Parsec Integer
decimal,
hexadecimal :: Parsec Integer
hexadecimal = Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
lexe Parsec Integer
hexadecimal,
octal :: Parsec Integer
octal = Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
lexe Parsec Integer
octal,
binary :: Parsec Integer
binary = Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
lexe Parsec Integer
binary,
number :: Parsec Integer
number = Parsec Integer -> Parsec Integer
forall a. Parsec a -> Parsec a
lexe Parsec Integer
number,
_bounded :: forall (bits :: Bits) t.
c bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded = \Proxy bits
n Parsec Integer
b Int
radix ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label -> Parsec t -> Parsec t
forall a. Parsec a -> Parsec a
lexe (Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
forall (bits :: Bits) t.
c bits t =>
Proxy bits
-> Parsec Integer
-> Int
-> (ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig)
-> Parsec t
_bounded Proxy bits
n Parsec Integer
b Int
radix ErrorConfig -> Bool -> Maybe Bits -> LabelWithExplainConfig
label)
}