{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE Safe #-}
module Parser.TypeCategory (
parseFilters,
parseScope,
parseScopedFunction,
singleDefine,
singleFilter,
singleRefine,
) where
import Text.Parsec
import Text.Parsec.String
import Parser.Common
import Parser.TypeInstance ()
import Types.Positional
import Types.TypeCategory
import Types.TypeInstance
import Types.Variance
instance ParseFromSource (AnyCategory SourcePos) where
sourceParser :: Parser (AnyCategory SourcePos)
sourceParser = Parser (AnyCategory SourcePos)
parseValue Parser (AnyCategory SourcePos)
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser (AnyCategory SourcePos)
parseInstance Parser (AnyCategory SourcePos)
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser (AnyCategory SourcePos)
parseConcrete where
open :: Parser ()
open = Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (String -> Parser ()
string_ String
"{")
close :: Parser ()
close = Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (String -> Parser ()
string_ String
"}")
parseValue :: Parser (AnyCategory SourcePos)
parseValue = String
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall a. String -> Parser a -> Parser a
labeled String
"value interface" (Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos))
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Parser () -> Parser ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ Parser ()
kwValue Parser () -> Parser () -> Parser ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser ()
kwInterface
CategoryName
n <- Parser CategoryName
forall a. ParseFromSource a => Parser a
sourceParser
[ValueParam SourcePos]
ps <- Parser [ValueParam SourcePos]
parseCategoryParams
Parser ()
open
([ValueRefine SourcePos]
rs,[ParamFilter SourcePos]
vs) <- Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
parseRefinesFilters
[ScopedFunction SourcePos]
fs <- (ParsecT String () Identity (ScopedFunction SourcePos)
-> Parser ()
-> ParsecT String () Identity [ScopedFunction SourcePos])
-> Parser ()
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ParsecT String () Identity (ScopedFunction SourcePos)
-> Parser ()
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser ()
optionalSpace (ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos])
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall a b. (a -> b) -> a -> b
$ Parser SymbolScope
-> Parser CategoryName
-> ParsecT String () Identity (ScopedFunction SourcePos)
parseScopedFunction (SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
ValueScope) (CategoryName -> Parser CategoryName
forall (m :: * -> *) a. Monad m => a -> m a
return CategoryName
n)
Parser ()
close
AnyCategory SourcePos -> Parser (AnyCategory SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyCategory SourcePos -> Parser (AnyCategory SourcePos))
-> AnyCategory SourcePos -> Parser (AnyCategory SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> Namespace
-> CategoryName
-> [ValueParam SourcePos]
-> [ValueRefine SourcePos]
-> [ParamFilter SourcePos]
-> [ScopedFunction SourcePos]
-> AnyCategory SourcePos
forall c.
[c]
-> Namespace
-> CategoryName
-> [ValueParam c]
-> [ValueRefine c]
-> [ParamFilter c]
-> [ScopedFunction c]
-> AnyCategory c
ValueInterface [SourcePos
c] Namespace
NoNamespace CategoryName
n [ValueParam SourcePos]
ps [ValueRefine SourcePos]
rs [ParamFilter SourcePos]
vs [ScopedFunction SourcePos]
fs
parseInstance :: Parser (AnyCategory SourcePos)
parseInstance = String
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall a. String -> Parser a -> Parser a
labeled String
"type interface" (Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos))
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Parser () -> Parser ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ Parser ()
kwType Parser () -> Parser () -> Parser ()
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser ()
kwInterface
CategoryName
n <- Parser CategoryName
forall a. ParseFromSource a => Parser a
sourceParser
[ValueParam SourcePos]
ps <- Parser [ValueParam SourcePos]
parseCategoryParams
Parser ()
open
[ParamFilter SourcePos]
vs <- Parser [ParamFilter SourcePos]
parseFilters
[ScopedFunction SourcePos]
fs <- (ParsecT String () Identity (ScopedFunction SourcePos)
-> Parser ()
-> ParsecT String () Identity [ScopedFunction SourcePos])
-> Parser ()
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ParsecT String () Identity (ScopedFunction SourcePos)
-> Parser ()
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser ()
optionalSpace (ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos])
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall a b. (a -> b) -> a -> b
$ Parser SymbolScope
-> Parser CategoryName
-> ParsecT String () Identity (ScopedFunction SourcePos)
parseScopedFunction (SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
TypeScope) (CategoryName -> Parser CategoryName
forall (m :: * -> *) a. Monad m => a -> m a
return CategoryName
n)
Parser ()
close
AnyCategory SourcePos -> Parser (AnyCategory SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyCategory SourcePos -> Parser (AnyCategory SourcePos))
-> AnyCategory SourcePos -> Parser (AnyCategory SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> Namespace
-> CategoryName
-> [ValueParam SourcePos]
-> [ParamFilter SourcePos]
-> [ScopedFunction SourcePos]
-> AnyCategory SourcePos
forall c.
[c]
-> Namespace
-> CategoryName
-> [ValueParam c]
-> [ParamFilter c]
-> [ScopedFunction c]
-> AnyCategory c
InstanceInterface [SourcePos
c] Namespace
NoNamespace CategoryName
n [ValueParam SourcePos]
ps [ParamFilter SourcePos]
vs [ScopedFunction SourcePos]
fs
parseConcrete :: Parser (AnyCategory SourcePos)
parseConcrete = String
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall a. String -> Parser a -> Parser a
labeled String
"concrete type" (Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos))
-> Parser (AnyCategory SourcePos) -> Parser (AnyCategory SourcePos)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Parser () -> Parser ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser ()
kwConcrete
CategoryName
n <- Parser CategoryName
forall a. ParseFromSource a => Parser a
sourceParser
[ValueParam SourcePos]
ps <- Parser [ValueParam SourcePos]
parseCategoryParams
Parser ()
open
([ValueRefine SourcePos]
rs,[ValueDefine SourcePos]
ds,[ParamFilter SourcePos]
vs) <- Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
parseRefinesDefinesFilters
[ScopedFunction SourcePos]
fs <- (ParsecT String () Identity (ScopedFunction SourcePos)
-> Parser ()
-> ParsecT String () Identity [ScopedFunction SourcePos])
-> Parser ()
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall a b c. (a -> b -> c) -> b -> a -> c
flip ParsecT String () Identity (ScopedFunction SourcePos)
-> Parser ()
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser ()
optionalSpace (ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos])
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity [ScopedFunction SourcePos]
forall a b. (a -> b) -> a -> b
$ Parser SymbolScope
-> Parser CategoryName
-> ParsecT String () Identity (ScopedFunction SourcePos)
parseScopedFunction Parser SymbolScope
parseScope (CategoryName -> Parser CategoryName
forall (m :: * -> *) a. Monad m => a -> m a
return CategoryName
n)
Parser ()
close
AnyCategory SourcePos -> Parser (AnyCategory SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyCategory SourcePos -> Parser (AnyCategory SourcePos))
-> AnyCategory SourcePos -> Parser (AnyCategory SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> Namespace
-> CategoryName
-> [ValueParam SourcePos]
-> [ValueRefine SourcePos]
-> [ValueDefine SourcePos]
-> [ParamFilter SourcePos]
-> [ScopedFunction SourcePos]
-> AnyCategory SourcePos
forall c.
[c]
-> Namespace
-> CategoryName
-> [ValueParam c]
-> [ValueRefine c]
-> [ValueDefine c]
-> [ParamFilter c]
-> [ScopedFunction c]
-> AnyCategory c
ValueConcrete [SourcePos
c] Namespace
NoNamespace CategoryName
n [ValueParam SourcePos]
ps [ValueRefine SourcePos]
rs [ValueDefine SourcePos]
ds [ParamFilter SourcePos]
vs [ScopedFunction SourcePos]
fs
parseCategoryParams :: Parser [ValueParam SourcePos]
parseCategoryParams :: Parser [ValueParam SourcePos]
parseCategoryParams = do
([(SourcePos, ParamName)]
con,[(SourcePos, ParamName)]
inv,[(SourcePos, ParamName)]
cov) <- ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall u a a a. ParsecT String u Identity ([a], [a], [a])
none ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall a a.
ParsecT String () Identity ([a], [(SourcePos, ParamName)], [a])
fixedOnly ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall a.
ParsecT
String
()
Identity
([(SourcePos, ParamName)], [a], [(SourcePos, ParamName)])
noFixed ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
explicitFixed
[ValueParam SourcePos] -> Parser [ValueParam SourcePos]
forall (m :: * -> *) a. Monad m => a -> m a
return ([ValueParam SourcePos] -> Parser [ValueParam SourcePos])
-> [ValueParam SourcePos] -> Parser [ValueParam SourcePos]
forall a b. (a -> b) -> a -> b
$ ((SourcePos, ParamName) -> ValueParam SourcePos)
-> [(SourcePos, ParamName)] -> [ValueParam SourcePos]
forall a b. (a -> b) -> [a] -> [b]
map (Variance -> (SourcePos, ParamName) -> ValueParam SourcePos
forall c. Variance -> (c, ParamName) -> ValueParam c
apply Variance
Contravariant) [(SourcePos, ParamName)]
con [ValueParam SourcePos]
-> [ValueParam SourcePos] -> [ValueParam SourcePos]
forall a. [a] -> [a] -> [a]
++
((SourcePos, ParamName) -> ValueParam SourcePos)
-> [(SourcePos, ParamName)] -> [ValueParam SourcePos]
forall a b. (a -> b) -> [a] -> [b]
map (Variance -> (SourcePos, ParamName) -> ValueParam SourcePos
forall c. Variance -> (c, ParamName) -> ValueParam c
apply Variance
Invariant) [(SourcePos, ParamName)]
inv [ValueParam SourcePos]
-> [ValueParam SourcePos] -> [ValueParam SourcePos]
forall a. [a] -> [a] -> [a]
++
((SourcePos, ParamName) -> ValueParam SourcePos)
-> [(SourcePos, ParamName)] -> [ValueParam SourcePos]
forall a b. (a -> b) -> [a] -> [b]
map (Variance -> (SourcePos, ParamName) -> ValueParam SourcePos
forall c. Variance -> (c, ParamName) -> ValueParam c
apply Variance
Covariant) [(SourcePos, ParamName)]
cov
where
none :: ParsecT String u Identity ([a], [a], [a])
none = do
ParsecT String u Identity String -> ParsecT String u Identity ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (String -> ParsecT String u Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"<")
([a], [a], [a]) -> ParsecT String u Identity ([a], [a], [a])
forall (m :: * -> *) a. Monad m => a -> m a
return ([],[],[])
fixedOnly :: ParsecT String () Identity ([a], [(SourcePos, ParamName)], [a])
fixedOnly = do
[(SourcePos, ParamName)]
inv <- Parser ()
-> Parser ()
-> ParsecT String () Identity [(SourcePos, ParamName)]
-> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"<")
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
">")
(ParsecT String () Identity (SourcePos, ParamName)
-> Parser () -> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (SourcePos, ParamName)
singleParam (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
","))
([a], [(SourcePos, ParamName)], [a])
-> ParsecT String () Identity ([a], [(SourcePos, ParamName)], [a])
forall (m :: * -> *) a. Monad m => a -> m a
return ([],[(SourcePos, ParamName)]
inv,[])
noFixed :: ParsecT
String
()
Identity
([(SourcePos, ParamName)], [a], [(SourcePos, ParamName)])
noFixed = do
[(SourcePos, ParamName)]
con <- Parser ()
-> Parser ()
-> ParsecT String () Identity [(SourcePos, ParamName)]
-> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"<")
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"|")
(ParsecT String () Identity (SourcePos, ParamName)
-> Parser () -> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (SourcePos, ParamName)
singleParam (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
","))
[(SourcePos, ParamName)]
cov <- Parser ()
-> Parser ()
-> ParsecT String () Identity [(SourcePos, ParamName)]
-> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between Parser ()
nullParse
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
">")
(ParsecT String () Identity (SourcePos, ParamName)
-> Parser () -> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (SourcePos, ParamName)
singleParam (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
","))
([(SourcePos, ParamName)], [a], [(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [a], [(SourcePos, ParamName)])
forall (m :: * -> *) a. Monad m => a -> m a
return ([(SourcePos, ParamName)]
con,[],[(SourcePos, ParamName)]
cov)
explicitFixed :: ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
explicitFixed = do
[(SourcePos, ParamName)]
con <- Parser ()
-> Parser ()
-> ParsecT String () Identity [(SourcePos, ParamName)]
-> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"<")
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"|")
(ParsecT String () Identity (SourcePos, ParamName)
-> Parser () -> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (SourcePos, ParamName)
singleParam (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
","))
[(SourcePos, ParamName)]
inv <- Parser ()
-> Parser ()
-> ParsecT String () Identity [(SourcePos, ParamName)]
-> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between Parser ()
nullParse
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"|")
(ParsecT String () Identity (SourcePos, ParamName)
-> Parser () -> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (SourcePos, ParamName)
singleParam (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
","))
[(SourcePos, ParamName)]
cov <- Parser ()
-> Parser ()
-> ParsecT String () Identity [(SourcePos, ParamName)]
-> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between Parser ()
nullParse
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
">")
(ParsecT String () Identity (SourcePos, ParamName)
-> Parser () -> ParsecT String () Identity [(SourcePos, ParamName)]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (SourcePos, ParamName)
singleParam (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
","))
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
-> ParsecT
String
()
Identity
([(SourcePos, ParamName)], [(SourcePos, ParamName)],
[(SourcePos, ParamName)])
forall (m :: * -> *) a. Monad m => a -> m a
return ([(SourcePos, ParamName)]
con,[(SourcePos, ParamName)]
inv,[(SourcePos, ParamName)]
cov)
singleParam :: ParsecT String () Identity (SourcePos, ParamName)
singleParam = String
-> ParsecT String () Identity (SourcePos, ParamName)
-> ParsecT String () Identity (SourcePos, ParamName)
forall a. String -> Parser a -> Parser a
labeled String
"param declaration" (ParsecT String () Identity (SourcePos, ParamName)
-> ParsecT String () Identity (SourcePos, ParamName))
-> ParsecT String () Identity (SourcePos, ParamName)
-> ParsecT String () Identity (SourcePos, ParamName)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParamName
n <- Parser ParamName
forall a. ParseFromSource a => Parser a
sourceParser
(SourcePos, ParamName)
-> ParsecT String () Identity (SourcePos, ParamName)
forall (m :: * -> *) a. Monad m => a -> m a
return (SourcePos
c,ParamName
n)
apply :: Variance -> (c, ParamName) -> ValueParam c
apply Variance
v (c
c,ParamName
n) = [c] -> ParamName -> Variance -> ValueParam c
forall c. [c] -> ParamName -> Variance -> ValueParam c
ValueParam [c
c] ParamName
n Variance
v
singleRefine :: Parser (ValueRefine SourcePos)
singleRefine :: Parser (ValueRefine SourcePos)
singleRefine = do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Parser () -> Parser ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser ()
kwRefines
TypeInstance
t <- Parser TypeInstance
forall a. ParseFromSource a => Parser a
sourceParser
ValueRefine SourcePos -> Parser (ValueRefine SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueRefine SourcePos -> Parser (ValueRefine SourcePos))
-> ValueRefine SourcePos -> Parser (ValueRefine SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos] -> TypeInstance -> ValueRefine SourcePos
forall c. [c] -> TypeInstance -> ValueRefine c
ValueRefine [SourcePos
c] TypeInstance
t
singleDefine :: Parser (ValueDefine SourcePos)
singleDefine :: Parser (ValueDefine SourcePos)
singleDefine = do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Parser () -> Parser ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser ()
kwDefines
DefinesInstance
t <- Parser DefinesInstance
forall a. ParseFromSource a => Parser a
sourceParser
ValueDefine SourcePos -> Parser (ValueDefine SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueDefine SourcePos -> Parser (ValueDefine SourcePos))
-> ValueDefine SourcePos -> Parser (ValueDefine SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos] -> DefinesInstance -> ValueDefine SourcePos
forall c. [c] -> DefinesInstance -> ValueDefine c
ValueDefine [SourcePos
c] DefinesInstance
t
singleFilter :: Parser (ParamFilter SourcePos)
singleFilter :: Parser (ParamFilter SourcePos)
singleFilter = Parser (ParamFilter SourcePos) -> Parser (ParamFilter SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Parser (ParamFilter SourcePos) -> Parser (ParamFilter SourcePos))
-> Parser (ParamFilter SourcePos) -> Parser (ParamFilter SourcePos)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParamName
n <- Parser ParamName
forall a. ParseFromSource a => Parser a
sourceParser
TypeFilter
f <- Parser TypeFilter
forall a. ParseFromSource a => Parser a
sourceParser
ParamFilter SourcePos -> Parser (ParamFilter SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ParamFilter SourcePos -> Parser (ParamFilter SourcePos))
-> ParamFilter SourcePos -> Parser (ParamFilter SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos] -> ParamName -> TypeFilter -> ParamFilter SourcePos
forall c. [c] -> ParamName -> TypeFilter -> ParamFilter c
ParamFilter [SourcePos
c] ParamName
n TypeFilter
f
parseCategoryRefines :: Parser [ValueRefine SourcePos]
parseCategoryRefines :: Parser [ValueRefine SourcePos]
parseCategoryRefines = Parser [ValueRefine SourcePos] -> Parser [ValueRefine SourcePos]
forall a. Parser a -> Parser a
sepAfter (Parser [ValueRefine SourcePos] -> Parser [ValueRefine SourcePos])
-> Parser [ValueRefine SourcePos] -> Parser [ValueRefine SourcePos]
forall a b. (a -> b) -> a -> b
$ Parser (ValueRefine SourcePos)
-> Parser () -> Parser [ValueRefine SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser (ValueRefine SourcePos)
singleRefine Parser ()
optionalSpace
parseFilters :: Parser [ParamFilter SourcePos]
parseFilters :: Parser [ParamFilter SourcePos]
parseFilters = Parser (ParamFilter SourcePos)
-> Parser () -> Parser [ParamFilter SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser (ParamFilter SourcePos)
singleFilter Parser ()
optionalSpace
parseRefinesFilters :: Parser ([ValueRefine SourcePos],[ParamFilter SourcePos])
parseRefinesFilters :: Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
parseRefinesFilters = ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ParamFilter SourcePos])]
parsed ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ParamFilter SourcePos])]
-> ([([ValueRefine SourcePos], [ParamFilter SourcePos])]
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos]))
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall (m :: * -> *) a. Monad m => a -> m a
return (([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos]))
-> ([([ValueRefine SourcePos], [ParamFilter SourcePos])]
-> ([ValueRefine SourcePos], [ParamFilter SourcePos]))
-> [([ValueRefine SourcePos], [ParamFilter SourcePos])]
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [([ValueRefine SourcePos], [ParamFilter SourcePos])]
-> ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall (f :: * -> *) a b.
(Foldable f, Monoid a, Monoid b) =>
f (a, b) -> (a, b)
merge2 where
parsed :: ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ParamFilter SourcePos])]
parsed = Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ()
-> ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ParamFilter SourcePos])]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
anyType Parser ()
optionalSpace
anyType :: Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
anyType = String
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall a. String -> Parser a -> Parser a
labeled String
"refine or param filter" (Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos]))
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall a b. (a -> b) -> a -> b
$ Parser (ValueRefine SourcePos)
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall (m :: * -> *) a b.
(Functor m, Monad m) =>
m a -> m ([a], [b])
put12 Parser (ValueRefine SourcePos)
singleRefine Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser (ParamFilter SourcePos)
-> Parser ([ValueRefine SourcePos], [ParamFilter SourcePos])
forall (m :: * -> *) b a.
(Functor m, Monad m) =>
m b -> m ([a], [b])
put22 Parser (ParamFilter SourcePos)
singleFilter
parseRefinesDefinesFilters :: Parser ([ValueRefine SourcePos],
[ValueDefine SourcePos],
[ParamFilter SourcePos])
parseRefinesDefinesFilters :: Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
parseRefinesDefinesFilters = ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
parsed ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
-> ([([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos]))
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall (m :: * -> *) a. Monad m => a -> m a
return (([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos]))
-> ([([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
-> ([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos]))
-> [([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
-> ([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall (f :: * -> *) a b c.
(Foldable f, Monoid a, Monoid b, Monoid c) =>
f (a, b, c) -> (a, b, c)
merge3 where
parsed :: ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
parsed = Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser ()
-> ParsecT
String
()
Identity
[([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
anyType Parser ()
optionalSpace
anyType :: Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
anyType =
String
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall a. String -> Parser a -> Parser a
labeled String
"refine or define or param filter" (Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos]))
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall a b. (a -> b) -> a -> b
$ Parser (ValueRefine SourcePos)
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall (m :: * -> *) a b c.
(Functor m, Monad m) =>
m a -> m ([a], [b], [c])
put13 Parser (ValueRefine SourcePos)
singleRefine Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser (ValueDefine SourcePos)
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall (m :: * -> *) b a c.
(Functor m, Monad m) =>
m b -> m ([a], [b], [c])
put23 Parser (ValueDefine SourcePos)
singleDefine Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser (ParamFilter SourcePos)
-> Parser
([ValueRefine SourcePos], [ValueDefine SourcePos],
[ParamFilter SourcePos])
forall (m :: * -> *) c a b.
(Functor m, Monad m) =>
m c -> m ([a], [b], [c])
put33 Parser (ParamFilter SourcePos)
singleFilter
instance ParseFromSource FunctionName where
sourceParser :: Parser FunctionName
sourceParser = String -> Parser FunctionName -> Parser FunctionName
forall a. String -> Parser a -> Parser a
labeled String
"function name" (Parser FunctionName -> Parser FunctionName)
-> Parser FunctionName -> Parser FunctionName
forall a b. (a -> b) -> a -> b
$ do
Parser ()
noKeywords
Char
b <- ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
lower
String
e <- Parser String -> Parser String
forall a. Parser a -> Parser a
sepAfter (Parser String -> Parser String) -> Parser String -> Parser String
forall a b. (a -> b) -> a -> b
$ ParsecT String () Identity Char -> Parser String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
many ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
alphaNum
FunctionName -> Parser FunctionName
forall (m :: * -> *) a. Monad m => a -> m a
return (FunctionName -> Parser FunctionName)
-> FunctionName -> Parser FunctionName
forall a b. (a -> b) -> a -> b
$ String -> FunctionName
FunctionName (Char
bChar -> String -> String
forall a. a -> [a] -> [a]
:String
e)
parseScopedFunction :: Parser SymbolScope -> Parser CategoryName ->
Parser (ScopedFunction SourcePos)
parseScopedFunction :: Parser SymbolScope
-> Parser CategoryName
-> ParsecT String () Identity (ScopedFunction SourcePos)
parseScopedFunction Parser SymbolScope
sp Parser CategoryName
tp = String
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity (ScopedFunction SourcePos)
forall a. String -> Parser a -> Parser a
labeled String
"function" (ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity (ScopedFunction SourcePos))
-> ParsecT String () Identity (ScopedFunction SourcePos)
-> ParsecT String () Identity (ScopedFunction SourcePos)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SymbolScope
s <- Parser SymbolScope -> Parser SymbolScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser SymbolScope
sp
CategoryName
t <- Parser CategoryName -> Parser CategoryName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser CategoryName
tp
FunctionName
n <- Parser FunctionName -> Parser FunctionName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser FunctionName
forall a. ParseFromSource a => Parser a
sourceParser
Positional (ValueParam SourcePos)
ps <- ([ValueParam SourcePos] -> Positional (ValueParam SourcePos))
-> Parser [ValueParam SourcePos]
-> ParsecT String () Identity (Positional (ValueParam SourcePos))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [ValueParam SourcePos] -> Positional (ValueParam SourcePos)
forall a. [a] -> Positional a
Positional (Parser [ValueParam SourcePos]
-> ParsecT String () Identity (Positional (ValueParam SourcePos)))
-> Parser [ValueParam SourcePos]
-> ParsecT String () Identity (Positional (ValueParam SourcePos))
forall a b. (a -> b) -> a -> b
$ Parser [ValueParam SourcePos]
forall u a. ParsecT String u Identity [a]
noParams Parser [ValueParam SourcePos]
-> Parser [ValueParam SourcePos] -> Parser [ValueParam SourcePos]
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser [ValueParam SourcePos]
someParams
[ParamFilter SourcePos]
fa <- Parser [ParamFilter SourcePos]
parseFilters
Positional (PassedValue SourcePos)
as <- ([PassedValue SourcePos] -> Positional (PassedValue SourcePos))
-> ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity (Positional (PassedValue SourcePos))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [PassedValue SourcePos] -> Positional (PassedValue SourcePos)
forall a. [a] -> Positional a
Positional (ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity (Positional (PassedValue SourcePos)))
-> ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity (Positional (PassedValue SourcePos))
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String () Identity [PassedValue SourcePos]
typeList String
"argument type"
Parser String -> Parser ()
forall a. Parser a -> Parser ()
sepAfter_ (String -> Parser String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"->")
Positional (PassedValue SourcePos)
rs <- ([PassedValue SourcePos] -> Positional (PassedValue SourcePos))
-> ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity (Positional (PassedValue SourcePos))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [PassedValue SourcePos] -> Positional (PassedValue SourcePos)
forall a. [a] -> Positional a
Positional (ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity (Positional (PassedValue SourcePos)))
-> ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity (Positional (PassedValue SourcePos))
forall a b. (a -> b) -> a -> b
$ String -> ParsecT String () Identity [PassedValue SourcePos]
typeList String
"return type"
ScopedFunction SourcePos
-> ParsecT String () Identity (ScopedFunction SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ScopedFunction SourcePos
-> ParsecT String () Identity (ScopedFunction SourcePos))
-> ScopedFunction SourcePos
-> ParsecT String () Identity (ScopedFunction SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos]
-> FunctionName
-> CategoryName
-> SymbolScope
-> Positional (PassedValue SourcePos)
-> Positional (PassedValue SourcePos)
-> Positional (ValueParam SourcePos)
-> [ParamFilter SourcePos]
-> [ScopedFunction SourcePos]
-> ScopedFunction SourcePos
forall c.
[c]
-> FunctionName
-> CategoryName
-> SymbolScope
-> Positional (PassedValue c)
-> Positional (PassedValue c)
-> Positional (ValueParam c)
-> [ParamFilter c]
-> [ScopedFunction c]
-> ScopedFunction c
ScopedFunction [SourcePos
c] FunctionName
n CategoryName
t SymbolScope
s Positional (PassedValue SourcePos)
as Positional (PassedValue SourcePos)
rs Positional (ValueParam SourcePos)
ps [ParamFilter SourcePos]
fa []
where
noParams :: ParsecT String u Identity [a]
noParams = ParsecT String u Identity String -> ParsecT String u Identity ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (String -> ParsecT String u Identity String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
"<") ParsecT String u Identity ()
-> ParsecT String u Identity [a] -> ParsecT String u Identity [a]
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [a] -> ParsecT String u Identity [a]
forall (m :: * -> *) a. Monad m => a -> m a
return []
someParams :: Parser [ValueParam SourcePos]
someParams = Parser ()
-> Parser ()
-> Parser [ValueParam SourcePos]
-> Parser [ValueParam SourcePos]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"<")
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
">")
(ParsecT String () Identity (ValueParam SourcePos)
-> Parser String -> Parser [ValueParam SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy ParsecT String () Identity (ValueParam SourcePos)
singleParam (Parser String -> Parser String
forall a. Parser a -> Parser a
sepAfter (Parser String -> Parser String) -> Parser String -> Parser String
forall a b. (a -> b) -> a -> b
$ String -> Parser String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
","))
singleParam :: ParsecT String () Identity (ValueParam SourcePos)
singleParam = String
-> ParsecT String () Identity (ValueParam SourcePos)
-> ParsecT String () Identity (ValueParam SourcePos)
forall a. String -> Parser a -> Parser a
labeled String
"param declaration" (ParsecT String () Identity (ValueParam SourcePos)
-> ParsecT String () Identity (ValueParam SourcePos))
-> ParsecT String () Identity (ValueParam SourcePos)
-> ParsecT String () Identity (ValueParam SourcePos)
forall a b. (a -> b) -> a -> b
$ do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParamName
n <- Parser ParamName
forall a. ParseFromSource a => Parser a
sourceParser
ValueParam SourcePos
-> ParsecT String () Identity (ValueParam SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueParam SourcePos
-> ParsecT String () Identity (ValueParam SourcePos))
-> ValueParam SourcePos
-> ParsecT String () Identity (ValueParam SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos] -> ParamName -> Variance -> ValueParam SourcePos
forall c. [c] -> ParamName -> Variance -> ValueParam c
ValueParam [SourcePos
c] ParamName
n Variance
Invariant
typeList :: String -> ParsecT String () Identity [PassedValue SourcePos]
typeList String
l = Parser ()
-> Parser ()
-> ParsecT String () Identity [PassedValue SourcePos]
-> ParsecT String () Identity [PassedValue SourcePos]
forall s (m :: * -> *) t u open close a.
Stream s m t =>
ParsecT s u m open
-> ParsecT s u m close -> ParsecT s u m a -> ParsecT s u m a
between (Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
"(")
(Parser () -> Parser ()
forall a. Parser a -> Parser a
sepAfter (Parser () -> Parser ()) -> Parser () -> Parser ()
forall a b. (a -> b) -> a -> b
$ String -> Parser ()
string_ String
")")
(ParsecT String () Identity (PassedValue SourcePos)
-> Parser String
-> ParsecT String () Identity [PassedValue SourcePos]
forall s (m :: * -> *) t u a sep.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m sep -> ParsecT s u m [a]
sepBy (String
-> ParsecT String () Identity (PassedValue SourcePos)
-> ParsecT String () Identity (PassedValue SourcePos)
forall a. String -> Parser a -> Parser a
labeled String
l (ParsecT String () Identity (PassedValue SourcePos)
-> ParsecT String () Identity (PassedValue SourcePos))
-> ParsecT String () Identity (PassedValue SourcePos)
-> ParsecT String () Identity (PassedValue SourcePos)
forall a b. (a -> b) -> a -> b
$ ParsecT String () Identity (PassedValue SourcePos)
singleType) (Parser String -> Parser String
forall a. Parser a -> Parser a
sepAfter (Parser String -> Parser String) -> Parser String -> Parser String
forall a b. (a -> b) -> a -> b
$ String -> Parser String
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m String
string String
","))
singleType :: ParsecT String () Identity (PassedValue SourcePos)
singleType = do
SourcePos
c <- ParsecT String () Identity SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ValueType
t <- Parser ValueType
forall a. ParseFromSource a => Parser a
sourceParser
PassedValue SourcePos
-> ParsecT String () Identity (PassedValue SourcePos)
forall (m :: * -> *) a. Monad m => a -> m a
return (PassedValue SourcePos
-> ParsecT String () Identity (PassedValue SourcePos))
-> PassedValue SourcePos
-> ParsecT String () Identity (PassedValue SourcePos)
forall a b. (a -> b) -> a -> b
$ [SourcePos] -> ValueType -> PassedValue SourcePos
forall c. [c] -> ValueType -> PassedValue c
PassedValue [SourcePos
c] ValueType
t
parseScope :: Parser SymbolScope
parseScope :: Parser SymbolScope
parseScope = Parser SymbolScope -> Parser SymbolScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser SymbolScope
categoryScope Parser SymbolScope -> Parser SymbolScope -> Parser SymbolScope
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser SymbolScope -> Parser SymbolScope
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser SymbolScope
typeScope Parser SymbolScope -> Parser SymbolScope -> Parser SymbolScope
forall s u (m :: * -> *) a.
ParsecT s u m a -> ParsecT s u m a -> ParsecT s u m a
<|> Parser SymbolScope
valueScope
categoryScope :: Parser SymbolScope
categoryScope :: Parser SymbolScope
categoryScope = Parser ()
kwCategory Parser () -> Parser SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
CategoryScope
typeScope :: Parser SymbolScope
typeScope :: Parser SymbolScope
typeScope = Parser ()
kwType Parser () -> Parser SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
TypeScope
valueScope :: Parser SymbolScope
valueScope :: Parser SymbolScope
valueScope = Parser ()
kwValue Parser () -> Parser SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SymbolScope -> Parser SymbolScope
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
ValueScope