{-# LANGUAGE UnboxedTuples #-}
module FlatParse.Stateful.Text
(
char, string
, anyChar, skipAnyChar
, satisfy, skipSatisfy
, fusedSatisfy, skipFusedSatisfy
, takeLine
, takeRestString
, anyAsciiChar, skipAnyAsciiChar
, satisfyAscii, skipSatisfyAscii
, anyAsciiDecimalWord
, anyAsciiDecimalInt
, anyAsciiDecimalInteger
, anyAsciiHexWord
, anyAsciiHexInt
, traceLine
, traceRest
) where
import FlatParse.Stateful.Parser
import FlatParse.Stateful.Base ( withEnsure1, lookahead, eof, branch )
import FlatParse.Stateful.Bytes ( bytes )
import FlatParse.Common.GHCExts
import Language.Haskell.TH
import qualified FlatParse.Common.Numbers as Common
import qualified FlatParse.Common.Assorted as Common
anyChar :: ParserT st r e Char
anyChar :: forall (st :: ZeroBitType) r e. ParserT st r e Char
anyChar = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
buf Int#
n st
st -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob Addr#
buf of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Char#
Common.derefChar8# Addr#
buf of
Char#
c1 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\x7F'# of
Int#
1# -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Char# -> Char
C# Char#
c1) (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
1#) Int#
n
Int#
_ -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
1#) of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Int# -> Char#
indexCharOffAddr# Addr#
buf Int#
1# of
Char#
c2 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\xDF'# of
Int#
1# ->
let resc :: Int#
resc = ((Char# -> Int#
ord# Char#
c1 Int# -> Int# -> Int#
-# Int#
0xC0#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
6#) Int# -> Int# -> Int#
`orI#`
(Char# -> Int#
ord# Char#
c2 Int# -> Int# -> Int#
-# Int#
0x80#)
in forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Char# -> Char
C# (Int# -> Char#
chr# Int#
resc)) (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
2#) Int#
n
Int#
_ -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
2#) of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Int# -> Char#
indexCharOffAddr# Addr#
buf Int#
2# of
Char#
c3 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\xEF'# of
Int#
1# ->
let resc :: Int#
resc = ((Char# -> Int#
ord# Char#
c1 Int# -> Int# -> Int#
-# Int#
0xE0#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
12#) Int# -> Int# -> Int#
`orI#`
((Char# -> Int#
ord# Char#
c2 Int# -> Int# -> Int#
-# Int#
0x80#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
6#) Int# -> Int# -> Int#
`orI#`
(Char# -> Int#
ord# Char#
c3 Int# -> Int# -> Int#
-# Int#
0x80#)
in forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Char# -> Char
C# (Int# -> Char#
chr# Int#
resc)) (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
3#) Int#
n
Int#
_ -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
3#) of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Int# -> Char#
indexCharOffAddr# Addr#
buf Int#
3# of
Char#
c4 ->
let resc :: Int#
resc = ((Char# -> Int#
ord# Char#
c1 Int# -> Int# -> Int#
-# Int#
0xF0#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
18#) Int# -> Int# -> Int#
`orI#`
((Char# -> Int#
ord# Char#
c2 Int# -> Int# -> Int#
-# Int#
0x80#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
12#) Int# -> Int# -> Int#
`orI#`
((Char# -> Int#
ord# Char#
c3 Int# -> Int# -> Int#
-# Int#
0x80#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
6#) Int# -> Int# -> Int#
`orI#`
(Char# -> Int#
ord# Char#
c4 Int# -> Int# -> Int#
-# Int#
0x80#)
in forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Char# -> Char
C# (Int# -> Char#
chr# Int#
resc)) (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
4#) Int#
n
{-# inline anyChar #-}
skipAnyChar :: ParserT st r e ()
skipAnyChar :: forall (st :: ZeroBitType) r e. ParserT st r e ()
skipAnyChar = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
buf Int#
n st
st -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob Addr#
buf of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Char#
Common.derefChar8# Addr#
buf of
Char#
c1 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\x7F'# of
Int#
1# -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st () (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
1#) Int#
n
Int#
_ ->
let buf' :: Addr#
buf' =
case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\xDF'# of
Int#
1# -> Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
2#
Int#
_ -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\xEF'# of
Int#
1# -> Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
3#
Int#
_ -> Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
4#
in case Addr# -> Addr# -> Int#
leAddr# Addr#
buf' Addr#
eob of
Int#
1# -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st () Addr#
buf' Int#
n
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline skipAnyChar #-}
withSatisfy
:: (Char -> Bool) -> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfy :: forall (st :: ZeroBitType) r e ret.
(Char -> Bool)
-> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfy Char -> Bool
f Char -> ParserT st r e ret
p = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case forall (st :: ZeroBitType) r e a.
ParserT st r e a
-> ForeignPtrContents
-> r
-> Addr#
-> Addr#
-> Int#
-> st
-> Res# st e a
runParserT# forall (st :: ZeroBitType) r e. ParserT st r e Char
anyChar ForeignPtrContents
fp r
r Addr#
eob Addr#
s Int#
n st
st of
(# st
st, (# (# Char
c, Addr#
s, Int#
n #) | | #) #) | Char -> Bool
f Char
c -> forall (st :: ZeroBitType) r e a.
ParserT st r e a
-> ForeignPtrContents
-> r
-> Addr#
-> Addr#
-> Int#
-> st
-> Res# st e a
runParserT# (Char -> ParserT st r e ret
p Char
c) ForeignPtrContents
fp r
r Addr#
eob Addr#
s Int#
n st
st
(# st
st, ResI# Any Char
_ #) -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline withSatisfy #-}
satisfy :: (Char -> Bool) -> ParserT st r e Char
satisfy :: forall (st :: ZeroBitType) r e.
(Char -> Bool) -> ParserT st r e Char
satisfy Char -> Bool
f = forall (st :: ZeroBitType) r e ret.
(Char -> Bool)
-> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfy Char -> Bool
f forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# inline satisfy #-}
skipSatisfy :: (Char -> Bool) -> ParserT st r e ()
skipSatisfy :: forall (st :: ZeroBitType) r e. (Char -> Bool) -> ParserT st r e ()
skipSatisfy Char -> Bool
f = forall (st :: ZeroBitType) r e ret.
(Char -> Bool)
-> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfy Char -> Bool
f (\Char
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
{-# inline skipSatisfy #-}
withSatisfyAscii
:: (Char -> Bool) -> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfyAscii :: forall (st :: ZeroBitType) r e ret.
(Char -> Bool)
-> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfyAscii Char -> Bool
f Char -> ParserT st r e ret
p = forall (st :: ZeroBitType) r e ret.
ParserT st r e ret -> ParserT st r e ret
withEnsure1 forall a b. (a -> b) -> a -> b
$ forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case Addr# -> Char#
Common.derefChar8# Addr#
s of
Char#
c1 | Char -> Bool
f (Char# -> Char
C# Char#
c1) -> forall (st :: ZeroBitType) r e a.
ParserT st r e a
-> ForeignPtrContents
-> r
-> Addr#
-> Addr#
-> Int#
-> st
-> Res# st e a
runParserT# (Char -> ParserT st r e ret
p (Char# -> Char
C# Char#
c1)) ForeignPtrContents
fp r
r Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
s Int#
1#) Int#
n st
st
| Bool
otherwise -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline withSatisfyAscii #-}
satisfyAscii :: (Char -> Bool) -> ParserT st r e Char
satisfyAscii :: forall (st :: ZeroBitType) r e.
(Char -> Bool) -> ParserT st r e Char
satisfyAscii Char -> Bool
f = forall (st :: ZeroBitType) r e ret.
(Char -> Bool)
-> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfyAscii Char -> Bool
f forall (f :: * -> *) a. Applicative f => a -> f a
pure
{-# inline satisfyAscii #-}
skipSatisfyAscii :: (Char -> Bool) -> ParserT st r e ()
skipSatisfyAscii :: forall (st :: ZeroBitType) r e. (Char -> Bool) -> ParserT st r e ()
skipSatisfyAscii Char -> Bool
f = forall (st :: ZeroBitType) r e ret.
(Char -> Bool)
-> (Char -> ParserT st r e ret) -> ParserT st r e ret
withSatisfyAscii Char -> Bool
f (\Char
_ -> forall (f :: * -> *) a. Applicative f => a -> f a
pure ())
{-# inline skipSatisfyAscii #-}
fusedSatisfy :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> ParserT st r e Char
fusedSatisfy :: forall (st :: ZeroBitType) r e.
(Char -> Bool)
-> (Char -> Bool)
-> (Char -> Bool)
-> (Char -> Bool)
-> ParserT st r e Char
fusedSatisfy Char -> Bool
f1 Char -> Bool
f2 Char -> Bool
f3 Char -> Bool
f4 = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
buf Int#
n st
st ->
case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob Addr#
buf of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Char#
Common.derefChar8# Addr#
buf of
Char#
c1 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\x7F'# of
Int#
1# | Char -> Bool
f1 (Char# -> Char
C# Char#
c1) -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Char# -> Char
C# Char#
c1) (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
1#) Int#
n
| Bool
otherwise -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
1#) of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Int# -> Char#
indexCharOffAddr# Addr#
buf Int#
1# of
Char#
c2 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\xDF'# of
Int#
1# ->
let resc :: Char
resc = Char# -> Char
C# (Int# -> Char#
chr# (((Char# -> Int#
ord# Char#
c1 Int# -> Int# -> Int#
-# Int#
0xC0#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
6#) Int# -> Int# -> Int#
`orI#`
(Char# -> Int#
ord# Char#
c2 Int# -> Int# -> Int#
-# Int#
0x80#)))
in case Char -> Bool
f2 Char
resc of
Bool
True -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st Char
resc (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
2#) Int#
n
Bool
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
2#) of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Int# -> Char#
indexCharOffAddr# Addr#
buf Int#
2# of
Char#
c3 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\xEF'# of
Int#
1# ->
let resc :: Char
resc = Char# -> Char
C# (Int# -> Char#
chr# (((Char# -> Int#
ord# Char#
c1 Int# -> Int# -> Int#
-# Int#
0xE0#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
12#) Int# -> Int# -> Int#
`orI#`
((Char# -> Int#
ord# Char#
c2 Int# -> Int# -> Int#
-# Int#
0x80#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
6#) Int# -> Int# -> Int#
`orI#`
(Char# -> Int#
ord# Char#
c3 Int# -> Int# -> Int#
-# Int#
0x80#)))
in case Char -> Bool
f3 Char
resc of
Bool
True -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st Char
resc (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
3#) Int#
n
Bool
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Addr# -> Int#
eqAddr# Addr#
eob (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
3#) of
Int#
1# -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
Int#
_ -> case Addr# -> Int# -> Char#
indexCharOffAddr# Addr#
buf Int#
3# of
Char#
c4 ->
let resc :: Char
resc = Char# -> Char
C# (Int# -> Char#
chr# (((Char# -> Int#
ord# Char#
c1 Int# -> Int# -> Int#
-# Int#
0xF0#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
18#) Int# -> Int# -> Int#
`orI#`
((Char# -> Int#
ord# Char#
c2 Int# -> Int# -> Int#
-# Int#
0x80#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
12#) Int# -> Int# -> Int#
`orI#`
((Char# -> Int#
ord# Char#
c3 Int# -> Int# -> Int#
-# Int#
0x80#) Int# -> Int# -> Int#
`uncheckedIShiftL#` Int#
6#) Int# -> Int# -> Int#
`orI#`
(Char# -> Int#
ord# Char#
c4 Int# -> Int# -> Int#
-# Int#
0x80#)))
in case Char -> Bool
f4 Char
resc of
Bool
True -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st Char
resc (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
4#) Int#
n
Bool
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline fusedSatisfy #-}
skipFusedSatisfy :: (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> (Char -> Bool) -> ParserT st r e ()
skipFusedSatisfy :: forall (st :: ZeroBitType) r e.
(Char -> Bool)
-> (Char -> Bool)
-> (Char -> Bool)
-> (Char -> Bool)
-> ParserT st r e ()
skipFusedSatisfy Char -> Bool
f1 Char -> Bool
f2 Char -> Bool
f3 Char -> Bool
f4 = () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (st :: ZeroBitType) r e.
(Char -> Bool)
-> (Char -> Bool)
-> (Char -> Bool)
-> (Char -> Bool)
-> ParserT st r e Char
fusedSatisfy Char -> Bool
f1 Char -> Bool
f2 Char -> Bool
f3 Char -> Bool
f4
{-# inline skipFusedSatisfy #-}
anyAsciiDecimalWord :: ParserT st r e Word
anyAsciiDecimalWord :: forall (st :: ZeroBitType) r e. ParserT st r e Word
anyAsciiDecimalWord = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case Addr# -> Addr# -> (# (# #) | (# Word#, Addr# #) #)
Common.anyAsciiDecimalWord# Addr#
eob Addr#
s of
(# | (# Word#
w, Addr#
s' #) #) -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Word# -> Word
W# Word#
w) Addr#
s' Int#
n
(# (##) | #) -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline anyAsciiDecimalWord #-}
anyAsciiDecimalInt :: ParserT st r e Int
anyAsciiDecimalInt :: forall (st :: ZeroBitType) r e. ParserT st r e Int
anyAsciiDecimalInt = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case Addr# -> Addr# -> (# (# #) | (# Int#, Addr# #) #)
Common.anyAsciiDecimalInt# Addr#
eob Addr#
s of
(# | (# Int#
i, Addr#
s' #) #) -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Int# -> Int
I# Int#
i) Addr#
s' Int#
n
(# (##) | #) -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline anyAsciiDecimalInt #-}
anyAsciiDecimalInteger :: ParserT st r e Integer
anyAsciiDecimalInteger :: forall (st :: ZeroBitType) r e. ParserT st r e Integer
anyAsciiDecimalInteger = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case ForeignPtrContents
-> Addr# -> Addr# -> (# (# #) | (# Integer, Addr# #) #)
Common.anyAsciiDecimalInteger# ForeignPtrContents
fp Addr#
eob Addr#
s of
(# | (# Integer
i, Addr#
s' #) #) -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st Integer
i Addr#
s' Int#
n
(# (##) | #) -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline anyAsciiDecimalInteger #-}
anyAsciiHexWord :: ParserT st r e Word
anyAsciiHexWord :: forall (st :: ZeroBitType) r e. ParserT st r e Word
anyAsciiHexWord = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case Addr# -> Addr# -> (# (# #) | (# Word#, Addr# #) #)
Common.anyAsciiHexWord# Addr#
eob Addr#
s of
(# | (# Word#
w, Addr#
s' #) #) -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Word# -> Word
W# Word#
w) Addr#
s' Int#
n
(# (##) | #) -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline anyAsciiHexWord #-}
anyAsciiHexInt :: ParserT st r e Int
anyAsciiHexInt :: forall (st :: ZeroBitType) r e. ParserT st r e Int
anyAsciiHexInt = forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
s Int#
n st
st ->
case Addr# -> Addr# -> (# (# #) | (# Int#, Addr# #) #)
Common.anyAsciiHexInt# Addr#
eob Addr#
s of
(# | (# Int#
i, Addr#
s' #) #) -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Int# -> Int
I# Int#
i) Addr#
s' Int#
n
(# (##) | #) -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline anyAsciiHexInt #-}
anyAsciiChar :: ParserT st r e Char
anyAsciiChar :: forall (st :: ZeroBitType) r e. ParserT st r e Char
anyAsciiChar = forall (st :: ZeroBitType) r e ret.
ParserT st r e ret -> ParserT st r e ret
withEnsure1 forall a b. (a -> b) -> a -> b
$ forall (st :: ZeroBitType) r e a.
(ForeignPtrContents
-> r -> Addr# -> Addr# -> Int# -> st -> Res# st e a)
-> ParserT st r e a
ParserT \ForeignPtrContents
fp !r
r Addr#
eob Addr#
buf Int#
n st
st ->
case Addr# -> Char#
Common.derefChar8# Addr#
buf of
Char#
c1 -> case Char#
c1 Char# -> Char# -> Int#
`leChar#` Char#
'\x7F'# of
Int#
1# -> forall (st :: ZeroBitType) a e.
st -> a -> Addr# -> Int# -> Res# st e a
OK# st
st (Char# -> Char
C# Char#
c1) (Addr# -> Int# -> Addr#
plusAddr# Addr#
buf Int#
1#) Int#
n
Int#
_ -> forall (st :: ZeroBitType) e a. st -> Res# st e a
Fail# st
st
{-# inline anyAsciiChar #-}
skipAnyAsciiChar :: ParserT st r e ()
skipAnyAsciiChar :: forall (st :: ZeroBitType) r e. ParserT st r e ()
skipAnyAsciiChar = () forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ forall (st :: ZeroBitType) r e. ParserT st r e Char
anyAsciiChar
{-# inline skipAnyAsciiChar #-}
char :: Char -> Q Exp
char :: Char -> Q Exp
char Char
c = String -> Q Exp
string [Char
c]
string :: String -> Q Exp
string :: String -> Q Exp
string String
str = [Word] -> Q Exp
bytes (String -> [Word]
Common.strToBytes String
str)
takeLine :: ParserT st r e String
takeLine :: forall (st :: ZeroBitType) r e. ParserT st r e String
takeLine = forall (st :: ZeroBitType) r e a b.
ParserT st r e a
-> ParserT st r e b -> ParserT st r e b -> ParserT st r e b
branch forall (st :: ZeroBitType) r e. ParserT st r e ()
eof (forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"") do
Char
c <- forall (st :: ZeroBitType) r e. ParserT st r e Char
anyChar
case Char
c of
Char
'\n' -> forall (f :: * -> *) a. Applicative f => a -> f a
pure String
""
Char
_ -> (Char
cforall a. a -> [a] -> [a]
:) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> forall (st :: ZeroBitType) r e. ParserT st r e String
takeLine
traceLine :: ParserT st r e String
traceLine :: forall (st :: ZeroBitType) r e. ParserT st r e String
traceLine = forall (st :: ZeroBitType) r e ret.
ParserT st r e ret -> ParserT st r e ret
lookahead forall (st :: ZeroBitType) r e. ParserT st r e String
takeLine
takeRestString :: ParserT st r e String
takeRestString :: forall (st :: ZeroBitType) r e. ParserT st r e String
takeRestString = forall (st :: ZeroBitType) r e a b.
ParserT st r e a
-> ParserT st r e b -> ParserT st r e b -> ParserT st r e b
branch forall (st :: ZeroBitType) r e. ParserT st r e ()
eof (forall (f :: * -> *) a. Applicative f => a -> f a
pure String
"") do
Char
c <- forall (st :: ZeroBitType) r e. ParserT st r e Char
anyChar
String
cs <- forall (st :: ZeroBitType) r e. ParserT st r e String
takeRestString
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Char
cforall a. a -> [a] -> [a]
:String
cs)
traceRest :: ParserT st r e String
traceRest :: forall (st :: ZeroBitType) r e. ParserT st r e String
traceRest = forall (st :: ZeroBitType) r e ret.
ParserT st r e ret -> ParserT st r e ret
lookahead forall (st :: ZeroBitType) r e. ParserT st r e String
takeRestString