{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeData #-}
{-# LANGUAGE TypeFamilies #-}
module Codec.CBOR.Cuddle.Parser where
import Codec.CBOR.Cuddle.CDDL
import Codec.CBOR.Cuddle.CDDL.CtlOp (CtlOp)
import Codec.CBOR.Cuddle.CDDL.CtlOp qualified as COp
import Codec.CBOR.Cuddle.Comments (
Comment,
HasComment (..),
WithComment (..),
withComment,
(!*>),
(//-),
(<*!),
)
import Codec.CBOR.Cuddle.Parser.Lexer (
Parser,
charInRange,
pCommentBlock,
space,
)
import Control.Applicative.Combinators.NonEmpty qualified as NE
import Data.ByteString.Base16 qualified as Base16
import Data.Foldable (Foldable (..))
import Data.Functor (void, ($>))
import Data.List.NonEmpty (NonEmpty (..))
import Data.List.NonEmpty qualified as NE
import Data.Maybe (isJust)
import Data.Text (Text)
import Data.Text qualified as T
import Data.Text.Encoding (encodeUtf8)
import Data.TreeDiff (ToExpr)
import Data.Void (Void)
import GHC.Generics (Generic)
import GHC.Word (Word64, Word8)
import Optics.Core ((&), (.~))
import Text.Megaparsec
import Text.Megaparsec.Char hiding (space)
import Text.Megaparsec.Char qualified as C
import Text.Megaparsec.Char.Lexer qualified as L
type data ParserStage
newtype instance XXTopLevel ParserStage = ParserXXTopLevel Comment
deriving ((forall x.
XXTopLevel ParserStage -> Rep (XXTopLevel ParserStage) x)
-> (forall x.
Rep (XXTopLevel ParserStage) x -> XXTopLevel ParserStage)
-> Generic (XXTopLevel ParserStage)
forall x. Rep (XXTopLevel ParserStage) x -> XXTopLevel ParserStage
forall x. XXTopLevel ParserStage -> Rep (XXTopLevel ParserStage) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. XXTopLevel ParserStage -> Rep (XXTopLevel ParserStage) x
from :: forall x. XXTopLevel ParserStage -> Rep (XXTopLevel ParserStage) x
$cto :: forall x. Rep (XXTopLevel ParserStage) x -> XXTopLevel ParserStage
to :: forall x. Rep (XXTopLevel ParserStage) x -> XXTopLevel ParserStage
Generic, Int -> XXTopLevel ParserStage -> ShowS
[XXTopLevel ParserStage] -> ShowS
XXTopLevel ParserStage -> String
(Int -> XXTopLevel ParserStage -> ShowS)
-> (XXTopLevel ParserStage -> String)
-> ([XXTopLevel ParserStage] -> ShowS)
-> Show (XXTopLevel ParserStage)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XXTopLevel ParserStage -> ShowS
showsPrec :: Int -> XXTopLevel ParserStage -> ShowS
$cshow :: XXTopLevel ParserStage -> String
show :: XXTopLevel ParserStage -> String
$cshowList :: [XXTopLevel ParserStage] -> ShowS
showList :: [XXTopLevel ParserStage] -> ShowS
Show, XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool
(XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool)
-> (XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool)
-> Eq (XXTopLevel ParserStage)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool
== :: XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool
$c/= :: XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool
/= :: XXTopLevel ParserStage -> XXTopLevel ParserStage -> Bool
Eq, [XXTopLevel ParserStage] -> Expr
XXTopLevel ParserStage -> Expr
(XXTopLevel ParserStage -> Expr)
-> ([XXTopLevel ParserStage] -> Expr)
-> ToExpr (XXTopLevel ParserStage)
forall a. (a -> Expr) -> ([a] -> Expr) -> ToExpr a
$ctoExpr :: XXTopLevel ParserStage -> Expr
toExpr :: XXTopLevel ParserStage -> Expr
$clistToExpr :: [XXTopLevel ParserStage] -> Expr
listToExpr :: [XXTopLevel ParserStage] -> Expr
ToExpr)
newtype instance XXType2 ParserStage = ParserXXType2 Void
deriving ((forall x. XXType2 ParserStage -> Rep (XXType2 ParserStage) x)
-> (forall x. Rep (XXType2 ParserStage) x -> XXType2 ParserStage)
-> Generic (XXType2 ParserStage)
forall x. Rep (XXType2 ParserStage) x -> XXType2 ParserStage
forall x. XXType2 ParserStage -> Rep (XXType2 ParserStage) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. XXType2 ParserStage -> Rep (XXType2 ParserStage) x
from :: forall x. XXType2 ParserStage -> Rep (XXType2 ParserStage) x
$cto :: forall x. Rep (XXType2 ParserStage) x -> XXType2 ParserStage
to :: forall x. Rep (XXType2 ParserStage) x -> XXType2 ParserStage
Generic, Int -> XXType2 ParserStage -> ShowS
[XXType2 ParserStage] -> ShowS
XXType2 ParserStage -> String
(Int -> XXType2 ParserStage -> ShowS)
-> (XXType2 ParserStage -> String)
-> ([XXType2 ParserStage] -> ShowS)
-> Show (XXType2 ParserStage)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XXType2 ParserStage -> ShowS
showsPrec :: Int -> XXType2 ParserStage -> ShowS
$cshow :: XXType2 ParserStage -> String
show :: XXType2 ParserStage -> String
$cshowList :: [XXType2 ParserStage] -> ShowS
showList :: [XXType2 ParserStage] -> ShowS
Show, XXType2 ParserStage -> XXType2 ParserStage -> Bool
(XXType2 ParserStage -> XXType2 ParserStage -> Bool)
-> (XXType2 ParserStage -> XXType2 ParserStage -> Bool)
-> Eq (XXType2 ParserStage)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XXType2 ParserStage -> XXType2 ParserStage -> Bool
== :: XXType2 ParserStage -> XXType2 ParserStage -> Bool
$c/= :: XXType2 ParserStage -> XXType2 ParserStage -> Bool
/= :: XXType2 ParserStage -> XXType2 ParserStage -> Bool
Eq, [XXType2 ParserStage] -> Expr
XXType2 ParserStage -> Expr
(XXType2 ParserStage -> Expr)
-> ([XXType2 ParserStage] -> Expr) -> ToExpr (XXType2 ParserStage)
forall a. (a -> Expr) -> ([a] -> Expr) -> ToExpr a
$ctoExpr :: XXType2 ParserStage -> Expr
toExpr :: XXType2 ParserStage -> Expr
$clistToExpr :: [XXType2 ParserStage] -> Expr
listToExpr :: [XXType2 ParserStage] -> Expr
ToExpr)
newtype instance XTerm ParserStage = ParserXTerm {XTerm ParserStage -> Comment
unParserXTerm :: Comment}
deriving ((forall x. XTerm ParserStage -> Rep (XTerm ParserStage) x)
-> (forall x. Rep (XTerm ParserStage) x -> XTerm ParserStage)
-> Generic (XTerm ParserStage)
forall x. Rep (XTerm ParserStage) x -> XTerm ParserStage
forall x. XTerm ParserStage -> Rep (XTerm ParserStage) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. XTerm ParserStage -> Rep (XTerm ParserStage) x
from :: forall x. XTerm ParserStage -> Rep (XTerm ParserStage) x
$cto :: forall x. Rep (XTerm ParserStage) x -> XTerm ParserStage
to :: forall x. Rep (XTerm ParserStage) x -> XTerm ParserStage
Generic, NonEmpty (XTerm ParserStage) -> XTerm ParserStage
XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage
(XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage)
-> (NonEmpty (XTerm ParserStage) -> XTerm ParserStage)
-> (forall b.
Integral b =>
b -> XTerm ParserStage -> XTerm ParserStage)
-> Semigroup (XTerm ParserStage)
forall b. Integral b => b -> XTerm ParserStage -> XTerm ParserStage
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage
<> :: XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage
$csconcat :: NonEmpty (XTerm ParserStage) -> XTerm ParserStage
sconcat :: NonEmpty (XTerm ParserStage) -> XTerm ParserStage
$cstimes :: forall b. Integral b => b -> XTerm ParserStage -> XTerm ParserStage
stimes :: forall b. Integral b => b -> XTerm ParserStage -> XTerm ParserStage
Semigroup, Semigroup (XTerm ParserStage)
XTerm ParserStage
Semigroup (XTerm ParserStage) =>
XTerm ParserStage
-> (XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage)
-> ([XTerm ParserStage] -> XTerm ParserStage)
-> Monoid (XTerm ParserStage)
[XTerm ParserStage] -> XTerm ParserStage
XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: XTerm ParserStage
mempty :: XTerm ParserStage
$cmappend :: XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage
mappend :: XTerm ParserStage -> XTerm ParserStage -> XTerm ParserStage
$cmconcat :: [XTerm ParserStage] -> XTerm ParserStage
mconcat :: [XTerm ParserStage] -> XTerm ParserStage
Monoid, Int -> XTerm ParserStage -> ShowS
[XTerm ParserStage] -> ShowS
XTerm ParserStage -> String
(Int -> XTerm ParserStage -> ShowS)
-> (XTerm ParserStage -> String)
-> ([XTerm ParserStage] -> ShowS)
-> Show (XTerm ParserStage)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XTerm ParserStage -> ShowS
showsPrec :: Int -> XTerm ParserStage -> ShowS
$cshow :: XTerm ParserStage -> String
show :: XTerm ParserStage -> String
$cshowList :: [XTerm ParserStage] -> ShowS
showList :: [XTerm ParserStage] -> ShowS
Show, XTerm ParserStage -> XTerm ParserStage -> Bool
(XTerm ParserStage -> XTerm ParserStage -> Bool)
-> (XTerm ParserStage -> XTerm ParserStage -> Bool)
-> Eq (XTerm ParserStage)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XTerm ParserStage -> XTerm ParserStage -> Bool
== :: XTerm ParserStage -> XTerm ParserStage -> Bool
$c/= :: XTerm ParserStage -> XTerm ParserStage -> Bool
/= :: XTerm ParserStage -> XTerm ParserStage -> Bool
Eq, [XTerm ParserStage] -> Expr
XTerm ParserStage -> Expr
(XTerm ParserStage -> Expr)
-> ([XTerm ParserStage] -> Expr) -> ToExpr (XTerm ParserStage)
forall a. (a -> Expr) -> ([a] -> Expr) -> ToExpr a
$ctoExpr :: XTerm ParserStage -> Expr
toExpr :: XTerm ParserStage -> Expr
$clistToExpr :: [XTerm ParserStage] -> Expr
listToExpr :: [XTerm ParserStage] -> Expr
ToExpr)
newtype instance XRule ParserStage = ParserXRule {XRule ParserStage -> Comment
unParserXRule :: Comment}
deriving ((forall x. XRule ParserStage -> Rep (XRule ParserStage) x)
-> (forall x. Rep (XRule ParserStage) x -> XRule ParserStage)
-> Generic (XRule ParserStage)
forall x. Rep (XRule ParserStage) x -> XRule ParserStage
forall x. XRule ParserStage -> Rep (XRule ParserStage) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. XRule ParserStage -> Rep (XRule ParserStage) x
from :: forall x. XRule ParserStage -> Rep (XRule ParserStage) x
$cto :: forall x. Rep (XRule ParserStage) x -> XRule ParserStage
to :: forall x. Rep (XRule ParserStage) x -> XRule ParserStage
Generic, NonEmpty (XRule ParserStage) -> XRule ParserStage
XRule ParserStage -> XRule ParserStage -> XRule ParserStage
(XRule ParserStage -> XRule ParserStage -> XRule ParserStage)
-> (NonEmpty (XRule ParserStage) -> XRule ParserStage)
-> (forall b.
Integral b =>
b -> XRule ParserStage -> XRule ParserStage)
-> Semigroup (XRule ParserStage)
forall b. Integral b => b -> XRule ParserStage -> XRule ParserStage
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: XRule ParserStage -> XRule ParserStage -> XRule ParserStage
<> :: XRule ParserStage -> XRule ParserStage -> XRule ParserStage
$csconcat :: NonEmpty (XRule ParserStage) -> XRule ParserStage
sconcat :: NonEmpty (XRule ParserStage) -> XRule ParserStage
$cstimes :: forall b. Integral b => b -> XRule ParserStage -> XRule ParserStage
stimes :: forall b. Integral b => b -> XRule ParserStage -> XRule ParserStage
Semigroup, Semigroup (XRule ParserStage)
XRule ParserStage
Semigroup (XRule ParserStage) =>
XRule ParserStage
-> (XRule ParserStage -> XRule ParserStage -> XRule ParserStage)
-> ([XRule ParserStage] -> XRule ParserStage)
-> Monoid (XRule ParserStage)
[XRule ParserStage] -> XRule ParserStage
XRule ParserStage -> XRule ParserStage -> XRule ParserStage
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: XRule ParserStage
mempty :: XRule ParserStage
$cmappend :: XRule ParserStage -> XRule ParserStage -> XRule ParserStage
mappend :: XRule ParserStage -> XRule ParserStage -> XRule ParserStage
$cmconcat :: [XRule ParserStage] -> XRule ParserStage
mconcat :: [XRule ParserStage] -> XRule ParserStage
Monoid, Int -> XRule ParserStage -> ShowS
[XRule ParserStage] -> ShowS
XRule ParserStage -> String
(Int -> XRule ParserStage -> ShowS)
-> (XRule ParserStage -> String)
-> ([XRule ParserStage] -> ShowS)
-> Show (XRule ParserStage)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XRule ParserStage -> ShowS
showsPrec :: Int -> XRule ParserStage -> ShowS
$cshow :: XRule ParserStage -> String
show :: XRule ParserStage -> String
$cshowList :: [XRule ParserStage] -> ShowS
showList :: [XRule ParserStage] -> ShowS
Show, XRule ParserStage -> XRule ParserStage -> Bool
(XRule ParserStage -> XRule ParserStage -> Bool)
-> (XRule ParserStage -> XRule ParserStage -> Bool)
-> Eq (XRule ParserStage)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XRule ParserStage -> XRule ParserStage -> Bool
== :: XRule ParserStage -> XRule ParserStage -> Bool
$c/= :: XRule ParserStage -> XRule ParserStage -> Bool
/= :: XRule ParserStage -> XRule ParserStage -> Bool
Eq, [XRule ParserStage] -> Expr
XRule ParserStage -> Expr
(XRule ParserStage -> Expr)
-> ([XRule ParserStage] -> Expr) -> ToExpr (XRule ParserStage)
forall a. (a -> Expr) -> ([a] -> Expr) -> ToExpr a
$ctoExpr :: XRule ParserStage -> Expr
toExpr :: XRule ParserStage -> Expr
$clistToExpr :: [XRule ParserStage] -> Expr
listToExpr :: [XRule ParserStage] -> Expr
ToExpr)
newtype instance XCddl ParserStage = ParserXCddl [Comment]
deriving ((forall x. XCddl ParserStage -> Rep (XCddl ParserStage) x)
-> (forall x. Rep (XCddl ParserStage) x -> XCddl ParserStage)
-> Generic (XCddl ParserStage)
forall x. Rep (XCddl ParserStage) x -> XCddl ParserStage
forall x. XCddl ParserStage -> Rep (XCddl ParserStage) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. XCddl ParserStage -> Rep (XCddl ParserStage) x
from :: forall x. XCddl ParserStage -> Rep (XCddl ParserStage) x
$cto :: forall x. Rep (XCddl ParserStage) x -> XCddl ParserStage
to :: forall x. Rep (XCddl ParserStage) x -> XCddl ParserStage
Generic, NonEmpty (XCddl ParserStage) -> XCddl ParserStage
XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage
(XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage)
-> (NonEmpty (XCddl ParserStage) -> XCddl ParserStage)
-> (forall b.
Integral b =>
b -> XCddl ParserStage -> XCddl ParserStage)
-> Semigroup (XCddl ParserStage)
forall b. Integral b => b -> XCddl ParserStage -> XCddl ParserStage
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage
<> :: XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage
$csconcat :: NonEmpty (XCddl ParserStage) -> XCddl ParserStage
sconcat :: NonEmpty (XCddl ParserStage) -> XCddl ParserStage
$cstimes :: forall b. Integral b => b -> XCddl ParserStage -> XCddl ParserStage
stimes :: forall b. Integral b => b -> XCddl ParserStage -> XCddl ParserStage
Semigroup, Semigroup (XCddl ParserStage)
XCddl ParserStage
Semigroup (XCddl ParserStage) =>
XCddl ParserStage
-> (XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage)
-> ([XCddl ParserStage] -> XCddl ParserStage)
-> Monoid (XCddl ParserStage)
[XCddl ParserStage] -> XCddl ParserStage
XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: XCddl ParserStage
mempty :: XCddl ParserStage
$cmappend :: XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage
mappend :: XCddl ParserStage -> XCddl ParserStage -> XCddl ParserStage
$cmconcat :: [XCddl ParserStage] -> XCddl ParserStage
mconcat :: [XCddl ParserStage] -> XCddl ParserStage
Monoid, Int -> XCddl ParserStage -> ShowS
[XCddl ParserStage] -> ShowS
XCddl ParserStage -> String
(Int -> XCddl ParserStage -> ShowS)
-> (XCddl ParserStage -> String)
-> ([XCddl ParserStage] -> ShowS)
-> Show (XCddl ParserStage)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> XCddl ParserStage -> ShowS
showsPrec :: Int -> XCddl ParserStage -> ShowS
$cshow :: XCddl ParserStage -> String
show :: XCddl ParserStage -> String
$cshowList :: [XCddl ParserStage] -> ShowS
showList :: [XCddl ParserStage] -> ShowS
Show, XCddl ParserStage -> XCddl ParserStage -> Bool
(XCddl ParserStage -> XCddl ParserStage -> Bool)
-> (XCddl ParserStage -> XCddl ParserStage -> Bool)
-> Eq (XCddl ParserStage)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: XCddl ParserStage -> XCddl ParserStage -> Bool
== :: XCddl ParserStage -> XCddl ParserStage -> Bool
$c/= :: XCddl ParserStage -> XCddl ParserStage -> Bool
/= :: XCddl ParserStage -> XCddl ParserStage -> Bool
Eq, [XCddl ParserStage] -> Expr
XCddl ParserStage -> Expr
(XCddl ParserStage -> Expr)
-> ([XCddl ParserStage] -> Expr) -> ToExpr (XCddl ParserStage)
forall a. (a -> Expr) -> ([a] -> Expr) -> ToExpr a
$ctoExpr :: XCddl ParserStage -> Expr
toExpr :: XCddl ParserStage -> Expr
$clistToExpr :: [XCddl ParserStage] -> Expr
listToExpr :: [XCddl ParserStage] -> Expr
ToExpr)
instance HasComment (XTerm ParserStage) where
commentL :: Lens' (XTerm ParserStage) Comment
commentL = Lens' (XTerm ParserStage) Comment
#unParserXTerm
instance HasComment (XRule ParserStage) where
commentL :: Lens' (XRule ParserStage) Comment
commentL = Lens' (XRule ParserStage) Comment
#unParserXRule
pCDDL :: Parser (CDDL ParserStage)
pCDDL :: Parser (CDDL ParserStage)
pCDDL = do
[Comment]
initialComments <- ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity [Comment]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many (ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a b. (a -> b) -> a -> b
$ ParsecT Void Text Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
C.space ParsecT Void Text Identity ()
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
pCommentBlock ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity ()
-> ParsecT Void Text Identity Comment
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity (Rule ParserStage)
-> ParsecT Void Text Identity ()
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ParsecT Void Text Identity (Rule ParserStage)
pRule)
Maybe Comment
initialRuleComment <- ParsecT Void Text Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
C.space ParsecT Void Text Identity ()
-> ParsecT Void Text Identity (Maybe Comment)
-> ParsecT Void Text Identity (Maybe Comment)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Maybe Comment)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Void Text Identity Comment
pCommentBlock
Rule ParserStage
initialRule <- ParsecT Void Text Identity (Rule ParserStage)
pRule
[TopLevel ParserStage]
cddlTail <- ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity [TopLevel ParserStage]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many (ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity [TopLevel ParserStage])
-> ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity [TopLevel ParserStage]
forall a b. (a -> b) -> a -> b
$ ParsecT Void Text Identity (TopLevel ParserStage)
pTopLevel ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity ()
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
C.space
ParsecT Void Text Identity ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof
ParsecT Void Text Identity ()
-> CDDL ParserStage -> Parser (CDDL ParserStage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Rule ParserStage
-> [TopLevel ParserStage]
-> [XXTopLevel ParserStage]
-> CDDL ParserStage
forall i. Rule i -> [TopLevel i] -> [XXTopLevel i] -> CDDL i
CDDL (Rule ParserStage
initialRule Rule ParserStage -> Comment -> Rule ParserStage
forall a. HasComment a => a -> Comment -> a
//- Maybe Comment -> Comment
forall m. Monoid m => Maybe m -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold Maybe Comment
initialRuleComment) [TopLevel ParserStage]
cddlTail (Comment -> XXTopLevel ParserStage
ParserXXTopLevel (Comment -> XXTopLevel ParserStage)
-> [Comment] -> [XXTopLevel ParserStage]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Comment]
initialComments)
pTopLevel :: Parser (TopLevel ParserStage)
pTopLevel :: ParsecT Void Text Identity (TopLevel ParserStage)
pTopLevel = ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Void Text Identity (TopLevel ParserStage)
tlRule ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity (TopLevel ParserStage)
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT Void Text Identity (TopLevel ParserStage)
tlComment
where
tlRule :: ParsecT Void Text Identity (TopLevel ParserStage)
tlRule = do
Maybe Comment
mCmt <- ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Maybe Comment)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Void Text Identity Comment
pCommentBlock
Rule ParserStage
rule <- ParsecT Void Text Identity (Rule ParserStage)
pRule
TopLevel ParserStage
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TopLevel ParserStage
-> ParsecT Void Text Identity (TopLevel ParserStage))
-> (Rule ParserStage -> TopLevel ParserStage)
-> Rule ParserStage
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rule ParserStage -> TopLevel ParserStage
forall i. Rule i -> TopLevel i
TopLevelRule (Rule ParserStage
-> ParsecT Void Text Identity (TopLevel ParserStage))
-> Rule ParserStage
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall a b. (a -> b) -> a -> b
$ Rule ParserStage
rule Rule ParserStage -> Comment -> Rule ParserStage
forall a. HasComment a => a -> Comment -> a
//- Maybe Comment -> Comment
forall m. Monoid m => Maybe m -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold Maybe Comment
mCmt
tlComment :: ParsecT Void Text Identity (TopLevel ParserStage)
tlComment = XXTopLevel ParserStage -> TopLevel ParserStage
forall i. XXTopLevel i -> TopLevel i
XXTopLevel (XXTopLevel ParserStage -> TopLevel ParserStage)
-> (Comment -> XXTopLevel ParserStage)
-> Comment
-> TopLevel ParserStage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Comment -> XXTopLevel ParserStage
ParserXXTopLevel (Comment -> TopLevel ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (TopLevel ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Comment
pCommentBlock
pRule :: Parser (Rule ParserStage)
pRule :: ParsecT Void Text Identity (Rule ParserStage)
pRule = do
Name
name <- Parser Name
pName
Maybe (GenericParameters ParserStage)
genericParam <- ParsecT Void Text Identity (GenericParameters ParserStage)
-> ParsecT
Void Text Identity (Maybe (GenericParameters ParserStage))
forall e s (f :: * -> *) a. MonadParsec e s f => f a -> f (Maybe a)
optcomp ParsecT Void Text Identity (GenericParameters ParserStage)
pGenericParameters
Comment
cmt <- ParsecT Void Text Identity Comment
space
(Assign
assign, TypeOrGroup ParserStage
typeOrGrp) <-
[ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)]
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
forall a b. (a -> b) -> a -> b
$
(,)
(Assign
-> TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity Assign
-> ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Assign
pAssignT
ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity Comment
-> ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Comment
space
ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity (TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Type0 ParserStage -> TypeOrGroup ParserStage
forall i. Type0 i -> TypeOrGroup i
TOGType (Type0 ParserStage -> TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
-> ParsecT Void Text Identity (TypeOrGroup ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity (Type0 ParserStage)
pType0 ParsecT Void Text Identity (TypeOrGroup ParserStage)
-> ParsecT Void Text Identity ()
-> ParsecT Void Text Identity (TypeOrGroup ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text -> ParsecT Void Text Identity ()
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> (ParsecT Void Text Identity Text
":" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT Void Text Identity Text
"=>")))
, (,) (Assign
-> TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity Assign
-> ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Assign
pAssignG ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity Comment
-> ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Comment
space ParsecT
Void
Text
Identity
(TypeOrGroup ParserStage -> (Assign, TypeOrGroup ParserStage))
-> ParsecT Void Text Identity (TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (Assign, TypeOrGroup ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (GroupEntry ParserStage -> TypeOrGroup ParserStage
forall i. GroupEntry i -> TypeOrGroup i
TOGGroup (GroupEntry ParserStage -> TypeOrGroup ParserStage)
-> ParsecT Void Text Identity (GroupEntry ParserStage)
-> ParsecT Void Text Identity (TypeOrGroup ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity (GroupEntry ParserStage)
pGrpEntry)
]
Rule ParserStage -> ParsecT Void Text Identity (Rule ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Rule ParserStage -> ParsecT Void Text Identity (Rule ParserStage))
-> Rule ParserStage
-> ParsecT Void Text Identity (Rule ParserStage)
forall a b. (a -> b) -> a -> b
$ Name
-> Maybe (GenericParameters ParserStage)
-> Assign
-> TypeOrGroup ParserStage
-> XRule ParserStage
-> Rule ParserStage
forall i.
Name
-> Maybe (GenericParameters i)
-> Assign
-> TypeOrGroup i
-> XRule i
-> Rule i
Rule Name
name Maybe (GenericParameters ParserStage)
genericParam Assign
assign TypeOrGroup ParserStage
typeOrGrp (Comment -> XRule ParserStage
ParserXRule Comment
cmt)
pName :: Parser Name
pName :: Parser Name
pName = String -> Parser Name -> Parser Name
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"name" (Parser Name -> Parser Name) -> Parser Name -> Parser Name
forall a b. (a -> b) -> a -> b
$ do
Char
fc <- ParsecT Void Text Identity Char
firstChar
String
rest <- ParsecT Void Text Identity Char
-> ParsecT Void Text Identity String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many ParsecT Void Text Identity Char
midChar
Name -> Parser Name
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Name -> Parser Name) -> Name -> Parser Name
forall a b. (a -> b) -> a -> b
$ Text -> Name
Name (Text -> Name) -> (String -> Text) -> String -> Name
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
T.pack (String -> Name) -> String -> Name
forall a b. (a -> b) -> a -> b
$ (Char
fc Char -> ShowS
forall a. a -> [a] -> [a]
: String
rest)
where
firstChar :: ParsecT Void Text Identity Char
firstChar = ParsecT Void Text Identity Char
ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
letterChar ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'@' ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'_' ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'$'
midChar :: ParsecT Void Text Identity Char
midChar =
ParsecT Void Text Identity Char
ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
alphaNumChar
ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'@'
ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'_'
ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'$'
ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'.' ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
-> ParsecT Void Text Identity Char
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'-') ParsecT Void Text Identity Char
-> ParsecT Void Text Identity () -> ParsecT Void Text Identity Char
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity () -> ParsecT Void Text Identity ()
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (ParsecT Void Text Identity ()
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m ()
space1 ParsecT Void Text Identity ()
-> ParsecT Void Text Identity () -> ParsecT Void Text Identity ()
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT Void Text Identity ()
forall e s (m :: * -> *). MonadParsec e s m => m ()
eof ParsecT Void Text Identity ()
-> ParsecT Void Text Identity () -> ParsecT Void Text Identity ()
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT Void Text Identity (Tokens Text)
-> ParsecT Void Text Identity ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void ParsecT Void Text Identity (Tokens Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Tokens s)
eol))
pAssignT :: Parser Assign
pAssignT :: ParsecT Void Text Identity Assign
pAssignT =
[ParsecT Void Text Identity Assign]
-> ParsecT Void Text Identity Assign
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Assign
AssignEq Assign
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Assign
forall a b.
a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Void Text Identity Text
"="
, Assign
AssignExt Assign
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Assign
forall a b.
a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Void Text Identity Text
"/="
]
pAssignG :: Parser Assign
pAssignG :: ParsecT Void Text Identity Assign
pAssignG =
[ParsecT Void Text Identity Assign]
-> ParsecT Void Text Identity Assign
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Assign
AssignEq Assign
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Assign
forall a b.
a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Void Text Identity Text
"="
, Assign
AssignExt Assign
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Assign
forall a b.
a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ ParsecT Void Text Identity Text
"//="
]
pGenericParameter :: Parser (GenericParameter ParserStage)
pGenericParameter :: Parser (GenericParameter ParserStage)
pGenericParameter = Name -> XTerm ParserStage -> GenericParameter ParserStage
forall i. Name -> XTerm i -> GenericParameter i
GenericParameter (Name -> XTerm ParserStage -> GenericParameter ParserStage)
-> Parser Name
-> ParsecT
Void
Text
Identity
(XTerm ParserStage -> GenericParameter ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Name
pName ParsecT
Void
Text
Identity
(XTerm ParserStage -> GenericParameter ParserStage)
-> ParsecT Void Text Identity (XTerm ParserStage)
-> Parser (GenericParameter ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> XTerm ParserStage -> ParsecT Void Text Identity (XTerm ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure XTerm ParserStage
forall a. Monoid a => a
mempty
pGenericParameters :: Parser (GenericParameters ParserStage)
pGenericParameters :: ParsecT Void Text Identity (GenericParameters ParserStage)
pGenericParameters =
NonEmpty (GenericParameter ParserStage)
-> GenericParameters ParserStage
forall i. NonEmpty (GenericParameter i) -> GenericParameters i
GenericParameters
(NonEmpty (GenericParameter ParserStage)
-> GenericParameters ParserStage)
-> ParsecT
Void Text Identity (NonEmpty (GenericParameter ParserStage))
-> ParsecT Void Text Identity (GenericParameters ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT
Void Text Identity (NonEmpty (GenericParameter ParserStage))
-> ParsecT
Void Text Identity (NonEmpty (GenericParameter ParserStage))
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between ParsecT Void Text Identity Text
"<" ParsecT Void Text Identity Text
">" (Parser (GenericParameter ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT
Void Text Identity (NonEmpty (GenericParameter ParserStage))
forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
NE.sepBy1 (ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> Parser (GenericParameter ParserStage)
-> Parser (GenericParameter ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> Parser (GenericParameter ParserStage)
pGenericParameter Parser (GenericParameter ParserStage)
-> ParsecT Void Text Identity Comment
-> Parser (GenericParameter ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space) ParsecT Void Text Identity Text
",")
pGenericArg :: Parser (GenericArg ParserStage)
pGenericArg :: Parser (GenericArg ParserStage)
pGenericArg =
NonEmpty (Type1 ParserStage) -> GenericArg ParserStage
forall i. NonEmpty (Type1 i) -> GenericArg i
GenericArg
(NonEmpty (Type1 ParserStage) -> GenericArg ParserStage)
-> ParsecT Void Text Identity (NonEmpty (Type1 ParserStage))
-> Parser (GenericArg ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (NonEmpty (Type1 ParserStage))
-> ParsecT Void Text Identity (NonEmpty (Type1 ParserStage))
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between ParsecT Void Text Identity Text
"<" ParsecT Void Text Identity Text
">" (ParsecT Void Text Identity (Type1 ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (NonEmpty (Type1 ParserStage))
forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
NE.sepBy1 (ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Type1 ParserStage)
-> ParsecT Void Text Identity (Type1 ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (Type1 ParserStage)
pType1 ParsecT Void Text Identity (Type1 ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Type1 ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space) ParsecT Void Text Identity Text
",")
pType0 :: Parser (Type0 ParserStage)
pType0 :: ParsecT Void Text Identity (Type0 ParserStage)
pType0 = NonEmpty (Type1 ParserStage) -> Type0 ParserStage
forall i. NonEmpty (Type1 i) -> Type0 i
Type0 (NonEmpty (Type1 ParserStage) -> Type0 ParserStage)
-> ParsecT Void Text Identity (NonEmpty (Type1 ParserStage))
-> ParsecT Void Text Identity (Type0 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity (Type1 ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (NonEmpty (Type1 ParserStage))
forall e s (m :: * -> *) a sep.
MonadParsec e s m =>
m a -> m sep -> m (NonEmpty a)
sepBy1' (ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Type1 ParserStage)
-> ParsecT Void Text Identity (Type1 ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (Type1 ParserStage)
pType1 ParsecT Void Text Identity (Type1 ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Type1 ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space) (ParsecT Void Text Identity Text -> ParsecT Void Text Identity Text
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Void Text Identity Text
"/")
pType1 :: Parser (Type1 ParserStage)
pType1 :: ParsecT Void Text Identity (Type1 ParserStage)
pType1 = do
Type2 ParserStage
v <- Parser (Type2 ParserStage)
pType2
Maybe (Comment, TyOp, Comment, Type2 ParserStage)
rest <- ParsecT
Void Text Identity (Comment, TyOp, Comment, Type2 ParserStage)
-> ParsecT
Void
Text
Identity
(Maybe (Comment, TyOp, Comment, Type2 ParserStage))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT
Void Text Identity (Comment, TyOp, Comment, Type2 ParserStage)
-> ParsecT
Void
Text
Identity
(Maybe (Comment, TyOp, Comment, Type2 ParserStage)))
-> ParsecT
Void Text Identity (Comment, TyOp, Comment, Type2 ParserStage)
-> ParsecT
Void
Text
Identity
(Maybe (Comment, TyOp, Comment, Type2 ParserStage))
forall a b. (a -> b) -> a -> b
$ do
(Comment
cmtFst, TyOp
tyOp) <- ParsecT Void Text Identity (Comment, TyOp)
-> ParsecT Void Text Identity (Comment, TyOp)
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Void Text Identity (Comment, TyOp)
-> ParsecT Void Text Identity (Comment, TyOp))
-> ParsecT Void Text Identity (Comment, TyOp)
-> ParsecT Void Text Identity (Comment, TyOp)
forall a b. (a -> b) -> a -> b
$ do
Comment
cmt <- ParsecT Void Text Identity Comment
space
TyOp
tyOp <- Parser TyOp
pTyOp
(Comment, TyOp) -> ParsecT Void Text Identity (Comment, TyOp)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Comment
cmt, TyOp
tyOp)
Comment
cmtSnd <- ParsecT Void Text Identity Comment
space
Type2 ParserStage
w <- Parser (Type2 ParserStage)
pType2
(Comment, TyOp, Comment, Type2 ParserStage)
-> ParsecT
Void Text Identity (Comment, TyOp, Comment, Type2 ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Comment
cmtFst, TyOp
tyOp, Comment
cmtSnd, Type2 ParserStage
w)
case Maybe (Comment, TyOp, Comment, Type2 ParserStage)
rest of
Just (Comment
cmtFst, TyOp
tyOp, Comment
cmtSnd, Type2 ParserStage
w) ->
Type1 ParserStage -> ParsecT Void Text Identity (Type1 ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Type1 ParserStage
-> ParsecT Void Text Identity (Type1 ParserStage))
-> Type1 ParserStage
-> ParsecT Void Text Identity (Type1 ParserStage)
forall a b. (a -> b) -> a -> b
$ Type2 ParserStage
-> Maybe (TyOp, Type2 ParserStage)
-> XTerm ParserStage
-> Type1 ParserStage
forall i. Type2 i -> Maybe (TyOp, Type2 i) -> XTerm i -> Type1 i
Type1 Type2 ParserStage
v ((TyOp, Type2 ParserStage) -> Maybe (TyOp, Type2 ParserStage)
forall a. a -> Maybe a
Just (TyOp
tyOp, Type2 ParserStage
w)) (XTerm ParserStage -> Type1 ParserStage)
-> (Comment -> XTerm ParserStage) -> Comment -> Type1 ParserStage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Comment -> XTerm ParserStage
ParserXTerm (Comment -> Type1 ParserStage) -> Comment -> Type1 ParserStage
forall a b. (a -> b) -> a -> b
$ Comment
cmtFst Comment -> Comment -> Comment
forall a. Semigroup a => a -> a -> a
<> Comment
cmtSnd
Maybe (Comment, TyOp, Comment, Type2 ParserStage)
Nothing -> Type1 ParserStage -> ParsecT Void Text Identity (Type1 ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Type1 ParserStage
-> ParsecT Void Text Identity (Type1 ParserStage))
-> Type1 ParserStage
-> ParsecT Void Text Identity (Type1 ParserStage)
forall a b. (a -> b) -> a -> b
$ Type2 ParserStage
-> Maybe (TyOp, Type2 ParserStage)
-> XTerm ParserStage
-> Type1 ParserStage
forall i. Type2 i -> Maybe (TyOp, Type2 i) -> XTerm i -> Type1 i
Type1 Type2 ParserStage
v Maybe (TyOp, Type2 ParserStage)
forall a. Maybe a
Nothing XTerm ParserStage
forall a. Monoid a => a
mempty
pType2 :: Parser (Type2 ParserStage)
pType2 :: Parser (Type2 ParserStage)
pType2 =
[Parser (Type2 ParserStage)] -> Parser (Type2 ParserStage)
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Value -> Type2 ParserStage
forall i. Value -> Type2 i
T2Value (Value -> Type2 ParserStage)
-> ParsecT Void Text Identity Value -> Parser (Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Value
pValue
, Name -> Maybe (GenericArg ParserStage) -> Type2 ParserStage
forall i. Name -> Maybe (GenericArg i) -> Type2 i
T2Name (Name -> Maybe (GenericArg ParserStage) -> Type2 ParserStage)
-> Parser Name
-> ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Name
pName ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> Type2 ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
-> Parser (Type2 ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (GenericArg ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (GenericArg ParserStage)
pGenericArg
, Type0 ParserStage -> Type2 ParserStage
forall i. Type0 i -> Type2 i
T2Group (Type0 ParserStage -> Type2 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
-> Parser (Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String
-> ParsecT Void Text Identity (Type0 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"group" (ParsecT Void Text Identity Text
"(" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Type0 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity (Type0 ParserStage)
pType0Cmt ParsecT Void Text Identity (Type0 ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Type0 ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
")")
, Group ParserStage -> Type2 ParserStage
forall i. Group i -> Type2 i
T2Map (Group ParserStage -> Type2 ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
-> Parser (Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"map" (ParsecT Void Text Identity Text
"{" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity (Group ParserStage)
pGroup ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
"}")
, Group ParserStage -> Type2 ParserStage
forall i. Group i -> Type2 i
T2Array (Group ParserStage -> Type2 ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
-> Parser (Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> String
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"array" (ParsecT Void Text Identity Text
"[" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (Group ParserStage)
pGroup ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
"]")
, Name -> Maybe (GenericArg ParserStage) -> Type2 ParserStage
forall i. Name -> Maybe (GenericArg i) -> Type2 i
T2Unwrapped (Name -> Maybe (GenericArg ParserStage) -> Type2 ParserStage)
-> Parser Name
-> ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Void Text Identity Text
"~" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment -> Parser Name -> Parser Name
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser Name
pName) ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> Type2 ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
-> Parser (Type2 ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (GenericArg ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (GenericArg ParserStage)
pGenericArg
, do
Text
_ <- ParsecT Void Text Identity Text
"&"
Comment
cmt <- ParsecT Void Text Identity Comment
space
[Parser (Type2 ParserStage)] -> Parser (Type2 ParserStage)
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Group ParserStage -> Type2 ParserStage
forall i. Group i -> Type2 i
T2Enum (Group ParserStage -> Type2 ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
-> Parser (Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Void Text Identity Text
"(" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (Group ParserStage)
pGroup ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! Comment -> ParsecT Void Text Identity Comment
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Comment
cmt ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
")")
, Name -> Maybe (GenericArg ParserStage) -> Type2 ParserStage
forall i. Name -> Maybe (GenericArg i) -> Type2 i
T2EnumRef (Name -> Maybe (GenericArg ParserStage) -> Type2 ParserStage)
-> Parser Name
-> ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Name
pName ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> Type2 ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
-> Parser (Type2 ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (GenericArg ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (GenericArg ParserStage)
pGenericArg
]
, ParsecT Void Text Identity Text
"#" ParsecT Void Text Identity Text
-> Parser (Type2 ParserStage) -> Parser (Type2 ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> do
Maybe Word8
mmajor :: Maybe Word8 <- ParsecT Void Text Identity Word8
-> ParsecT Void Text Identity (Maybe Word8)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Void Text Identity Word8
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, Num a) =>
m a
L.decimal
case Maybe Word8
mmajor of
Just Word8
major -> do
Maybe Word64
mminor <- ParsecT Void Text Identity Word64
-> ParsecT Void Text Identity (Maybe Word64)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT Void Text Identity Text
"." ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Word64
-> ParsecT Void Text Identity Word64
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Word64
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, Num a) =>
m a
L.decimal)
let
pTag :: Parser (Type2 ParserStage)
pTag
| Word8
major Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
== Word8
6 = Maybe Word64 -> Type0 ParserStage -> Type2 ParserStage
forall i. Maybe Word64 -> Type0 i -> Type2 i
T2Tag Maybe Word64
mminor (Type0 ParserStage -> Type2 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
-> Parser (Type2 ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Void Text Identity Text
"(" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Type0 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity (Type0 ParserStage)
pType0Cmt ParsecT Void Text Identity (Type0 ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Type0 ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
")")
| Bool
otherwise = Parser (Type2 ParserStage)
forall a. ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a
empty
Parser (Type2 ParserStage)
pTag Parser (Type2 ParserStage)
-> Parser (Type2 ParserStage) -> Parser (Type2 ParserStage)
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Type2 ParserStage -> Parser (Type2 ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word8 -> Maybe Word64 -> Type2 ParserStage
forall i. Word8 -> Maybe Word64 -> Type2 i
T2DataItem Word8
major Maybe Word64
mminor)
Maybe Word8
Nothing -> Type2 ParserStage -> Parser (Type2 ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type2 ParserStage
forall i. Type2 i
T2Any
]
where
pType0Cmt :: ParsecT Void Text Identity (Type0 ParserStage)
pType0Cmt = do
Comment
pre <- ParsecT Void Text Identity Comment
space
Type0 (Type1 ParserStage
t :| [Type1 ParserStage]
ts) <- ParsecT Void Text Identity (Type0 ParserStage)
pType0
Comment
post <- ParsecT Void Text Identity Comment
space
Type0 ParserStage -> ParsecT Void Text Identity (Type0 ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Type0 ParserStage
-> ParsecT Void Text Identity (Type0 ParserStage))
-> (NonEmpty (Type1 ParserStage) -> Type0 ParserStage)
-> NonEmpty (Type1 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. NonEmpty (Type1 ParserStage) -> Type0 ParserStage
forall i. NonEmpty (Type1 i) -> Type0 i
Type0 (NonEmpty (Type1 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage))
-> NonEmpty (Type1 ParserStage)
-> ParsecT Void Text Identity (Type0 ParserStage)
forall a b. (a -> b) -> a -> b
$ (Type1 ParserStage
t Type1 ParserStage
-> (Type1 ParserStage -> Type1 ParserStage) -> Type1 ParserStage
forall a b. a -> (a -> b) -> b
& Lens' (Type1 ParserStage) Comment
forall a. HasComment a => Lens' a Comment
commentL Lens' (Type1 ParserStage) Comment
-> Comment -> Type1 ParserStage -> Type1 ParserStage
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> b -> s -> t
.~ (Comment
pre Comment -> Comment -> Comment
forall a. Semigroup a => a -> a -> a
<> Comment
post)) Type1 ParserStage
-> [Type1 ParserStage] -> NonEmpty (Type1 ParserStage)
forall a. a -> [a] -> NonEmpty a
:| [Type1 ParserStage]
ts
pHeadNumber :: Parser Word64
pHeadNumber :: ParsecT Void Text Identity Word64
pHeadNumber = ParsecT Void Text Identity Word64
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, Num a) =>
m a
L.decimal
pRangeOp :: Parser RangeBound
pRangeOp :: Parser RangeBound
pRangeOp = String -> Parser RangeBound -> Parser RangeBound
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"range operator" (Parser RangeBound -> Parser RangeBound)
-> Parser RangeBound -> Parser RangeBound
forall a b. (a -> b) -> a -> b
$ Parser RangeBound -> Parser RangeBound
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Void Text Identity Text
"..." ParsecT Void Text Identity Text -> RangeBound -> Parser RangeBound
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> RangeBound
ClOpen) Parser RangeBound -> Parser RangeBound -> Parser RangeBound
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ParsecT Void Text Identity Text
".." ParsecT Void Text Identity Text -> RangeBound -> Parser RangeBound
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> RangeBound
Closed)
pCtlOp :: Parser CtlOp
pCtlOp :: Parser CtlOp
pCtlOp =
String -> Parser CtlOp -> Parser CtlOp
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"control operator" (Parser CtlOp -> Parser CtlOp) -> Parser CtlOp -> Parser CtlOp
forall a b. (a -> b) -> a -> b
$
ParsecT Void Text Identity Text
"."
ParsecT Void Text Identity Text -> Parser CtlOp -> Parser CtlOp
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> [Parser CtlOp] -> Parser CtlOp
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
( Parser CtlOp -> Parser CtlOp
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try
(Parser CtlOp -> Parser CtlOp) -> [Parser CtlOp] -> [Parser CtlOp]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ ParsecT Void Text Identity Text
"cborseq" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Cborseq
, ParsecT Void Text Identity Text
"cbor" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Cbor
, ParsecT Void Text Identity Text
"size" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Size
, ParsecT Void Text Identity Text
"bits" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Bits
, ParsecT Void Text Identity Text
"within" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Within
, ParsecT Void Text Identity Text
"and" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.And
, ParsecT Void Text Identity Text
"lt" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Lt
, ParsecT Void Text Identity Text
"le" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Le
, ParsecT Void Text Identity Text
"gt" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Gt
, ParsecT Void Text Identity Text
"ge" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Ge
, ParsecT Void Text Identity Text
"eq" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Eq
, ParsecT Void Text Identity Text
"ne" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Ne
, ParsecT Void Text Identity Text
"default" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Default
, ParsecT Void Text Identity Text
"regexp" ParsecT Void Text Identity Text -> CtlOp -> Parser CtlOp
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> CtlOp
COp.Regexp
]
)
pGroup :: Parser (Group ParserStage)
pGroup :: ParsecT Void Text Identity (Group ParserStage)
pGroup = NonEmpty (GrpChoice ParserStage) -> Group ParserStage
forall i. NonEmpty (GrpChoice i) -> Group i
Group (NonEmpty (GrpChoice ParserStage) -> Group ParserStage)
-> ParsecT Void Text Identity (NonEmpty (GrpChoice ParserStage))
-> ParsecT Void Text Identity (Group ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity (GrpChoice ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (NonEmpty (GrpChoice ParserStage))
forall (m :: * -> *) a sep.
Alternative m =>
m a -> m sep -> m (NonEmpty a)
NE.sepBy1 (ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (GrpChoice ParserStage)
-> ParsecT Void Text Identity (GrpChoice ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (GrpChoice ParserStage)
pGrpChoice) ParsecT Void Text Identity Text
"//"
pGrpChoice :: Parser (GrpChoice ParserStage)
pGrpChoice :: ParsecT Void Text Identity (GrpChoice ParserStage)
pGrpChoice = [GroupEntry ParserStage]
-> XTerm ParserStage -> GrpChoice ParserStage
forall i. [GroupEntry i] -> XTerm i -> GrpChoice i
GrpChoice ([GroupEntry ParserStage]
-> XTerm ParserStage -> GrpChoice ParserStage)
-> ParsecT Void Text Identity [GroupEntry ParserStage]
-> ParsecT
Void Text Identity (XTerm ParserStage -> GrpChoice ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity (GroupEntry ParserStage)
-> ParsecT Void Text Identity [GroupEntry ParserStage]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many (ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (GroupEntry ParserStage)
-> ParsecT Void Text Identity (GroupEntry ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (GroupEntry ParserStage)
pGrpEntry ParsecT Void Text Identity (GroupEntry ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (GroupEntry ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
pOptCom) ParsecT
Void Text Identity (XTerm ParserStage -> GrpChoice ParserStage)
-> ParsecT Void Text Identity (XTerm ParserStage)
-> ParsecT Void Text Identity (GrpChoice ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT Void Text Identity (XTerm ParserStage)
forall a. Monoid a => a
mempty
pGrpEntry :: Parser (GroupEntry ParserStage)
pGrpEntry :: ParsecT Void Text Identity (GroupEntry ParserStage)
pGrpEntry = do
Maybe OccurrenceIndicator
occur <- ParsecT Void Text Identity OccurrenceIndicator
-> ParsecT Void Text Identity (Maybe OccurrenceIndicator)
forall e s (f :: * -> *) a. MonadParsec e s f => f a -> f (Maybe a)
optcomp ParsecT Void Text Identity OccurrenceIndicator
pOccur
Comment
cmt <- ParsecT Void Text Identity Comment
space
WithComment Comment
cmt' GroupEntryVariant ParserStage
variant <-
[ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))]
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage)))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall a b. (a -> b) -> a -> b
$ do
Maybe (WithComment (MemberKey ParserStage))
mKey <- ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT
Void Text Identity (Maybe (WithComment (MemberKey ParserStage)))
forall e s (f :: * -> *) a. MonadParsec e s f => f a -> f (Maybe a)
optcomp (ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT
Void Text Identity (Maybe (WithComment (MemberKey ParserStage))))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT
Void Text Identity (Maybe (WithComment (MemberKey ParserStage)))
forall a b. (a -> b) -> a -> b
$ ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
pMemberKey ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space
Type0 ParserStage
t0 <- ParsecT Void Text Identity (Type0 ParserStage)
pType0
WithComment (GroupEntryVariant ParserStage)
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WithComment (GroupEntryVariant ParserStage)
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage)))
-> WithComment (GroupEntryVariant ParserStage)
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall a b. (a -> b) -> a -> b
$ Maybe (MemberKey ParserStage)
-> Type0 ParserStage -> GroupEntryVariant ParserStage
forall i. Maybe (MemberKey i) -> Type0 i -> GroupEntryVariant i
GEType (Maybe (MemberKey ParserStage)
-> Type0 ParserStage -> GroupEntryVariant ParserStage)
-> WithComment (Maybe (MemberKey ParserStage))
-> WithComment (Type0 ParserStage -> GroupEntryVariant ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (WithComment (MemberKey ParserStage))
-> WithComment (Maybe (MemberKey ParserStage))
forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
forall (m :: * -> *) a. Monad m => Maybe (m a) -> m (Maybe a)
sequence Maybe (WithComment (MemberKey ParserStage))
mKey WithComment (Type0 ParserStage -> GroupEntryVariant ParserStage)
-> WithComment (Type0 ParserStage)
-> WithComment (GroupEntryVariant ParserStage)
forall a b. WithComment (a -> b) -> WithComment a -> WithComment b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Type0 ParserStage -> WithComment (Type0 ParserStage)
forall a. a -> WithComment a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Type0 ParserStage
t0
, ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage)))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall a b. (a -> b) -> a -> b
$ GroupEntryVariant ParserStage
-> WithComment (GroupEntryVariant ParserStage)
forall a. a -> WithComment a
withComment (GroupEntryVariant ParserStage
-> WithComment (GroupEntryVariant ParserStage))
-> ParsecT Void Text Identity (GroupEntryVariant ParserStage)
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Name
-> Maybe (GenericArg ParserStage) -> GroupEntryVariant ParserStage
forall i. Name -> Maybe (GenericArg i) -> GroupEntryVariant i
GERef (Name
-> Maybe (GenericArg ParserStage) -> GroupEntryVariant ParserStage)
-> Parser Name
-> ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> GroupEntryVariant ParserStage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser Name
pName ParsecT
Void
Text
Identity
(Maybe (GenericArg ParserStage) -> GroupEntryVariant ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
-> ParsecT Void Text Identity (GroupEntryVariant ParserStage)
forall a b.
ParsecT Void Text Identity (a -> b)
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (GenericArg ParserStage)
-> ParsecT Void Text Identity (Maybe (GenericArg ParserStage))
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional Parser (GenericArg ParserStage)
pGenericArg)
, GroupEntryVariant ParserStage
-> WithComment (GroupEntryVariant ParserStage)
forall a. a -> WithComment a
withComment (GroupEntryVariant ParserStage
-> WithComment (GroupEntryVariant ParserStage))
-> (Group ParserStage -> GroupEntryVariant ParserStage)
-> Group ParserStage
-> WithComment (GroupEntryVariant ParserStage)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Group ParserStage -> GroupEntryVariant ParserStage
forall i. Group i -> GroupEntryVariant i
GEGroup (Group ParserStage -> WithComment (GroupEntryVariant ParserStage))
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT
Void Text Identity (WithComment (GroupEntryVariant ParserStage))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Void Text Identity Text
"(" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m Comment -> m a -> m a
!*> ParsecT Void Text Identity (Group ParserStage)
pGroup ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Group ParserStage)
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! ParsecT Void Text Identity Comment
space ParsecT Void Text Identity (Group ParserStage)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Group ParserStage)
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
")")
]
GroupEntry ParserStage
-> ParsecT Void Text Identity (GroupEntry ParserStage)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GroupEntry ParserStage
-> ParsecT Void Text Identity (GroupEntry ParserStage))
-> GroupEntry ParserStage
-> ParsecT Void Text Identity (GroupEntry ParserStage)
forall a b. (a -> b) -> a -> b
$ Maybe OccurrenceIndicator
-> GroupEntryVariant ParserStage
-> XTerm ParserStage
-> GroupEntry ParserStage
forall i.
Maybe OccurrenceIndicator
-> GroupEntryVariant i -> XTerm i -> GroupEntry i
GroupEntry Maybe OccurrenceIndicator
occur GroupEntryVariant ParserStage
variant (Comment -> XTerm ParserStage
ParserXTerm (Comment -> XTerm ParserStage) -> Comment -> XTerm ParserStage
forall a b. (a -> b) -> a -> b
$ Comment
cmt Comment -> Comment -> Comment
forall a. Semigroup a => a -> a -> a
<> Comment
cmt')
pMemberKey :: Parser (WithComment (MemberKey ParserStage))
pMemberKey :: ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
pMemberKey =
[ParsecT Void Text Identity (WithComment (MemberKey ParserStage))]
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a b. (a -> b) -> a -> b
$ do
Type1 ParserStage
t1 <- ParsecT Void Text Identity (Type1 ParserStage)
pType1
Comment
cmt0 <- ParsecT Void Text Identity Comment
space
Comment
cmt1 <- Maybe Comment -> Comment
forall m. Monoid m => Maybe m -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold (Maybe Comment -> Comment)
-> ParsecT Void Text Identity (Maybe Comment)
-> ParsecT Void Text Identity Comment
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Maybe Comment)
forall e s (f :: * -> *) a. MonadParsec e s f => f a -> f (Maybe a)
optcomp (ParsecT Void Text Identity Text
"^" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Comment
space) ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Comment
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
"=>"
WithComment (MemberKey ParserStage)
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WithComment (MemberKey ParserStage)
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> WithComment (MemberKey ParserStage)
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a b. (a -> b) -> a -> b
$ Comment
-> MemberKey ParserStage -> WithComment (MemberKey ParserStage)
forall a. Comment -> a -> WithComment a
WithComment (Comment
cmt0 Comment -> Comment -> Comment
forall a. Semigroup a => a -> a -> a
<> Comment
cmt1) (Type1 ParserStage -> MemberKey ParserStage
forall i. Type1 i -> MemberKey i
MKType Type1 ParserStage
t1)
, ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a b. (a -> b) -> a -> b
$ do
Name
name <- Parser Name
pName
Comment
cmt <- ParsecT Void Text Identity Comment
space
Text
_ <- ParsecT Void Text Identity Text
":"
WithComment (MemberKey ParserStage)
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WithComment (MemberKey ParserStage)
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> (MemberKey ParserStage -> WithComment (MemberKey ParserStage))
-> MemberKey ParserStage
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Comment
-> MemberKey ParserStage -> WithComment (MemberKey ParserStage)
forall a. Comment -> a -> WithComment a
WithComment Comment
cmt (MemberKey ParserStage
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> MemberKey ParserStage
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a b. (a -> b) -> a -> b
$ Name -> MemberKey ParserStage
forall i. Name -> MemberKey i
MKBareword Name
name
, do
Value
val <- ParsecT Void Text Identity Value
pValue
Comment
cmt <- ParsecT Void Text Identity Comment
space
Text
_ <- ParsecT Void Text Identity Text
":"
WithComment (MemberKey ParserStage)
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (WithComment (MemberKey ParserStage)
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> (MemberKey ParserStage -> WithComment (MemberKey ParserStage))
-> MemberKey ParserStage
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Comment
-> MemberKey ParserStage -> WithComment (MemberKey ParserStage)
forall a. Comment -> a -> WithComment a
WithComment Comment
cmt (MemberKey ParserStage
-> ParsecT
Void Text Identity (WithComment (MemberKey ParserStage)))
-> MemberKey ParserStage
-> ParsecT Void Text Identity (WithComment (MemberKey ParserStage))
forall a b. (a -> b) -> a -> b
$ Value -> MemberKey ParserStage
forall i. Value -> MemberKey i
MKValue Value
val
]
pOptCom :: Parser Comment
pOptCom :: ParsecT Void Text Identity Comment
pOptCom = ParsecT Void Text Identity Comment
space ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a (m :: * -> *).
(HasComment a, Applicative m) =>
m a -> m Comment -> m a
<*! (Maybe Comment -> Comment
forall m. Monoid m => Maybe m -> m
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold (Maybe Comment -> Comment)
-> ParsecT Void Text Identity (Maybe Comment)
-> ParsecT Void Text Identity Comment
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity (Maybe Comment)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT Void Text Identity Text
"," ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Comment
-> ParsecT Void Text Identity Comment
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT Void Text Identity Comment
space))
pOccur :: Parser OccurrenceIndicator
pOccur :: ParsecT Void Text Identity OccurrenceIndicator
pOccur =
String
-> ParsecT Void Text Identity OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"occurrence indicator" (ParsecT Void Text Identity OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator)
-> ParsecT Void Text Identity OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator
forall a b. (a -> b) -> a -> b
$
[ParsecT Void Text Identity OccurrenceIndicator]
-> ParsecT Void Text Identity OccurrenceIndicator
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'+' ParsecT Void Text Identity Char
-> OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> OccurrenceIndicator
OIOneOrMore
, Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'?' ParsecT Void Text Identity Char
-> OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> OccurrenceIndicator
OIOptional
, ParsecT Void Text Identity OccurrenceIndicator
pBounded
]
pValue :: Parser Value
pValue :: ParsecT Void Text Identity Value
pValue =
String
-> ParsecT Void Text Identity Value
-> ParsecT Void Text Identity Value
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"value" (ParsecT Void Text Identity Value
-> ParsecT Void Text Identity Value)
-> ParsecT Void Text Identity Value
-> ParsecT Void Text Identity Value
forall a b. (a -> b) -> a -> b
$
(ValueVariant -> Comment -> Value
`Value` Comment
forall a. Monoid a => a
mempty)
(ValueVariant -> Value)
-> ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ParsecT Void Text Identity ValueVariant]
-> ParsecT Void Text Identity ValueVariant
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Void Text Identity ValueVariant
pFloat
, ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Void Text Identity ValueVariant
pInt
, ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Void Text Identity ValueVariant
pBytes
, ParsecT Void Text Identity ValueVariant
pText
, ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT Void Text Identity ValueVariant
pBool
]
where
pSignedNum :: Num a => Parser a -> Parser (Bool, a)
pSignedNum :: forall a. Num a => Parser a -> Parser (Bool, a)
pSignedNum Parser a
valParser = do
Maybe Text
sign <- ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Void Text Identity Text
"-"
a
val <- Parser a
valParser Parser a -> ParsecT Void Text Identity () -> Parser a
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text -> ParsecT Void Text Identity ()
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy ParsecT Void Text Identity Text
"*"
(Bool, a) -> Parser (Bool, a)
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe Text -> Bool
forall a. Maybe a -> Bool
isJust Maybe Text
sign, a
val)
pInt :: ParsecT Void Text Identity ValueVariant
pInt =
Parser Integer -> Parser (Bool, Integer)
forall a. Num a => Parser a -> Parser (Bool, a)
pSignedNum Parser Integer
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, Num a) =>
m a
L.decimal Parser (Bool, Integer)
-> ((Bool, Integer) -> ParsecT Void Text Identity ValueVariant)
-> ParsecT Void Text Identity ValueVariant
forall a b.
ParsecT Void Text Identity a
-> (a -> ParsecT Void Text Identity b)
-> ParsecT Void Text Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
(Bool
False, Integer
val)
| Integer
val Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Word64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Bounded a => a
maxBound @Word64) -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> (Word64 -> ValueVariant)
-> Word64
-> ParsecT Void Text Identity ValueVariant
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> ValueVariant
VUInt (Word64 -> ParsecT Void Text Identity ValueVariant)
-> Word64 -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ Integer -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
val
| Bool
otherwise -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ Integer -> ValueVariant
VBignum Integer
val
(Bool
True, Integer
val)
| Integer
val Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
< Word64 -> Integer
forall a b. (Integral a, Num b) => a -> b
fromIntegral (forall a. Bounded a => a
maxBound @Word64) -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> (Word64 -> ValueVariant)
-> Word64
-> ParsecT Void Text Identity ValueVariant
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> ValueVariant
VNInt (Word64 -> ParsecT Void Text Identity ValueVariant)
-> Word64 -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ Integer -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral Integer
val
| Bool
otherwise -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> (Integer -> ValueVariant)
-> Integer
-> ParsecT Void Text Identity ValueVariant
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> ValueVariant
VBignum (Integer -> ParsecT Void Text Identity ValueVariant)
-> Integer -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ -Integer
val
pFloat :: ParsecT Void Text Identity ValueVariant
pFloat =
Parser Double -> Parser (Bool, Double)
forall a. Num a => Parser a -> Parser (Bool, a)
pSignedNum Parser Double
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, RealFloat a) =>
m a
L.float Parser (Bool, Double)
-> ((Bool, Double) -> ParsecT Void Text Identity ValueVariant)
-> ParsecT Void Text Identity ValueVariant
forall a b.
ParsecT Void Text Identity a
-> (a -> ParsecT Void Text Identity b)
-> ParsecT Void Text Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
(Bool
False, Double
val) -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ Double -> ValueVariant
VFloat64 Double
val
(Bool
True, Double
val) -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> (Double -> ValueVariant)
-> Double
-> ParsecT Void Text Identity ValueVariant
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> ValueVariant
VFloat64 (Double -> ParsecT Void Text Identity ValueVariant)
-> Double -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ Double -> Double
forall a. Num a => a -> a
negate Double
val
pSChar :: Parser Text
pSChar :: ParsecT Void Text Identity Text
pSChar = Maybe String
-> (Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text)
forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP (String -> Maybe String
forall a. a -> Maybe a
Just String
"character") ((Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text))
-> (Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text)
forall a b. (a -> b) -> a -> b
$ \Token Text
x ->
[Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
or ([Bool] -> Bool) -> [Bool] -> Bool
forall a b. (a -> b) -> a -> b
$
[ Char -> Char -> Char -> Bool
charInRange Char
'\x20' Char
'\x21'
, Char -> Char -> Char -> Bool
charInRange Char
'\x23' Char
'\x5b'
, Char -> Char -> Char -> Bool
charInRange Char
'\x5d' Char
'\x7e'
, Char -> Char -> Char -> Bool
charInRange Char
'\x80' Char
'\x10fffd'
]
[Char -> Bool] -> String -> [Bool]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Char -> String
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Char
Token Text
x
pText :: ParsecT Void Text Identity ValueVariant
pText = Text -> ValueVariant
VText (Text -> ValueVariant)
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity ValueVariant
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParsecT Void Text Identity Text
"\"" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT Void Text Identity Text
pSChar ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
forall a b.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT Void Text Identity Text
"\"")
pSByte :: ParsecT Void Text Identity (Tokens Text)
pSByte = Maybe String
-> (Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text)
forall e s (m :: * -> *).
MonadParsec e s m =>
Maybe String -> (Token s -> Bool) -> m (Tokens s)
takeWhileP (String -> Maybe String
forall a. a -> Maybe a
Just String
"byte character") ((Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text))
-> (Token Text -> Bool) -> ParsecT Void Text Identity (Tokens Text)
forall a b. (a -> b) -> a -> b
$ \Token Text
x ->
[Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
or ([Bool] -> Bool) -> [Bool] -> Bool
forall a b. (a -> b) -> a -> b
$
[ Char -> Char -> Char -> Bool
charInRange Char
'\x20' Char
'\x26'
, Char -> Char -> Char -> Bool
charInRange Char
'\x28' Char
'\x5b'
, Char -> Char -> Char -> Bool
charInRange Char
'\x5d' Char
'\x10fffd'
]
[Char -> Bool] -> String -> [Bool]
forall a b. [a -> b] -> [a] -> [b]
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Char -> String
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
pure Char
Token Text
x
pBytes :: ParsecT Void Text Identity ValueVariant
pBytes = do
Maybe Text
_qualifier <- ParsecT Void Text Identity Text
-> ParsecT Void Text Identity (Maybe Text)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT Void Text Identity Text
"h" ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT Void Text Identity Text
"b64")
Text
bytes <- ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
-> ParsecT Void Text Identity Text
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between ParsecT Void Text Identity Text
"'" ParsecT Void Text Identity Text
"'" ParsecT Void Text Identity Text
ParsecT Void Text Identity (Tokens Text)
pSByte
case ByteString -> Either String ByteString
Base16.decode (ByteString -> Either String ByteString)
-> ByteString -> Either String ByteString
forall a b. (a -> b) -> a -> b
$ Text -> ByteString
encodeUtf8 Text
bytes of
Right ByteString
x -> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ ByteString -> ValueVariant
VBytes ByteString
x
Left String
err -> String -> ParsecT Void Text Identity ValueVariant
forall a. String -> ParsecT Void Text Identity a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
err
pBool :: ParsecT Void Text Identity ValueVariant
pBool = String
-> ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant
forall a.
String
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a.
MonadParsec e s m =>
String -> m a -> m a
label String
"boolean" (ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant)
-> ParsecT Void Text Identity ValueVariant
-> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ do
Bool
b <-
(Bool
True Bool
-> ParsecT Void Text Identity (Tokens Text)
-> ParsecT Void Text Identity Bool
forall a b.
a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens Text
"true")
ParsecT Void Text Identity Bool
-> ParsecT Void Text Identity Bool
-> ParsecT Void Text Identity Bool
forall a.
ParsecT Void Text Identity a
-> ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Bool
False Bool
-> ParsecT Void Text Identity (Tokens Text)
-> ParsecT Void Text Identity Bool
forall a b.
a -> ParsecT Void Text Identity b -> ParsecT Void Text Identity a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Tokens Text -> ParsecT Void Text Identity (Tokens Text)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string Tokens Text
"false")
ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ValueVariant -> ParsecT Void Text Identity ValueVariant)
-> ValueVariant -> ParsecT Void Text Identity ValueVariant
forall a b. (a -> b) -> a -> b
$ Bool -> ValueVariant
VBool Bool
b
pTyOp :: Parser TyOp
pTyOp :: Parser TyOp
pTyOp =
[Parser TyOp] -> Parser TyOp
forall (f :: * -> *) (m :: * -> *) a.
(Foldable f, Alternative m) =>
f (m a) -> m a
choice
[ Parser TyOp -> Parser TyOp
forall a.
ParsecT Void Text Identity a -> ParsecT Void Text Identity a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (Parser TyOp -> Parser TyOp) -> Parser TyOp -> Parser TyOp
forall a b. (a -> b) -> a -> b
$ RangeBound -> TyOp
RangeOp (RangeBound -> TyOp) -> Parser RangeBound -> Parser TyOp
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser RangeBound
pRangeOp
, CtlOp -> TyOp
CtrlOp (CtlOp -> TyOp) -> Parser CtlOp -> Parser TyOp
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser CtlOp
pCtlOp
]
pBounded :: Parser OccurrenceIndicator
pBounded :: ParsecT Void Text Identity OccurrenceIndicator
pBounded = do
Maybe Word64
lo <- ParsecT Void Text Identity Word64
-> ParsecT Void Text Identity (Maybe Word64)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Void Text Identity Word64
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, Num a) =>
m a
L.decimal
Char
_ <- Token Text -> ParsecT Void Text Identity (Token Text)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
Token s -> m (Token s)
char Char
Token Text
'*'
Maybe Word64
hi <- ParsecT Void Text Identity Word64
-> ParsecT Void Text Identity (Maybe Word64)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional ParsecT Void Text Identity Word64
forall e s (m :: * -> *) a.
(MonadParsec e s m, Token s ~ Char, Num a) =>
m a
L.decimal
OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator
forall a. a -> ParsecT Void Text Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator)
-> OccurrenceIndicator
-> ParsecT Void Text Identity OccurrenceIndicator
forall a b. (a -> b) -> a -> b
$ case (Maybe Word64
lo, Maybe Word64
hi) of
(Maybe Word64
Nothing, Maybe Word64
Nothing) -> OccurrenceIndicator
OIZeroOrMore
(Maybe Word64
x, Maybe Word64
y) -> Maybe Word64 -> Maybe Word64 -> OccurrenceIndicator
OIBounded Maybe Word64
x Maybe Word64
y
optcomp :: MonadParsec e s f => f a -> f (Maybe a)
optcomp :: forall e s (f :: * -> *) a. MonadParsec e s f => f a -> f (Maybe a)
optcomp = f a -> f (Maybe a)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (f a -> f (Maybe a)) -> (f a -> f a) -> f a -> f (Maybe a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. f a -> f a
forall a. f a -> f a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try
sepBy1' :: MonadParsec e s m => m a -> m sep -> m (NonEmpty a)
sepBy1' :: forall e s (m :: * -> *) a sep.
MonadParsec e s m =>
m a -> m sep -> m (NonEmpty a)
sepBy1' m a
p m sep
sep = [a] -> NonEmpty a
forall a. HasCallStack => [a] -> NonEmpty a
NE.fromList ([a] -> NonEmpty a) -> m [a] -> m (NonEmpty a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m [a]
go
where
go :: m [a]
go = (a -> [a] -> [a]) -> m a -> m [a] -> m [a]
forall a b c. (a -> b -> c) -> m a -> m b -> m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 (:) m a
p (m a -> m [a]
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many (m a -> m a
forall a. m a -> m a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (m a -> m a) -> m a -> m a
forall a b. (a -> b) -> a -> b
$ m sep
sep m sep -> m a -> m a
forall a b. m a -> m b -> m b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> m a
p))