{-# LANGUAGE Safe #-}
{-# LANGUAGE OverloadedLists #-}
{-# OPTIONS_GHC -Wno-all-missed-specialisations -Wno-overflowed-literals #-}
module Text.Gigaparsec.Char (
char, item, satisfy, satisfyMap,
oneOf, noneOf,
string, stringOfMany, stringOfSome, strings, trie,
bit, crlf, digit, endOfLine, hexDigit, letter, letterOrDigit, lower, newline, octDigit, space,
tab, upper, whitespace,
spaces, whitespaces,
) where
import Text.Gigaparsec (Parsec, atomic, empty, some, many, (<|>))
import Text.Gigaparsec.Combinator (skipMany)
import Text.Gigaparsec.Errors.Combinator ((<?>))
import Text.Gigaparsec.Internal qualified as Internal (Parsec(Parsec, unParsec), State(..), expectedErr, useHints)
import Text.Gigaparsec.Internal.Errors qualified as Internal (ExpectItem(ExpectRaw), Error)
import Text.Gigaparsec.Internal.Require (require)
import Data.Bits (Bits((.&.), (.|.)))
import Data.Char (ord)
import Data.Char qualified as Char
import Data.List.NonEmpty as NonEmpty (NonEmpty((:|)), groupWith, sortWith)
import Data.Maybe (isJust, fromJust)
import Data.Monoid (Alt(Alt, getAlt))
import Data.Set (Set)
import Data.Set qualified as Set (empty, member, size, findMin, findMax, mapMonotonic, singleton)
import Data.Map (Map)
import Data.Map qualified as Map (fromSet, toAscList, member)
_satisfy :: Set Internal.ExpectItem -> (Char -> Bool) -> Parsec Char
_satisfy :: Set ExpectItem -> (Char -> Bool) -> Parsec Char
_satisfy Set ExpectItem
expecteds Char -> Bool
test = (forall r.
State
-> (Char -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec Char
forall a.
(forall r.
State -> (a -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec a
Internal.Parsec ((forall r.
State
-> (Char -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec Char)
-> (forall r.
State
-> (Char -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec Char
forall a b. (a -> b) -> a -> b
$ \State
st Char -> State -> RT r
ok Error -> State -> RT r
bad ->
case State -> String
Internal.input State
st of
Char
c:String
cs | Char -> Bool
test Char
c -> Char -> State -> RT r
ok Char
c (State -> Char -> String -> State
updateState State
st Char
c String
cs)
String
_ -> (Error -> State -> RT r) -> Error -> State -> RT r
forall r. (Error -> State -> RT r) -> Error -> State -> RT r
Internal.useHints Error -> State -> RT r
bad (State -> Set ExpectItem -> Word -> Error
Internal.expectedErr State
st Set ExpectItem
expecteds Word
1) State
st
where
updateState :: State -> Char -> String -> State
updateState State
st Char
'\n' String
cs = State
st
{ Internal.line = Internal.line st + 1, Internal.col = 1,
Internal.input = cs, Internal.consumed = Internal.consumed st + 1 }
updateState State
st Char
'\t' String
cs = State
st
{ Internal.col = ((Internal.col st + 3) .&. (-4)) .|. 1,
Internal.input = cs, Internal.consumed = Internal.consumed st + 1 }
updateState State
st Char
_ String
cs = State
st
{ Internal.col = Internal.col st + 1,
Internal.input = cs, Internal.consumed = Internal.consumed st + 1 }
satisfy :: (Char -> Bool)
-> Parsec Char
satisfy :: (Char -> Bool) -> Parsec Char
satisfy = Set ExpectItem -> (Char -> Bool) -> Parsec Char
_satisfy Set ExpectItem
forall a. Set a
Set.empty
char :: Char
-> Parsec Char
char :: Char -> Parsec Char
char Char
c = Set ExpectItem -> (Char -> Bool) -> Parsec Char
_satisfy (ExpectItem -> Set ExpectItem
forall a. a -> Set a
Set.singleton (String -> ExpectItem
Internal.ExpectRaw (Char -> String
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Char
c))) (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
c)
string :: String
-> Parsec String
string :: String -> Parsec String
string String
s = Bool -> String -> String -> Parsec String -> Parsec String
forall a. Bool -> String -> String -> a -> a
require (Bool -> Bool
not (String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
s)) String
"Text.Gigaparsec.Char.string" String
"cannot pass empty string" (Parsec String -> Parsec String) -> Parsec String -> Parsec String
forall a b. (a -> b) -> a -> b
$
(forall r.
State
-> (String -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec String
forall a.
(forall r.
State -> (a -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec a
Internal.Parsec ((forall r.
State
-> (String -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec String)
-> (forall r.
State
-> (String -> State -> RT r) -> (Error -> State -> RT r) -> RT r)
-> Parsec String
forall a b. (a -> b) -> a -> b
$ \State
st String -> State -> RT r
ok Error -> State -> RT r
bad ->
let bad' :: Error -> State -> RT r
bad' (Error
_ :: Internal.Error) =
(Error -> State -> RT r) -> Error -> State -> RT r
forall r. (Error -> State -> RT r) -> Error -> State -> RT r
Internal.useHints Error -> State -> RT r
bad (State -> Set ExpectItem -> Word -> Error
Internal.expectedErr State
st [String -> ExpectItem
Internal.ExpectRaw String
s]
(Int -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length String
s)))
in Parsec String
-> forall r.
State
-> (String -> State -> RT r) -> (Error -> State -> RT r) -> RT r
forall a.
Parsec a
-> forall r.
State -> (a -> State -> RT r) -> (Error -> State -> RT r) -> RT r
Internal.unParsec ((Char -> Parsec Char) -> String -> Parsec String
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse Char -> Parsec Char
char String
s) State
st String -> State -> RT r
ok Error -> State -> RT r
bad'
satisfyMap :: (Char -> Maybe a)
-> Parsec a
satisfyMap :: forall a. (Char -> Maybe a) -> Parsec a
satisfyMap Char -> Maybe a
f = Maybe a -> a
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe a -> a) -> (Char -> Maybe a) -> Char -> a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Maybe a
f (Char -> a) -> Parsec Char -> Parsec a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Char -> Bool) -> Parsec Char
satisfy (Maybe a -> Bool
forall a. Maybe a -> Bool
isJust (Maybe a -> Bool) -> (Char -> Maybe a) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Maybe a
f)
oneOf :: Set Char
-> Parsec Char
oneOf :: Set Char -> Parsec Char
oneOf Set Char
cs
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Parsec Char
forall a. Parsec a
forall (f :: * -> *) a. Alternative f => f a
empty
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 = Char -> Parsec Char
char Char
c1
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== (Char -> Int
ord Char
c2 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Char -> Int
ord Char
c1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) = (Char -> Bool) -> Parsec Char
satisfy (\Char
c -> Char
c1 Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
c Bool -> Bool -> Bool
&& Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
c2) Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
rangeLabel]
| Bool
otherwise = (Char -> Bool) -> Parsec Char
satisfy (Char -> Set Char -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Char
cs) Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> (Char -> String) -> Set Char -> Set String
forall a b. (a -> b) -> Set a -> Set b
Set.mapMonotonic (String -> String
forall a. Show a => a -> String
show (String -> String) -> (Char -> String) -> Char -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> String -> String
forall a. a -> [a] -> [a]
: [])) Set Char
cs
where !sz :: Int
sz = Set Char -> Int
forall a. Set a -> Int
Set.size Set Char
cs
c1 :: Char
c1 = Set Char -> Char
forall a. Set a -> a
Set.findMin Set Char
cs
c2 :: Char
c2 = Set Char -> Char
forall a. Set a -> a
Set.findMax Set Char
cs
rangeLabel :: String
rangeLabel = String
"one of " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show @String [Char
Item String
c1] String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" to " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show @String [Char
Item String
c2]
noneOf :: Set Char
-> Parsec Char
noneOf :: Set Char -> Parsec Char
noneOf Set Char
cs
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
0 = Parsec Char
item
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 = (Char -> Bool) -> Parsec Char
satisfy (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
c1) Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
"anything except " String -> String -> String
forall a. [a] -> [a] -> [a]
++ Char -> String
forall a. Show a => a -> String
show Char
c1]
| Int
sz Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== (Char -> Int
ord Char
c2 Int -> Int -> Int
forall a. Num a => a -> a -> a
- Char -> Int
ord Char
c1 Int -> Int -> Int
forall a. Num a => a -> a -> a
+ Int
1) = (Char -> Bool) -> Parsec Char
satisfy (\Char
c -> Char
c Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
< Char
c1 Bool -> Bool -> Bool
|| Char
c2 Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
< Char
c) Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
rangeLabel]
| Bool
otherwise = (Char -> Bool) -> Parsec Char
satisfy (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Char -> Set Char -> Bool
forall a. Ord a => a -> Set a -> Bool
`Set.member` Set Char
cs))
where !sz :: Int
sz = Set Char -> Int
forall a. Set a -> Int
Set.size Set Char
cs
c1 :: Char
c1 = Set Char -> Char
forall a. Set a -> a
Set.findMin Set Char
cs
c2 :: Char
c2 = Set Char -> Char
forall a. Set a -> a
Set.findMax Set Char
cs
rangeLabel :: String
rangeLabel = String
"anything outside of " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show @String [Char
Item String
c1] String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
" to " String -> String -> String
forall a. [a] -> [a] -> [a]
++ forall a. Show a => a -> String
show @String [Char
Item String
c2]
stringOfMany :: (Char -> Bool)
-> Parsec String
stringOfMany :: (Char -> Bool) -> Parsec String
stringOfMany Char -> Bool
p = Parsec Char -> Parsec String
forall a. Parsec a -> Parsec [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ((Char -> Bool) -> Parsec Char
satisfy Char -> Bool
p)
stringOfSome :: (Char -> Bool) -> Parsec String
stringOfSome :: (Char -> Bool) -> Parsec String
stringOfSome Char -> Bool
p = Parsec Char -> Parsec String
forall a. Parsec a -> Parsec [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some ((Char -> Bool) -> Parsec Char
satisfy Char -> Bool
p)
strings :: Set String
-> Parsec String
strings :: Set String -> Parsec String
strings = String -> Map String (Parsec String) -> Parsec String
forall a. String -> Map String (Parsec a) -> Parsec a
_trie String
"Text.Gigaparsec.Char.strings" (Map String (Parsec String) -> Parsec String)
-> (Set String -> Map String (Parsec String))
-> Set String
-> Parsec String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Parsec String)
-> Set String -> Map String (Parsec String)
forall k a. (k -> a) -> Set k -> Map k a
Map.fromSet String -> Parsec String
forall a. a -> Parsec a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
trie :: Map String (Parsec a)
-> Parsec a
trie :: forall a. Map String (Parsec a) -> Parsec a
trie = String -> Map String (Parsec a) -> Parsec a
forall a. String -> Map String (Parsec a) -> Parsec a
_trie String
"Text.Gigaparsec.Char.trie"
_trie :: String -> Map String (Parsec a) -> Parsec a
_trie :: forall a. String -> Map String (Parsec a) -> Parsec a
_trie String
func Map String (Parsec a)
strs = Bool -> String -> String -> Parsec a -> Parsec a
forall a. Bool -> String -> String -> a -> a
require (Bool -> Bool
not (String -> Map String (Parsec a) -> Bool
forall k a. Ord k => k -> Map k a -> Bool
Map.member String
"" Map String (Parsec a)
strs)) String
func String
"the empty string is not a valid key" (Parsec a -> Parsec a) -> Parsec a -> Parsec a
forall a b. (a -> b) -> a -> b
$
Alt Parsec a -> Parsec a
forall {k} (f :: k -> *) (a :: k). Alt f a -> f a
getAlt (Alt Parsec a -> Parsec a) -> Alt Parsec a -> Parsec a
forall a b. (a -> b) -> a -> b
$ (NonEmpty (String, Parsec a) -> Alt Parsec a)
-> [NonEmpty (String, Parsec a)] -> Alt Parsec a
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap NonEmpty (String, Parsec a) -> Alt Parsec a
forall a. NonEmpty (String, Parsec a) -> Alt Parsec a
combineSameLeading (((String, Parsec a) -> Char)
-> [(String, Parsec a)] -> [NonEmpty (String, Parsec a)]
forall (f :: * -> *) b a.
(Foldable f, Eq b) =>
(a -> b) -> f a -> [NonEmpty a]
NonEmpty.groupWith (String -> Char
forall a. HasCallStack => [a] -> a
head (String -> Char)
-> ((String, Parsec a) -> String) -> (String, Parsec a) -> Char
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, Parsec a) -> String
forall a b. (a, b) -> a
fst) (Map String (Parsec a) -> [(String, Parsec a)]
forall k a. Map k a -> [(k, a)]
Map.toAscList Map String (Parsec a)
strs))
where
combineSameLeading :: NonEmpty (String, Parsec a) -> Alt Parsec a
combineSameLeading :: forall a. NonEmpty (String, Parsec a) -> Alt Parsec a
combineSameLeading NonEmpty (String, Parsec a)
group = ((String, Parsec a) -> Alt Parsec a)
-> [(String, Parsec a)] -> Alt Parsec a
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (\(String
str, Parsec a
p) -> Parsec a -> Alt Parsec a
forall {k} (f :: k -> *) (a :: k). f a -> Alt f a
Alt (Parsec a -> Alt Parsec a) -> Parsec a -> Alt Parsec a
forall a b. (a -> b) -> a -> b
$ Parsec String -> Parsec String
forall a. Parsec a -> Parsec a
atomic (String -> Parsec String
string String
str) Parsec String -> Parsec a -> Parsec a
forall a b. Parsec a -> Parsec b -> Parsec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec a
p) ([(String, Parsec a)] -> [(String, Parsec a)]
forall a. [a] -> [a]
reverse [(String, Parsec a)]
rest)
Alt Parsec a -> Alt Parsec a -> Alt Parsec a
forall a. Alt Parsec a -> Alt Parsec a -> Alt Parsec a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parsec a -> Alt Parsec a
forall {k} (f :: k -> *) (a :: k). f a -> Alt f a
Alt (String -> Parsec String
string String
shortest Parsec String -> Parsec a -> Parsec a
forall a b. Parsec a -> Parsec b -> Parsec b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec a
shortP)
where (String
shortest, Parsec a
shortP) :| [(String, Parsec a)]
rest = ((String, Parsec a) -> Int)
-> NonEmpty (String, Parsec a) -> NonEmpty (String, Parsec a)
forall o a. Ord o => (a -> o) -> NonEmpty a -> NonEmpty a
NonEmpty.sortWith (String -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (String -> Int)
-> ((String, Parsec a) -> String) -> (String, Parsec a) -> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, Parsec a) -> String
forall a b. (a, b) -> a
fst) NonEmpty (String, Parsec a)
group
item :: Parsec Char
item :: Parsec Char
item = (Char -> Bool) -> Parsec Char
satisfy (Bool -> Char -> Bool
forall a b. a -> b -> a
const Bool
True) Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"any character"]
space :: Parsec Char
space :: Parsec Char
space = (Char -> Bool) -> Parsec Char
satisfy (\Char
c -> Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
' ' Bool -> Bool -> Bool
|| Char
c Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\t') Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"space", String
Item (Set String)
"tab"]
spaces :: Parsec ()
spaces :: Parsec ()
spaces = Parsec Char -> Parsec ()
forall a. Parsec a -> Parsec ()
skipMany Parsec Char
space
whitespace :: Parsec Char
whitespace :: Parsec Char
whitespace = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isSpace Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"whitespace"]
whitespaces :: Parsec ()
whitespaces :: Parsec ()
whitespaces = Parsec Char -> Parsec ()
forall a. Parsec a -> Parsec ()
skipMany Parsec Char
whitespace
newline :: Parsec Char
newline :: Parsec Char
newline = Char -> Parsec Char
char Char
'\n' Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"newline"]
crlf :: Parsec Char
crlf :: Parsec Char
crlf = Char
'\n' Char -> Parsec String -> Parsec Char
forall a b. a -> Parsec b -> Parsec a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Parsec String -> Parsec String
forall a. Parsec a -> Parsec a
atomic (String -> Parsec String
string String
"\r\n") Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"crlf"]
endOfLine :: Parsec Char
endOfLine :: Parsec Char
endOfLine = Parsec Char
newline Parsec Char -> Parsec Char -> Parsec Char
forall a. Parsec a -> Parsec a -> Parsec a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parsec Char
crlf Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"end of line"]
tab :: Parsec Char
tab :: Parsec Char
tab = Char -> Parsec Char
char Char
'\t' Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"tab"]
upper :: Parsec Char
upper :: Parsec Char
upper = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isUpper Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"uppercase letter"]
lower :: Parsec Char
lower :: Parsec Char
lower = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isLower Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"lowercase letter"]
letterOrDigit :: Parsec Char
letterOrDigit :: Parsec Char
letterOrDigit = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isAlphaNum Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"alpha-numeric character"]
letter :: Parsec Char
letter :: Parsec Char
letter = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isAlpha Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"letter"]
digit :: Parsec Char
digit :: Parsec Char
digit = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isDigit Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"digit"]
hexDigit :: Parsec Char
hexDigit :: Parsec Char
hexDigit = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isHexDigit Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"hexadecimal digit"]
octDigit :: Parsec Char
octDigit :: Parsec Char
octDigit = (Char -> Bool) -> Parsec Char
satisfy Char -> Bool
Char.isOctDigit Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"octal digit"]
bit :: Parsec Char
bit :: Parsec Char
bit = Set Char -> Parsec Char
oneOf [Char
Item (Set Char)
'0', Char
Item (Set Char)
'1'] Parsec Char -> Set String -> Parsec Char
forall a. Parsec a -> Set String -> Parsec a
<?> [String
Item (Set String)
"bit"]