{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE FlexibleContexts #-}
module Text.XML.Selectors.Parsers.JQ
( jq
, jqFile
, jqFile'
, jqString
, jqText
, jqString'
, jqText'
, errorBundlePretty
)
where
import Text.Megaparsec
import Text.Megaparsec.Char
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.IO as Text
import Text.XML.Selectors.Types
import Text.XML (Name)
import Data.String (IsString, fromString)
import Data.Char (isAlphaNum, isDigit)
jq :: (IsString (Tokens s), Stream s, Token s ~ Char)
=> String
-> s
-> Either (ParseErrorBundle s Text) Selector
jq :: String -> s -> Either (ParseErrorBundle s Text) Selector
jq = Parsec Text s Selector
-> String -> s -> Either (ParseErrorBundle s Text) Selector
forall e s a.
Parsec e s a -> String -> s -> Either (ParseErrorBundle s e) a
parse Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
jqSelector
jqString :: String
-> Either (ParseErrorBundle String Text) Selector
jqString :: String -> Either (ParseErrorBundle String Text) Selector
jqString = String -> String -> Either (ParseErrorBundle String Text) Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
String -> s -> Either (ParseErrorBundle s Text) Selector
jq String
"<input>"
jqString' :: String
-> Selector
jqString' :: String -> Selector
jqString' = (ParseErrorBundle String Text -> Selector)
-> (Selector -> Selector)
-> Either (ParseErrorBundle String Text) Selector
-> Selector
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> Selector
forall a. HasCallStack => String -> a
error (String -> Selector)
-> (ParseErrorBundle String Text -> String)
-> ParseErrorBundle String Text
-> Selector
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseErrorBundle String Text -> String
forall s e.
(VisualStream s, TraversableStream s, ShowErrorComponent e) =>
ParseErrorBundle s e -> String
errorBundlePretty) Selector -> Selector
forall a. a -> a
id (Either (ParseErrorBundle String Text) Selector -> Selector)
-> (String -> Either (ParseErrorBundle String Text) Selector)
-> String
-> Selector
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String -> Either (ParseErrorBundle String Text) Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
String -> s -> Either (ParseErrorBundle s Text) Selector
jq String
"<input>"
jqText :: Text
-> Either (ParseErrorBundle Text Text) Selector
jqText :: Text -> Either (ParseErrorBundle Text Text) Selector
jqText = String -> Text -> Either (ParseErrorBundle Text Text) Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
String -> s -> Either (ParseErrorBundle s Text) Selector
jq String
"<input>"
jqText' :: Text
-> Selector
jqText' :: Text -> Selector
jqText' = (ParseErrorBundle Text Text -> Selector)
-> (Selector -> Selector)
-> Either (ParseErrorBundle Text Text) Selector
-> Selector
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> Selector
forall a. HasCallStack => String -> a
error (String -> Selector)
-> (ParseErrorBundle Text Text -> String)
-> ParseErrorBundle Text Text
-> Selector
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseErrorBundle Text Text -> String
forall s e.
(VisualStream s, TraversableStream s, ShowErrorComponent e) =>
ParseErrorBundle s e -> String
errorBundlePretty) Selector -> Selector
forall a. a -> a
id (Either (ParseErrorBundle Text Text) Selector -> Selector)
-> (Text -> Either (ParseErrorBundle Text Text) Selector)
-> Text
-> Selector
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text -> Either (ParseErrorBundle Text Text) Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
String -> s -> Either (ParseErrorBundle s Text) Selector
jq String
"<input>"
jqFile :: FilePath
-> IO (Either (ParseErrorBundle Text Text) Selector)
jqFile :: String -> IO (Either (ParseErrorBundle Text Text) Selector)
jqFile String
fn = do
String -> Text -> Either (ParseErrorBundle Text Text) Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
String -> s -> Either (ParseErrorBundle s Text) Selector
jq String
fn (Text -> Either (ParseErrorBundle Text Text) Selector)
-> IO Text -> IO (Either (ParseErrorBundle Text Text) Selector)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String -> IO Text
Text.readFile String
fn
jqFile' :: FilePath
-> IO Selector
jqFile' :: String -> IO Selector
jqFile' String
fn =
String -> IO (Either (ParseErrorBundle Text Text) Selector)
jqFile String
fn IO (Either (ParseErrorBundle Text Text) Selector)
-> (Either (ParseErrorBundle Text Text) Selector -> IO Selector)
-> IO Selector
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ParseErrorBundle Text Text -> IO Selector)
-> (Selector -> IO Selector)
-> Either (ParseErrorBundle Text Text) Selector
-> IO Selector
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (String -> IO Selector
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> IO Selector)
-> (ParseErrorBundle Text Text -> String)
-> ParseErrorBundle Text Text
-> IO Selector
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseErrorBundle Text Text -> String
forall s e.
(VisualStream s, TraversableStream s, ShowErrorComponent e) =>
ParseErrorBundle s e -> String
errorBundlePretty) Selector -> IO Selector
forall (m :: * -> *) a. Monad m => a -> m a
return
instance ShowErrorComponent Text where
showErrorComponent :: Text -> String
showErrorComponent = Text -> String
Text.unpack
jqSelector :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
jqSelector :: Parsec Text s Selector
jqSelector = ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
choices Parsec Text s Selector
-> ParsecT Text s Identity () -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space Parsec Text s Selector
-> ParsecT Text s Identity () -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
choices :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
choices :: Parsec Text s Selector
choices = do
[Selector]
xs <- Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item Parsec Text s Selector
-> ParsecT Text s Identity Char
-> ParsecT Text s Identity [Selector]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
`sepBy` (ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
',' ParsecT Text s Identity Char
-> ParsecT Text s Identity () -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space)
case [Selector]
xs of
[] -> Selector -> Parsec Text s Selector
forall (m :: * -> *) a. Monad m => a -> m a
return Selector
None
[Selector
x] -> Selector -> Parsec Text s Selector
forall (m :: * -> *) a. Monad m => a -> m a
return Selector
x
[Selector]
_ -> Selector -> Parsec Text s Selector
forall (m :: * -> *) a. Monad m => a -> m a
return (Selector -> Parsec Text s Selector)
-> Selector -> Parsec Text s Selector
forall a b. (a -> b) -> a -> b
$ [Selector] -> Selector
Choice [Selector]
xs
item :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
item :: Parsec Text s Selector
item = do
Selector
what <- Selector -> Parsec Text s Selector -> Parsec Text s Selector
forall (m :: * -> *) a. Alternative m => a -> m a -> m a
option Selector
Any (Parsec Text s Selector
forall s. (Stream s, Token s ~ Char) => Parsec Text s Selector
anyElem Parsec Text s Selector
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parsec Text s Selector -> Parsec Text s Selector
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try Parsec Text s Selector
forall s. (Stream s, Token s ~ Char) => Parsec Text s Selector
elemName)
[Selector]
qualifiers <- Parsec Text s Selector -> ParsecT Text s Identity [Selector]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
qualifier
Maybe Selector
mcont <- Parsec Text s Selector -> ParsecT Text s Identity (Maybe Selector)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
continuation
let self :: Selector
self = [Selector] -> Selector
forall a. Monoid a => [a] -> a
mconcat (Selector
what Selector -> [Selector] -> [Selector]
forall a. a -> [a] -> [a]
: [Selector]
qualifiers)
case Maybe Selector
mcont of
Maybe Selector
Nothing -> Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Applicative f => a -> f a
pure Selector
self
Just Selector
cont -> Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Selector -> Parsec Text s Selector)
-> Selector -> Parsec Text s Selector
forall a b. (a -> b) -> a -> b
$ Selector
self Selector -> Selector -> Selector
forall a. Semigroup a => a -> a -> a
<> Selector
cont
anyElem :: (Stream s, Token s ~ Char) => Parsec Text s Selector
anyElem :: Parsec Text s Selector
anyElem = Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'*' ParsecT Text s Identity Char
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Applicative f => a -> f a
pure Selector
Any
elemName :: (Stream s, Token s ~ Char) => Parsec Text s Selector
elemName :: Parsec Text s Selector
elemName = Name -> Selector
Elem (Name -> Selector)
-> ParsecT Text s Identity Name -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text s Identity Name
forall n s.
(IsString n, Stream s, Token s ~ Char) =>
Parsec Text s n
name
name :: (IsString n, Stream s, Token s ~ Char) => Parsec Text s n
name :: Parsec Text s n
name = String -> n
forall a. IsString a => String -> a
fromString (String -> n) -> ParsecT Text s Identity String -> Parsec Text s n
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text s Identity Char -> ParsecT Text s Identity String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
some ParsecT Text s Identity Char
forall s. (Stream s, Token s ~ Char) => Parsec Text s Char
nameChar
nameChar :: (Stream s, Token s ~ Char) => Parsec Text s Char
nameChar :: Parsec Text s Char
nameChar = (Token s -> Bool) -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
MonadParsec e s m =>
(Token s -> Bool) -> m (Token s)
satisfy Char -> Bool
Token s -> Bool
isNameChar
isNameChar :: Char -> Bool
isNameChar :: Char -> Bool
isNameChar Char
c = Char -> Bool
isAlphaNum Char
c Bool -> Bool -> Bool
|| (Char
c Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [Char
'_', Char
'-'])
continuation :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
continuation :: Parsec Text s Selector
continuation = [Parsec Text s Selector] -> Parsec Text s Selector
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
child
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
sibling
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
nextSibling
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
descendant
]
descendant :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
descendant :: Parsec Text s Selector
descendant = ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space1 ParsecT Text s Identity ()
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ((Selector
Descendant Selector -> Selector -> Selector
forall a. Semigroup a => a -> a -> a
<>) (Selector -> Selector)
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item)
child :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
child :: Parsec Text s Selector
child = ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'>' ParsecT Text s Identity Char
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space) ParsecT Text s Identity ()
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ((Selector
Child Selector -> Selector -> Selector
forall a. Semigroup a => a -> a -> a
<>) (Selector -> Selector)
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item)
sibling :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
sibling :: Parsec Text s Selector
sibling = ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'~' ParsecT Text s Identity Char
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space) ParsecT Text s Identity ()
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ((Selector
Sibling Selector -> Selector -> Selector
forall a. Semigroup a => a -> a -> a
<>) (Selector -> Selector)
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item)
nextSibling :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
nextSibling :: Parsec Text s Selector
nextSibling = ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'+' ParsecT Text s Identity Char
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space) ParsecT Text s Identity ()
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ((Selector
NextSibling Selector -> Selector -> Selector
forall a. Semigroup a => a -> a -> a
<>) (Selector -> Selector)
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item)
qualifier :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
qualifier :: Parsec Text s Selector
qualifier = [Parsec Text s Selector] -> Parsec Text s Selector
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Parsec Text s Selector
forall s. (Stream s, Token s ~ Char) => Parsec Text s Selector
classAttrib
, Parsec Text s Selector
forall s. (Stream s, Token s ~ Char) => Parsec Text s Selector
idAttrib
, Parsec Text s Selector
forall s. (Stream s, Token s ~ Char) => Parsec Text s Selector
attribSelector
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
firstChild
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
nthChild
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
nthLastChild
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
having
, Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
not_
]
classAttrib :: (Stream s, Token s ~ Char) => Parsec Text s Selector
classAttrib :: Parsec Text s Selector
classAttrib = do
Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'.'
Text
value <- Parsec Text s Text
forall n s.
(IsString n, Stream s, Token s ~ Char) =>
Parsec Text s n
name
Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Selector -> Parsec Text s Selector)
-> Selector -> Parsec Text s Selector
forall a b. (a -> b) -> a -> b
$ AttribSelector -> Selector
Attrib (Name -> Text -> AttribSelector
AttribContainsWord Name
"class" Text
value)
idAttrib :: (Stream s, Token s ~ Char) => Parsec Text s Selector
idAttrib :: Parsec Text s Selector
idAttrib = do
Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'#'
Text
value <- Parsec Text s Text
forall n s.
(IsString n, Stream s, Token s ~ Char) =>
Parsec Text s n
name
Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Selector -> Parsec Text s Selector)
-> Selector -> Parsec Text s Selector
forall a b. (a -> b) -> a -> b
$ AttribSelector -> Selector
Attrib (Name -> Text -> AttribSelector
AttribIs Name
"id" Text
value)
attribSelector :: (Stream s, Token s ~ Char) => Parsec Text s Selector
attribSelector :: Parsec Text s Selector
attribSelector = do
Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'['
Name
aname <- Parsec Text s Name
forall n s.
(IsString n, Stream s, Token s ~ Char) =>
Parsec Text s n
name
Maybe (Name -> Text -> AttribSelector)
mop <- ParsecT Text s Identity (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity (Maybe (Name -> Text -> AttribSelector))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Text s Identity (Name -> Text -> AttribSelector)
forall s.
(Stream s, Token s ~ Char) =>
Parsec Text s (Name -> Text -> AttribSelector)
attribOp
AttribSelector
asel <- case Maybe (Name -> Text -> AttribSelector)
mop of
Maybe (Name -> Text -> AttribSelector)
Nothing -> AttribSelector -> ParsecT Text s Identity AttribSelector
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AttribSelector -> ParsecT Text s Identity AttribSelector)
-> AttribSelector -> ParsecT Text s Identity AttribSelector
forall a b. (a -> b) -> a -> b
$ Name -> AttribSelector
AttribExists Name
aname
Just Name -> Text -> AttribSelector
op -> Name -> Text -> AttribSelector
op Name
aname (Text -> AttribSelector)
-> ParsecT Text s Identity Text
-> ParsecT Text s Identity AttribSelector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Text s Identity Text
forall n s.
(IsString n, Stream s, Token s ~ Char) =>
Parsec Text s n
quotedStr ParsecT Text s Identity Text
-> ParsecT Text s Identity Text -> ParsecT Text s Identity Text
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT Text s Identity Text
forall n s.
(IsString n, Stream s, Token s ~ Char) =>
Parsec Text s n
name)
Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
']'
Selector -> Parsec Text s Selector
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Selector -> Parsec Text s Selector)
-> Selector -> Parsec Text s Selector
forall a b. (a -> b) -> a -> b
$ AttribSelector -> Selector
Attrib AttribSelector
asel
attribOp :: (Stream s, Token s ~ Char) => Parsec Text s (Name -> Text -> AttribSelector)
attribOp :: Parsec Text s (Name -> Text -> AttribSelector)
attribOp = [Parsec Text s (Name -> Text -> AttribSelector)]
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Name -> Text -> AttribSelector
AttribIs (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
, Name -> Text -> AttribSelector
AttribIsNot (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'!' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
, Name -> Text -> AttribSelector
AttribStartsWith (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'^' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
, Name -> Text -> AttribSelector
AttribEndsWith (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'$' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
, Name -> Text -> AttribSelector
AttribContains (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'*' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
, Name -> Text -> AttribSelector
AttribContainsWord (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'~' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
, Name -> Text -> AttribSelector
AttribContainsPrefix (Name -> Text -> AttribSelector)
-> ParsecT Text s Identity Char
-> Parsec Text s (Name -> Text -> AttribSelector)
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'|' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'=')
]
quotedStr :: (IsString v, Stream s, Token s ~ Char) => Parsec Text s v
quotedStr :: Parsec Text s v
quotedStr = do
Char
quoteSym <- Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'"' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'\''
String
val <- ParsecT Text s Identity Char -> ParsecT Text s Identity String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many ((Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'\\' ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Token s -> Bool) -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
MonadParsec e s m =>
(Token s -> Bool) -> m (Token s)
satisfy (Bool -> Char -> Bool
forall a b. a -> b -> a
const Bool
True)) ParsecT Text s Identity Char
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((Token s -> Bool) -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
MonadParsec e s m =>
(Token s -> Bool) -> m (Token s)
satisfy (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
/= Char
quoteSym)))
Char
_ <- Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
quoteSym
v -> Parsec Text s v
forall (f :: * -> *) a. Applicative f => a -> f a
pure (v -> Parsec Text s v) -> v -> Parsec Text s v
forall a b. (a -> b) -> a -> b
$ String -> v
forall a. IsString a => String -> a
fromString String
val
firstChild :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
firstChild :: Parsec Text s Selector
firstChild = Selector
FirstChild Selector
-> ParsecT Text s Identity (Tokens s) -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Tokens s -> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens s
":first-child") Parsec Text s Selector
-> ParsecT Text s Identity () -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity Char -> ParsecT Text s Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ParsecT Text s Identity Char
forall s. (Stream s, Token s ~ Char) => Parsec Text s Char
nameChar
lastChild :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
lastChild :: Parsec Text s Selector
lastChild = Selector
LastChild Selector
-> ParsecT Text s Identity (Tokens s) -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Tokens s -> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens s
":last-child") Parsec Text s Selector
-> ParsecT Text s Identity () -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity Char -> ParsecT Text s Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ParsecT Text s Identity Char
forall s. (Stream s, Token s ~ Char) => Parsec Text s Char
nameChar
nthChild :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
nthChild :: Parsec Text s Selector
nthChild = do
Int -> Selector
NthChild (Int -> Selector)
-> ParsecT Text s Identity Int -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Tokens s -> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens s
":nth-child") ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'(' ParsecT Text s Identity Char
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Int -> ParsecT Text s Identity Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity Int
forall s. (Stream s, Token s ~ Char) => Parsec Text s Int
positiveInt ParsecT Text s Identity Int
-> ParsecT Text s Identity () -> ParsecT Text s Identity Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity Int
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
')')
nthLastChild :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
nthLastChild :: Parsec Text s Selector
nthLastChild = do
Int -> Selector
NthChild (Int -> Selector) -> (Int -> Int) -> Int -> Selector
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> Int
forall a. Num a => a -> a
negate (Int -> Selector)
-> ParsecT Text s Identity Int -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Tokens s -> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens s
":nth-last-child") ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'(' ParsecT Text s Identity Char
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Int -> ParsecT Text s Identity Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity Int
forall s. (Stream s, Token s ~ Char) => Parsec Text s Int
positiveInt ParsecT Text s Identity Int
-> ParsecT Text s Identity () -> ParsecT Text s Identity Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity Int
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Int
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
')')
positiveInt :: (Stream s, Token s ~ Char) => Parsec Text s Int
positiveInt :: Parsec Text s Int
positiveInt = String -> Int
forall a. Read a => String -> a
read (String -> Int)
-> ParsecT Text s Identity String -> Parsec Text s Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Text s Identity Char -> ParsecT Text s Identity String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
some ParsecT Text s Identity Char
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
digitChar
having :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
having :: Parsec Text s Selector
having = ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Tokens s -> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens s
":has") ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'(' ParsecT Text s Identity Char
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Selector -> Selector
Having (Selector -> Selector)
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item) Parsec Text s Selector
-> ParsecT Text s Identity Char -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
')'
not_ :: (IsString (Tokens s), Stream s, Token s ~ Char) => Parsec Text s Selector
not_ :: Parsec Text s Selector
not_ = ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Tokens s -> ParsecT Text s Identity (Tokens s)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens s
":not") ParsecT Text s Identity (Tokens s)
-> ParsecT Text s Identity () -> ParsecT Text s Identity ()
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Text s Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space ParsecT Text s Identity ()
-> ParsecT Text s Identity Char -> ParsecT Text s Identity Char
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
'(' ParsecT Text s Identity Char
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Selector -> Selector
Not (Selector -> Selector)
-> Parsec Text s Selector -> Parsec Text s Selector
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parsec Text s Selector
forall s.
(IsString (Tokens s), Stream s, Token s ~ Char) =>
Parsec Text s Selector
item) Parsec Text s Selector
-> ParsecT Text s Identity Char -> Parsec Text s Selector
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* Token s -> ParsecT Text s Identity (Token s)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token s
')'