{-# LANGUAGE UnboxedTuples #-}
module FlatParse.Basic.Base
(
eof
, take
, take#
, takeUnsafe#
, takeRest
, skip
, skip#
, skipBack
, skipBack#
, atSkip#
, atSkipUnsafe#
, branch
, notFollowedBy
, chainl
, chainr
, lookahead
, ensure
, ensure#
, withEnsure
, withEnsure1
, withEnsure#
, isolate
, isolate#
, isolateUnsafe#
, skipMany
, skipSome
, failed
, try
, err
, withError
, fails
, cut
, cutting
, optional
, optional_
, withOption
) where
import Prelude hiding ( take )
import FlatParse.Basic.Parser
import qualified FlatParse.Common.Assorted as Common
import GHC.Exts
import qualified Data.ByteString as B
import qualified Data.ByteString.Internal as B
import GHC.ForeignPtr ( ForeignPtr(..) )
import qualified Control.Applicative
failed :: ParserT st e a
failed :: forall (st :: ZeroBitType) e a. ParserT st e a
failed = forall (f :: * -> *) a. Alternative f => f a
Control.Applicative.empty
{-# inline failed #-}
err :: e -> ParserT st e a
err :: forall e (st :: ZeroBitType) a. e -> ParserT st e a
err e
e = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
_fp Addr#
_eob Addr#
_s st
st -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st e
e
{-# inline err #-}
withError :: ParserT st e b -> (e -> ParserT st e b) -> ParserT st e b
withError :: forall (st :: ZeroBitType) e b.
ParserT st e b -> (e -> ParserT st e b) -> ParserT st e b
withError (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
f) e -> ParserT st e b
hdl = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT forall a b. (a -> b) -> a -> b
$ \ForeignPtrContents
fp Addr#
eob Addr#
s st
st -> case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
Err# st
st' e
e -> case e -> ParserT st e b
hdl e
e of
ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
g -> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
g ForeignPtrContents
fp Addr#
eob Addr#
s st
st'
Res# st e b
x -> Res# st e b
x
{-# inline withError #-}
try :: ParserT st e a -> ParserT st e a
try :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e a
try (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st -> case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
Err# st
st' e
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st'
Res# st e a
x -> Res# st e a
x
{-# inline try #-}
fails :: ParserT st e a -> ParserT st e ()
fails :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e ()
fails (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
OK# st
st' a
_ Addr#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st'
Fail# st
st' -> forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st' () Addr#
s
Err# st
st' e
e -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' e
e
{-# inline fails #-}
cut :: ParserT st e a -> e -> ParserT st e a
cut :: forall (st :: ZeroBitType) e a.
ParserT st e a -> e -> ParserT st e a
cut (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) e
e = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st -> case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
Fail# st
st' -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' e
e
Res# st e a
x -> Res# st e a
x
{-# inline cut #-}
cutting :: ParserT st e a -> e -> (e -> e -> e) -> ParserT st e a
cutting :: forall (st :: ZeroBitType) e a.
ParserT st e a -> e -> (e -> e -> e) -> ParserT st e a
cutting (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) e
e e -> e -> e
merge = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st -> case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
Fail# st
st' -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' e
e
Err# st
st' e
e' -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' forall a b. (a -> b) -> a -> b
$! e -> e -> e
merge e
e' e
e
Res# st e a
x -> Res# st e a
x
{-# inline cutting #-}
optional :: ParserT st e a -> ParserT st e (Maybe a)
optional :: forall (st :: ZeroBitType) e a.
ParserT st e a -> ParserT st e (Maybe a)
optional ParserT st e a
p = (forall a. a -> Maybe a
Just forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParserT st e a
p) forall (st :: ZeroBitType) e a.
ParserT st e a -> ParserT st e a -> ParserT st e a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a. Maybe a
Nothing
{-# inline optional #-}
optional_ :: ParserT st e a -> ParserT st e ()
optional_ :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e ()
optional_ ParserT st e a
p = (() forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParserT st e a
p) forall (st :: ZeroBitType) e a.
ParserT st e a -> ParserT st e a -> ParserT st e a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure ()
{-# inline optional_ #-}
withOption :: ParserT st e a -> (a -> ParserT st e r) -> ParserT st e r -> ParserT st e r
withOption :: forall (st :: ZeroBitType) e a r.
ParserT st e a
-> (a -> ParserT st e r) -> ParserT st e r -> ParserT st e r
withOption (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) a -> ParserT st e r
just (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
nothing) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
OK# st
st' a
a Addr#
s -> forall (st :: ZeroBitType) e a.
ParserT st e a
-> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
runParserT# (a -> ParserT st e r
just a
a) ForeignPtrContents
fp Addr#
eob Addr#
s st
st'
Fail# st
st' -> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
nothing ForeignPtrContents
fp Addr#
eob Addr#
s st
st'
Err# st
st' e
e -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' e
e
{-# inline withOption #-}
eof :: ParserT st e ()
eof :: forall (st :: ZeroBitType) e. ParserT st e ()
eof = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob Addr#
s of
Int#
1# -> forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st () Addr#
s
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline eof #-}
lookahead :: ParserT st e a -> ParserT st e a
lookahead :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e a
lookahead (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
OK# st
st' a
a Addr#
_ -> forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st' a
a Addr#
s
Res# st e a
x -> Res# st e a
x
{-# inline lookahead #-}
isolate :: Int -> ParserT st e a -> ParserT st e a
isolate :: forall (st :: ZeroBitType) e a.
Int -> ParserT st e a -> ParserT st e a
isolate = forall r. (Int# -> r) -> Int -> r
Common.withIntUnwrap# forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
isolate#
{-# inline isolate #-}
isolate# :: Int# -> ParserT st e a -> ParserT st e a
isolate# :: forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
isolate# Int#
n# ParserT st e a
p = forall r. Int# -> r -> r
Common.withPosInt# Int#
n# (forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
isolateUnsafe# Int#
n# ParserT st e a
p)
{-# inline isolate# #-}
isolateUnsafe# :: Int# -> ParserT st e a -> ParserT st e a
isolateUnsafe# :: forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
isolateUnsafe# Int#
n# (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
p) =
forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
withEnsure# Int#
n# forall a b. (a -> b) -> a -> b
$ forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
let s' :: Addr#
s' = Addr# -> Int# -> Addr#
plusAddr# Addr#
s Int#
n#
in case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
p ForeignPtrContents
fp Addr#
s' Addr#
s st
st of
OK# st
st' a
a Addr#
s'' ->
case Addr# -> Addr# -> Int#
eqAddr# Addr#
s' Addr#
s'' of
Int#
1# -> forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st' a
a Addr#
s''
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st'
Res# st e a
x -> Res# st e a
x
{-# inline isolateUnsafe# #-}
chainl :: (b -> a -> b) -> ParserT st e b -> ParserT st e a -> ParserT st e b
chainl :: forall b a (st :: ZeroBitType) e.
(b -> a -> b) -> ParserT st e b -> ParserT st e a -> ParserT st e b
chainl b -> a -> b
f ParserT st e b
start ParserT st e a
elem = ParserT st e b
start forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= b -> ParserT st e b
go where
go :: b -> ParserT st e b
go b
b = do {!a
a <- ParserT st e a
elem; b -> ParserT st e b
go forall a b. (a -> b) -> a -> b
$! b -> a -> b
f b
b a
a} forall (st :: ZeroBitType) e a.
ParserT st e a -> ParserT st e a -> ParserT st e a
<|> forall (f :: * -> *) a. Applicative f => a -> f a
pure b
b
{-# inline chainl #-}
chainr :: (a -> b -> b) -> ParserT st e a -> ParserT st e b -> ParserT st e b
chainr :: forall a b (st :: ZeroBitType) e.
(a -> b -> b) -> ParserT st e a -> ParserT st e b -> ParserT st e b
chainr a -> b -> b
f (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
elem) (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
end) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
go where
go :: ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
go ForeignPtrContents
fp Addr#
eob Addr#
s st
st = case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
elem ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
OK# st
st' a
a Addr#
s -> case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
go ForeignPtrContents
fp Addr#
eob Addr#
s st
st' of
OK# st
st'' b
b Addr#
s -> let !b' :: b
b' = a -> b -> b
f a
a b
b in forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st'' b
b' Addr#
s
Res# st e b
x -> Res# st e b
x
Fail# st
st' -> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e b
end ForeignPtrContents
fp Addr#
eob Addr#
s st
st'
Err# st
st' e
e -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' e
e
{-# inline chainr #-}
branch :: ParserT st e a -> ParserT st e b -> ParserT st e b -> ParserT st e b
branch :: forall (st :: ZeroBitType) e a b.
ParserT st e a
-> ParserT st e b -> ParserT st e b -> ParserT st e b
branch ParserT st e a
pa ParserT st e b
pt ParserT st e b
pf = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st -> case forall (st :: ZeroBitType) e a.
ParserT st e a
-> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
runParserT# ParserT st e a
pa ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
OK# st
st' a
_ Addr#
s -> forall (st :: ZeroBitType) e a.
ParserT st e a
-> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
runParserT# ParserT st e b
pt ForeignPtrContents
fp Addr#
eob Addr#
s st
st'
Fail# st
st' -> forall (st :: ZeroBitType) e a.
ParserT st e a
-> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
runParserT# ParserT st e b
pf ForeignPtrContents
fp Addr#
eob Addr#
s st
st'
Err# st
st' e
e -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st' e
e
{-# inline branch #-}
notFollowedBy :: ParserT st e a -> ParserT st e b -> ParserT st e a
notFollowedBy :: forall (st :: ZeroBitType) e a b.
ParserT st e a -> ParserT st e b -> ParserT st e a
notFollowedBy ParserT st e a
p1 ParserT st e b
p2 = ParserT st e a
p1 forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e ()
fails ParserT st e b
p2
{-# inline notFollowedBy #-}
ensure :: Int -> ParserT st e ()
ensure :: forall (st :: ZeroBitType) e. Int -> ParserT st e ()
ensure = forall r. (Int# -> r) -> Int -> r
Common.withIntUnwrap# forall (st :: ZeroBitType) e. Int# -> ParserT st e ()
ensure#
{-# inline ensure #-}
ensure# :: Int# -> ParserT st e ()
ensure# :: forall (st :: ZeroBitType) e. Int# -> ParserT st e ()
ensure# Int#
n# = forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
withEnsure# Int#
n# (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
{-# inline ensure# #-}
withEnsure :: Int -> ParserT st e r -> ParserT st e r
withEnsure :: forall (st :: ZeroBitType) e a.
Int -> ParserT st e a -> ParserT st e a
withEnsure = forall r. (Int# -> r) -> Int -> r
Common.withIntUnwrap# forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
withEnsure#
{-# inline withEnsure #-}
withEnsure1 :: ParserT st e r -> ParserT st e r
withEnsure1 :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e a
withEnsure1 (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
p) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob Addr#
s of
Int#
0# -> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
p ForeignPtrContents
fp Addr#
eob Addr#
s st
st
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline withEnsure1 #-}
withEnsure# :: Int# -> ParserT st e r -> ParserT st e r
withEnsure# :: forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
withEnsure# Int#
n# (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
p) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
case Int#
n# Int# -> Int# -> Int#
<=# Addr# -> Addr# -> Int#
minusAddr# Addr#
eob Addr#
s of
Int#
1# -> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
p ForeignPtrContents
fp Addr#
eob Addr#
s st
st
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline withEnsure# #-}
take :: Int -> ParserT st e B.ByteString
take :: forall (st :: ZeroBitType) e. Int -> ParserT st e ByteString
take (I# Int#
n#) = forall (st :: ZeroBitType) e. Int# -> ParserT st e ByteString
take# Int#
n#
{-# inline take #-}
take# :: Int# -> ParserT st e B.ByteString
take# :: forall (st :: ZeroBitType) e. Int# -> ParserT st e ByteString
take# Int#
n# = forall r. Int# -> r -> r
Common.withPosInt# Int#
n# (forall (st :: ZeroBitType) e. Int# -> ParserT st e ByteString
takeUnsafe# Int#
n#)
{-# inline take# #-}
takeUnsafe# :: Int# -> ParserT st e B.ByteString
takeUnsafe# :: forall (st :: ZeroBitType) e. Int# -> ParserT st e ByteString
takeUnsafe# Int#
n# = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
case Int#
n# Int# -> Int# -> Int#
<=# Addr# -> Addr# -> Int#
minusAddr# Addr#
eob Addr#
s of
Int#
1# -> forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st (ForeignPtr Word8 -> Int -> Int -> ByteString
B.PS (forall a. Addr# -> ForeignPtrContents -> ForeignPtr a
ForeignPtr Addr#
s ForeignPtrContents
fp) Int
0 (Int# -> Int
I# Int#
n#)) (Addr# -> Int# -> Addr#
plusAddr# Addr#
s Int#
n#)
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline takeUnsafe# #-}
takeRest :: ParserT st e B.ByteString
takeRest :: forall (st :: ZeroBitType) e. ParserT st e ByteString
takeRest = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
let n# :: Int#
n# = Addr# -> Addr# -> Int#
minusAddr# Addr#
eob Addr#
s
in forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st (ForeignPtr Word8 -> Int -> Int -> ByteString
B.PS (forall a. Addr# -> ForeignPtrContents -> ForeignPtr a
ForeignPtr Addr#
s ForeignPtrContents
fp) Int
0 (Int# -> Int
I# Int#
n#)) Addr#
eob
{-# inline takeRest #-}
skip :: Int -> ParserT st e ()
skip :: forall (st :: ZeroBitType) e. Int -> ParserT st e ()
skip (I# Int#
n#) = forall (st :: ZeroBitType) e. Int# -> ParserT st e ()
skip# Int#
n#
{-# inline skip #-}
skip# :: Int# -> ParserT st e ()
skip# :: forall (st :: ZeroBitType) e. Int# -> ParserT st e ()
skip# Int#
n# = forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
atSkip# Int#
n# (forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
{-# inline skip# #-}
skipBack :: Int -> ParserT st e ()
skipBack :: forall (st :: ZeroBitType) e. Int -> ParserT st e ()
skipBack = forall r. (Int# -> r) -> Int -> r
Common.withIntUnwrap# forall (st :: ZeroBitType) e. Int# -> ParserT st e ()
skipBack#
{-# inline skipBack #-}
skipBack# :: Int# -> ParserT st e ()
skipBack# :: forall (st :: ZeroBitType) e. Int# -> ParserT st e ()
skipBack# Int#
n# = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st () (Addr# -> Int# -> Addr#
plusAddr# Addr#
s (Int# -> Int#
negateInt# Int#
n#))
{-# inline skipBack# #-}
atSkip# :: Int# -> ParserT st e a -> ParserT st e a
atSkip# :: forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
atSkip# Int#
n# ParserT st e a
p = forall r. Int# -> r -> r
Common.withPosInt# Int#
n# (forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
atSkipUnsafe# Int#
n# ParserT st e a
p)
{-# inline atSkip# #-}
atSkipUnsafe# :: Int# -> ParserT st e r -> ParserT st e r
atSkipUnsafe# :: forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
atSkipUnsafe# Int#
n# (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
p) =
forall (st :: ZeroBitType) e a.
Int# -> ParserT st e a -> ParserT st e a
withEnsure# Int#
n# forall a b. (a -> b) -> a -> b
$ forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT \ForeignPtrContents
fp Addr#
eob Addr#
s st
st ->
ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e r
p ForeignPtrContents
fp Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
s Int#
n#) st
st
{-# inline atSkipUnsafe# #-}
skipMany :: ParserT st e a -> ParserT st e ()
skipMany :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e ()
skipMany (ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f) = forall (st :: ZeroBitType) e a.
(ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a)
-> ParserT st e a
ParserT ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e ()
go where
go :: ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e ()
go ForeignPtrContents
fp Addr#
eob Addr#
s st
st = case ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e a
f ForeignPtrContents
fp Addr#
eob Addr#
s st
st of
OK# st
st a
a Addr#
s -> ForeignPtrContents -> Addr# -> Addr# -> st -> Res# st e ()
go ForeignPtrContents
fp Addr#
eob Addr#
s st
st
Fail# st
st -> forall (st :: ZeroBitType) a e. st -> a -> Addr# -> Res# st e a
OK# st
st () Addr#
s
Err# st
st e
e -> forall (st :: ZeroBitType) e a. st -> e -> Res# st e a
Err# st
st e
e
{-# inline skipMany #-}
skipSome :: ParserT st e a -> ParserT st e ()
skipSome :: forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e ()
skipSome ParserT st e a
p = ParserT st e a
p forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> forall (st :: ZeroBitType) e a. ParserT st e a -> ParserT st e ()
skipMany ParserT st e a
p
{-# inline skipSome #-}