{-# LANGUAGE FlexibleInstances #-}
module Parser.TypeCategory (
parseFilters,
parseScope,
parseScopedFunction,
singleDefine,
singleFilter,
singleRefine,
) where
import Base.Positional
import Parser.Common
import Parser.TextParser
import Parser.TypeInstance ()
import Types.TypeCategory
import Types.TypeInstance
import Types.Variance
instance ParseFromSource (AnyCategory SourceContext) where
sourceParser :: TextParser (AnyCategory SourceContext)
sourceParser = TextParser (AnyCategory SourceContext)
parseValue TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser (AnyCategory SourceContext)
parseInstance TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser (AnyCategory SourceContext)
parseConcrete where
open :: TextParser ()
open = TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (String -> TextParser ()
string_ String
"{")
close :: TextParser ()
close = TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (String -> TextParser ()
string_ String
"}")
parseValue :: TextParser (AnyCategory SourceContext)
parseValue = String
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"value interface" (TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext))
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ TextParser ()
kwValue TextParser () -> TextParser () -> TextParser ()
forall a b.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TextParser ()
kwInterface
CategoryName
n <- TextParser CategoryName
forall a. ParseFromSource a => TextParser a
sourceParser
[ValueParam SourceContext]
ps <- TextParser [ValueParam SourceContext]
parseCategoryParams
TextParser ()
open
[PragmaCategory SourceContext]
pg <- ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
pragmas
[ValueRefine SourceContext]
rs <- TextParser [ValueRefine SourceContext]
parseCategoryRefines
[ScopedFunction SourceContext]
fs <- (TextParser (ScopedFunction SourceContext)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext])
-> TextParser ()
-> TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext]
forall a b c. (a -> b -> c) -> b -> a -> c
flip TextParser (ScopedFunction SourceContext)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser ()
optionalSpace (TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext])
-> TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext]
forall a b. (a -> b) -> a -> b
$ TextParser SymbolScope
-> TextParser CategoryName
-> TextParser (ScopedFunction SourceContext)
parseScopedFunction (SymbolScope -> TextParser SymbolScope
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
ValueScope) (CategoryName -> TextParser CategoryName
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return CategoryName
n)
TextParser ()
close
AnyCategory SourceContext -> TextParser (AnyCategory SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyCategory SourceContext
-> TextParser (AnyCategory SourceContext))
-> AnyCategory SourceContext
-> TextParser (AnyCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> Namespace
-> CategoryName
-> [PragmaCategory SourceContext]
-> [ValueParam SourceContext]
-> [ValueRefine SourceContext]
-> [ScopedFunction SourceContext]
-> AnyCategory SourceContext
forall c.
[c]
-> Namespace
-> CategoryName
-> [PragmaCategory c]
-> [ValueParam c]
-> [ValueRefine c]
-> [ScopedFunction c]
-> AnyCategory c
ValueInterface [SourceContext
c] Namespace
NoNamespace CategoryName
n [PragmaCategory SourceContext]
pg [ValueParam SourceContext]
ps [ValueRefine SourceContext]
rs [ScopedFunction SourceContext]
fs
parseInstance :: TextParser (AnyCategory SourceContext)
parseInstance = String
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"type interface" (TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext))
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ TextParser ()
kwType TextParser () -> TextParser () -> TextParser ()
forall a b.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> TextParser ()
kwInterface
CategoryName
n <- TextParser CategoryName
forall a. ParseFromSource a => TextParser a
sourceParser
[ValueParam SourceContext]
ps <- TextParser [ValueParam SourceContext]
parseCategoryParams
TextParser ()
open
[PragmaCategory SourceContext]
pg <- ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
pragmas
[ScopedFunction SourceContext]
fs <- (TextParser (ScopedFunction SourceContext)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext])
-> TextParser ()
-> TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext]
forall a b c. (a -> b -> c) -> b -> a -> c
flip TextParser (ScopedFunction SourceContext)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser ()
optionalSpace (TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext])
-> TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage String Identity [ScopedFunction SourceContext]
forall a b. (a -> b) -> a -> b
$ TextParser SymbolScope
-> TextParser CategoryName
-> TextParser (ScopedFunction SourceContext)
parseScopedFunction (SymbolScope -> TextParser SymbolScope
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
TypeScope) (CategoryName -> TextParser CategoryName
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return CategoryName
n)
TextParser ()
close
AnyCategory SourceContext -> TextParser (AnyCategory SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyCategory SourceContext
-> TextParser (AnyCategory SourceContext))
-> AnyCategory SourceContext
-> TextParser (AnyCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> Namespace
-> CategoryName
-> [PragmaCategory SourceContext]
-> [ValueParam SourceContext]
-> [ScopedFunction SourceContext]
-> AnyCategory SourceContext
forall c.
[c]
-> Namespace
-> CategoryName
-> [PragmaCategory c]
-> [ValueParam c]
-> [ScopedFunction c]
-> AnyCategory c
InstanceInterface [SourceContext
c] Namespace
NoNamespace CategoryName
n [PragmaCategory SourceContext]
pg [ValueParam SourceContext]
ps [ScopedFunction SourceContext]
fs
parseConcrete :: TextParser (AnyCategory SourceContext)
parseConcrete = String
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"concrete type" (TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext))
-> TextParser (AnyCategory SourceContext)
-> TextParser (AnyCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser ()
kwConcrete
CategoryName
n <- TextParser CategoryName
forall a. ParseFromSource a => TextParser a
sourceParser
[ValueParam SourceContext]
ps <- TextParser [ValueParam SourceContext]
parseCategoryParams
TextParser ()
open
[PragmaCategory SourceContext]
pg <- ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
pragmas
([ValueRefine SourceContext]
rs,[ValueDefine SourceContext]
ds,[ParamFilter SourceContext]
vs) <- TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
parseRefinesDefinesFilters
([ScopedFunction SourceContext]
fs,[FunctionVisibility SourceContext]
fv) <- TextParser (ScopedFunction SourceContext)
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
parseFunctionsWithVisibility (TextParser (ScopedFunction SourceContext)
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext]))
-> TextParser (ScopedFunction SourceContext)
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
forall a b. (a -> b) -> a -> b
$ TextParser SymbolScope
-> TextParser CategoryName
-> TextParser (ScopedFunction SourceContext)
parseScopedFunction TextParser SymbolScope
parseScope (CategoryName -> TextParser CategoryName
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return CategoryName
n)
TextParser ()
close
AnyCategory SourceContext -> TextParser (AnyCategory SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (AnyCategory SourceContext
-> TextParser (AnyCategory SourceContext))
-> AnyCategory SourceContext
-> TextParser (AnyCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> Namespace
-> CategoryName
-> [PragmaCategory SourceContext]
-> [FunctionVisibility SourceContext]
-> [ValueParam SourceContext]
-> [ValueRefine SourceContext]
-> [ValueDefine SourceContext]
-> [ParamFilter SourceContext]
-> [ScopedFunction SourceContext]
-> AnyCategory SourceContext
forall c.
[c]
-> Namespace
-> CategoryName
-> [PragmaCategory c]
-> [FunctionVisibility c]
-> [ValueParam c]
-> [ValueRefine c]
-> [ValueDefine c]
-> [ParamFilter c]
-> [ScopedFunction c]
-> AnyCategory c
ValueConcrete [SourceContext
c] Namespace
NoNamespace CategoryName
n [PragmaCategory SourceContext]
pg [FunctionVisibility SourceContext]
fv [ValueParam SourceContext]
ps [ValueRefine SourceContext]
rs [ValueDefine SourceContext]
ds [ParamFilter SourceContext]
vs [ScopedFunction SourceContext]
fs
pragmas :: ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
pragmas = (PragmaCategory SourceContext -> [PragmaCategory SourceContext])
-> ParsecT
CompilerMessage String Identity (PragmaCategory SourceContext)
-> ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (PragmaCategory SourceContext
-> [PragmaCategory SourceContext] -> [PragmaCategory SourceContext]
forall a. a -> [a] -> [a]
:[]) ParsecT
CompilerMessage String Identity (PragmaCategory SourceContext)
immutable ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
-> ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
-> ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> [PragmaCategory SourceContext]
-> ParsecT
CompilerMessage String Identity [PragmaCategory SourceContext]
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return []
immutable :: ParsecT
CompilerMessage String Identity (PragmaCategory SourceContext)
immutable = do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser ()
kwImmutable
PragmaCategory SourceContext
-> ParsecT
CompilerMessage String Identity (PragmaCategory SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (PragmaCategory SourceContext
-> ParsecT
CompilerMessage String Identity (PragmaCategory SourceContext))
-> PragmaCategory SourceContext
-> ParsecT
CompilerMessage String Identity (PragmaCategory SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext] -> PragmaCategory SourceContext
forall c. [c] -> PragmaCategory c
CategoryImmutable [SourceContext
c]
parseCategoryParams :: TextParser [ValueParam SourceContext]
parseCategoryParams :: TextParser [ValueParam SourceContext]
parseCategoryParams = do
([(SourceContext, ParamName)]
con,[(SourceContext, ParamName)]
inv,[(SourceContext, ParamName)]
cov) <- ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall {a} {a} {a}.
ParsecT CompilerMessage String Identity ([a], [a], [a])
none ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall {a} {a}.
ParsecT
CompilerMessage
String
Identity
([a], [(SourceContext, ParamName)], [a])
fixedOnly ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall {a}.
ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [a], [(SourceContext, ParamName)])
noFixed ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
explicitFixed
[ValueParam SourceContext] -> TextParser [ValueParam SourceContext]
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([ValueParam SourceContext]
-> TextParser [ValueParam SourceContext])
-> [ValueParam SourceContext]
-> TextParser [ValueParam SourceContext]
forall a b. (a -> b) -> a -> b
$ ((SourceContext, ParamName) -> ValueParam SourceContext)
-> [(SourceContext, ParamName)] -> [ValueParam SourceContext]
forall a b. (a -> b) -> [a] -> [b]
map (Variance -> (SourceContext, ParamName) -> ValueParam SourceContext
forall {c}. Variance -> (c, ParamName) -> ValueParam c
apply Variance
Contravariant) [(SourceContext, ParamName)]
con [ValueParam SourceContext]
-> [ValueParam SourceContext] -> [ValueParam SourceContext]
forall a. [a] -> [a] -> [a]
++
((SourceContext, ParamName) -> ValueParam SourceContext)
-> [(SourceContext, ParamName)] -> [ValueParam SourceContext]
forall a b. (a -> b) -> [a] -> [b]
map (Variance -> (SourceContext, ParamName) -> ValueParam SourceContext
forall {c}. Variance -> (c, ParamName) -> ValueParam c
apply Variance
Invariant) [(SourceContext, ParamName)]
inv [ValueParam SourceContext]
-> [ValueParam SourceContext] -> [ValueParam SourceContext]
forall a. [a] -> [a] -> [a]
++
((SourceContext, ParamName) -> ValueParam SourceContext)
-> [(SourceContext, ParamName)] -> [ValueParam SourceContext]
forall a b. (a -> b) -> [a] -> [b]
map (Variance -> (SourceContext, ParamName) -> ValueParam SourceContext
forall {c}. Variance -> (c, ParamName) -> ValueParam c
apply Variance
Covariant) [(SourceContext, ParamName)]
cov
where
none :: ParsecT CompilerMessage String Identity ([a], [a], [a])
none = do
ParsecT CompilerMessage String Identity (Tokens String)
-> TextParser ()
forall a.
ParsecT CompilerMessage String Identity a -> TextParser ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
"<")
([a], [a], [a])
-> ParsecT CompilerMessage String Identity ([a], [a], [a])
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([],[],[])
fixedOnly :: ParsecT
CompilerMessage
String
Identity
([a], [(SourceContext, ParamName)], [a])
fixedOnly = do
[(SourceContext, ParamName)]
inv <- TextParser ()
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"<")
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
">")
(ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
","))
([a], [(SourceContext, ParamName)], [a])
-> ParsecT
CompilerMessage
String
Identity
([a], [(SourceContext, ParamName)], [a])
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([],[(SourceContext, ParamName)]
inv,[])
noFixed :: ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [a], [(SourceContext, ParamName)])
noFixed = do
[(SourceContext, ParamName)]
con <- TextParser ()
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"<")
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"|")
(ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
","))
[(SourceContext, ParamName)]
cov <- TextParser ()
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between TextParser ()
nullParse
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
">")
(ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
","))
([(SourceContext, ParamName)], [a], [(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [a], [(SourceContext, ParamName)])
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([(SourceContext, ParamName)]
con,[],[(SourceContext, ParamName)]
cov)
explicitFixed :: ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
explicitFixed = do
[(SourceContext, ParamName)]
con <- TextParser ()
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"<")
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"|")
(ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
","))
[(SourceContext, ParamName)]
inv <- TextParser ()
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between TextParser ()
nullParse
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"|")
(ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
","))
[(SourceContext, ParamName)]
cov <- TextParser ()
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between TextParser ()
nullParse
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
">")
(ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> TextParser ()
-> ParsecT
CompilerMessage String Identity [(SourceContext, ParamName)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
","))
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
-> ParsecT
CompilerMessage
String
Identity
([(SourceContext, ParamName)], [(SourceContext, ParamName)],
[(SourceContext, ParamName)])
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([(SourceContext, ParamName)]
con,[(SourceContext, ParamName)]
inv,[(SourceContext, ParamName)]
cov)
singleParam :: ParsecT CompilerMessage String Identity (SourceContext, ParamName)
singleParam = String
-> ParsecT
CompilerMessage String Identity (SourceContext, ParamName)
-> ParsecT
CompilerMessage String Identity (SourceContext, ParamName)
forall a. String -> TextParser a -> TextParser a
labeled String
"param declaration" (ParsecT CompilerMessage String Identity (SourceContext, ParamName)
-> ParsecT
CompilerMessage String Identity (SourceContext, ParamName))
-> ParsecT
CompilerMessage String Identity (SourceContext, ParamName)
-> ParsecT
CompilerMessage String Identity (SourceContext, ParamName)
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
noParamSelf
SourceContext
c <- TextParser SourceContext
getSourceContext
ParamName
n <- TextParser ParamName
forall a. ParseFromSource a => TextParser a
sourceParser
(SourceContext, ParamName)
-> ParsecT
CompilerMessage String Identity (SourceContext, ParamName)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceContext
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 :: TextParser (ValueRefine SourceContext)
singleRefine :: TextParser (ValueRefine SourceContext)
singleRefine = do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser ()
kwRefines
TypeInstance
t <- TextParser TypeInstance
forall a. ParseFromSource a => TextParser a
sourceParser
ValueRefine SourceContext -> TextParser (ValueRefine SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueRefine SourceContext
-> TextParser (ValueRefine SourceContext))
-> ValueRefine SourceContext
-> TextParser (ValueRefine SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext] -> TypeInstance -> ValueRefine SourceContext
forall c. [c] -> TypeInstance -> ValueRefine c
ValueRefine [SourceContext
c] TypeInstance
t
singleDefine :: TextParser (ValueDefine SourceContext)
singleDefine :: TextParser (ValueDefine SourceContext)
singleDefine = do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser ()
kwDefines
DefinesInstance
t <- TextParser DefinesInstance
forall a. ParseFromSource a => TextParser a
sourceParser
ValueDefine SourceContext -> TextParser (ValueDefine SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueDefine SourceContext
-> TextParser (ValueDefine SourceContext))
-> ValueDefine SourceContext
-> TextParser (ValueDefine SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext] -> DefinesInstance -> ValueDefine SourceContext
forall c. [c] -> DefinesInstance -> ValueDefine c
ValueDefine [SourceContext
c] DefinesInstance
t
singleFilter :: TextParser (ParamFilter SourceContext)
singleFilter :: TextParser (ParamFilter SourceContext)
singleFilter = do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser ()
noParamSelf
ParamName
n <- TextParser ParamName
forall a. ParseFromSource a => TextParser a
sourceParser
TypeFilter
f <- TextParser TypeFilter
forall a. ParseFromSource a => TextParser a
sourceParser
ParamFilter SourceContext -> TextParser (ParamFilter SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (ParamFilter SourceContext
-> TextParser (ParamFilter SourceContext))
-> ParamFilter SourceContext
-> TextParser (ParamFilter SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> ParamName -> TypeFilter -> ParamFilter SourceContext
forall c. [c] -> ParamName -> TypeFilter -> ParamFilter c
ParamFilter [SourceContext
c] ParamName
n TypeFilter
f
parseCategoryRefines :: TextParser [ValueRefine SourceContext]
parseCategoryRefines :: TextParser [ValueRefine SourceContext]
parseCategoryRefines = TextParser [ValueRefine SourceContext]
-> TextParser [ValueRefine SourceContext]
forall a. TextParser a -> TextParser a
sepAfter (TextParser [ValueRefine SourceContext]
-> TextParser [ValueRefine SourceContext])
-> TextParser [ValueRefine SourceContext]
-> TextParser [ValueRefine SourceContext]
forall a b. (a -> b) -> a -> b
$ TextParser (ValueRefine SourceContext)
-> TextParser () -> TextParser [ValueRefine SourceContext]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser (ValueRefine SourceContext)
singleRefine TextParser ()
optionalSpace
parseFilters :: TextParser [ParamFilter SourceContext]
parseFilters :: TextParser [ParamFilter SourceContext]
parseFilters = TextParser (ParamFilter SourceContext)
-> TextParser () -> TextParser [ParamFilter SourceContext]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser (ParamFilter SourceContext)
singleFilter TextParser ()
optionalSpace
parseRefinesDefinesFilters ::
TextParser ([ValueRefine SourceContext],[ValueDefine SourceContext],[ParamFilter SourceContext])
parseRefinesDefinesFilters :: TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
parseRefinesDefinesFilters = ParsecT
CompilerMessage
String
Identity
[([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
parsed ParsecT
CompilerMessage
String
Identity
[([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
-> ([([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext]))
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall a b.
ParsecT CompilerMessage String Identity a
-> (a -> ParsecT CompilerMessage String Identity b)
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= ([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext]))
-> ([([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
-> ([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext]))
-> [([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
-> ([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall (f :: * -> *) a b c.
(Foldable f, Monoid a, Monoid b, Monoid c) =>
f (a, b, c) -> (a, b, c)
merge3 where
parsed :: ParsecT
CompilerMessage
String
Identity
[([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
parsed = TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser ()
-> ParsecT
CompilerMessage
String
Identity
[([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
anyType TextParser ()
optionalSpace
anyType :: TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
anyType =
String
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall a. String -> TextParser a -> TextParser a
labeled String
"refine or define or param filter" (TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext]))
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall a b. (a -> b) -> a -> b
$ TextParser (ValueRefine SourceContext)
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall (m :: * -> *) a b c.
(Functor m, Monad m) =>
m a -> m ([a], [b], [c])
put13 TextParser (ValueRefine SourceContext)
singleRefine TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser (ValueDefine SourceContext)
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall (m :: * -> *) b a c.
(Functor m, Monad m) =>
m b -> m ([a], [b], [c])
put23 TextParser (ValueDefine SourceContext)
singleDefine TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser (ParamFilter SourceContext)
-> TextParser
([ValueRefine SourceContext], [ValueDefine SourceContext],
[ParamFilter SourceContext])
forall (m :: * -> *) c a b.
(Functor m, Monad m) =>
m c -> m ([a], [b], [c])
put33 TextParser (ParamFilter SourceContext)
singleFilter
instance ParseFromSource FunctionName where
sourceParser :: TextParser FunctionName
sourceParser = String -> TextParser FunctionName -> TextParser FunctionName
forall a. String -> TextParser a -> TextParser a
labeled String
"function name" (TextParser FunctionName -> TextParser FunctionName)
-> TextParser FunctionName -> TextParser FunctionName
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
noKeywords
Char
b <- ParsecT CompilerMessage String Identity Char
ParsecT CompilerMessage String Identity (Token String)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
lowerChar
String
e <- TextParser String -> TextParser String
forall a. TextParser a -> TextParser a
sepAfter (TextParser String -> TextParser String)
-> TextParser String -> TextParser String
forall a b. (a -> b) -> a -> b
$ ParsecT CompilerMessage String Identity Char -> TextParser String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many ParsecT CompilerMessage String Identity Char
ParsecT CompilerMessage String Identity (Token String)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
alphaNumChar
FunctionName -> TextParser FunctionName
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (FunctionName -> TextParser FunctionName)
-> FunctionName -> TextParser FunctionName
forall a b. (a -> b) -> a -> b
$ String -> FunctionName
FunctionName (Char
bChar -> String -> String
forall a. a -> [a] -> [a]
:String
e)
instance ParseFromSource (CallArgLabel SourceContext) where
sourceParser :: TextParser (CallArgLabel SourceContext)
sourceParser = String
-> TextParser (CallArgLabel SourceContext)
-> TextParser (CallArgLabel SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"arg label" (TextParser (CallArgLabel SourceContext)
-> TextParser (CallArgLabel SourceContext))
-> TextParser (CallArgLabel SourceContext)
-> TextParser (CallArgLabel SourceContext)
forall a b. (a -> b) -> a -> b
$ do
SourceContext
c <- TextParser SourceContext
getSourceContext
Char
b <- ParsecT CompilerMessage String Identity Char
ParsecT CompilerMessage String Identity (Token String)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
lowerChar
String
e <- ParsecT CompilerMessage String Identity Char -> TextParser String
forall (m :: * -> *) a. MonadPlus m => m a -> m [a]
many ParsecT CompilerMessage String Identity Char
ParsecT CompilerMessage String Identity (Token String)
forall e s (m :: * -> *).
(MonadParsec e s m, Token s ~ Char) =>
m (Token s)
alphaNumChar
TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ Char -> TextParser ()
char_ Char
':'
CallArgLabel SourceContext
-> TextParser (CallArgLabel SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (CallArgLabel SourceContext
-> TextParser (CallArgLabel SourceContext))
-> CallArgLabel SourceContext
-> TextParser (CallArgLabel SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext] -> String -> CallArgLabel SourceContext
forall c. [c] -> String -> CallArgLabel c
CallArgLabel [SourceContext
c] (Char
bChar -> String -> String
forall a. a -> [a] -> [a]
:String
e String -> String -> String
forall a. [a] -> [a] -> [a]
++ String
":")
instance ParseFromSource (FunctionVisibility SourceContext) where
sourceParser :: TextParser (FunctionVisibility SourceContext)
sourceParser = String
-> TextParser (FunctionVisibility SourceContext)
-> TextParser (FunctionVisibility SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"visibility" (TextParser (FunctionVisibility SourceContext)
-> TextParser (FunctionVisibility SourceContext))
-> TextParser (FunctionVisibility SourceContext)
-> TextParser (FunctionVisibility SourceContext)
forall a b. (a -> b) -> a -> b
$ do
SourceContext
c <- TextParser SourceContext
getSourceContext
TextParser ()
kwVisibility
TextParser (FunctionVisibility SourceContext)
forall {c}.
ParsecT CompilerMessage String Identity (FunctionVisibility c)
visDefault TextParser (FunctionVisibility SourceContext)
-> TextParser (FunctionVisibility SourceContext)
-> TextParser (FunctionVisibility SourceContext)
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SourceContext -> TextParser (FunctionVisibility SourceContext)
visTypes SourceContext
c where
visDefault :: ParsecT CompilerMessage String Identity (FunctionVisibility c)
visDefault = do
TextParser ()
kwIgnore
FunctionVisibility c
-> ParsecT CompilerMessage String Identity (FunctionVisibility c)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (FunctionVisibility c
-> ParsecT CompilerMessage String Identity (FunctionVisibility c))
-> FunctionVisibility c
-> ParsecT CompilerMessage String Identity (FunctionVisibility c)
forall a b. (a -> b) -> a -> b
$ FunctionVisibility c
forall c. FunctionVisibility c
FunctionVisibilityDefault
visTypes :: SourceContext -> TextParser (FunctionVisibility SourceContext)
visTypes SourceContext
c = do
[([SourceContext], GeneralInstance)]
ts <- ParsecT
CompilerMessage String Identity ([SourceContext], GeneralInstance)
-> ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT
CompilerMessage
String
Identity
[([SourceContext], GeneralInstance)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy1 ParsecT
CompilerMessage String Identity ([SourceContext], GeneralInstance)
singleType (ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String)
forall a. TextParser a -> TextParser a
sepAfter (ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String))
-> ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String)
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
",")
FunctionVisibility SourceContext
-> TextParser (FunctionVisibility SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (FunctionVisibility SourceContext
-> TextParser (FunctionVisibility SourceContext))
-> FunctionVisibility SourceContext
-> TextParser (FunctionVisibility SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> [([SourceContext], GeneralInstance)]
-> FunctionVisibility SourceContext
forall c. [c] -> [([c], GeneralInstance)] -> FunctionVisibility c
FunctionVisibility [SourceContext
c] [([SourceContext], GeneralInstance)]
ts
singleType :: ParsecT
CompilerMessage String Identity ([SourceContext], GeneralInstance)
singleType = do
SourceContext
c <- TextParser SourceContext
getSourceContext
GeneralInstance
t <- TextParser GeneralInstance
forall a. ParseFromSource a => TextParser a
sourceParser
([SourceContext], GeneralInstance)
-> ParsecT
CompilerMessage String Identity ([SourceContext], GeneralInstance)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ([SourceContext
c],GeneralInstance
t)
parseFunctionsWithVisibility :: TextParser (ScopedFunction SourceContext) ->
TextParser ([ScopedFunction SourceContext],[FunctionVisibility SourceContext])
parseFunctionsWithVisibility :: TextParser (ScopedFunction SourceContext)
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
parseFunctionsWithVisibility TextParser (ScopedFunction SourceContext)
func = String
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
forall a. String -> TextParser a -> TextParser a
labeled String
"visibility" (TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext]))
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
forall a b. (a -> b) -> a -> b
$ ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
-> TextParser ()
-> ParsecT
CompilerMessage
String
Identity
[Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext)]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
anyType TextParser ()
optionalSpace ParsecT
CompilerMessage
String
Identity
[Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext)]
-> ([Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext)]
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext]))
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
forall a b.
ParsecT CompilerMessage String Identity a
-> (a -> ParsecT CompilerMessage String Identity b)
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= FunctionVisibility SourceContext
-> [Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext)]
-> TextParser
([ScopedFunction SourceContext],
[FunctionVisibility SourceContext])
forall {m :: * -> *} {c}.
Monad m =>
FunctionVisibility c
-> [Either (ScopedFunction c) (FunctionVisibility c)]
-> m ([ScopedFunction c], [FunctionVisibility c])
merge FunctionVisibility SourceContext
forall c. FunctionVisibility c
FunctionVisibilityDefault where
anyType :: ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
anyType = (ScopedFunction SourceContext
-> Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
-> TextParser (ScopedFunction SourceContext)
-> ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ScopedFunction SourceContext
-> Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext)
forall a b. a -> Either a b
Left TextParser (ScopedFunction SourceContext)
func ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
-> ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
-> ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (FunctionVisibility SourceContext
-> Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
-> TextParser (FunctionVisibility SourceContext)
-> ParsecT
CompilerMessage
String
Identity
(Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext))
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap FunctionVisibility SourceContext
-> Either
(ScopedFunction SourceContext) (FunctionVisibility SourceContext)
forall a b. b -> Either a b
Right TextParser (FunctionVisibility SourceContext)
forall a. ParseFromSource a => TextParser a
sourceParser
merge :: FunctionVisibility c
-> [Either (ScopedFunction c) (FunctionVisibility c)]
-> m ([ScopedFunction c], [FunctionVisibility c])
merge FunctionVisibility c
v0 (Left ScopedFunction c
f:[Either (ScopedFunction c) (FunctionVisibility c)]
ps) = do
([ScopedFunction c]
fs,[FunctionVisibility c]
vs) <- FunctionVisibility c
-> [Either (ScopedFunction c) (FunctionVisibility c)]
-> m ([ScopedFunction c], [FunctionVisibility c])
merge FunctionVisibility c
v0 [Either (ScopedFunction c) (FunctionVisibility c)]
ps
([ScopedFunction c], [FunctionVisibility c])
-> m ([ScopedFunction c], [FunctionVisibility c])
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (FunctionVisibility c -> ScopedFunction c -> ScopedFunction c
forall {c}.
FunctionVisibility c -> ScopedFunction c -> ScopedFunction c
setVis FunctionVisibility c
v0 ScopedFunction c
fScopedFunction c -> [ScopedFunction c] -> [ScopedFunction c]
forall a. a -> [a] -> [a]
:[ScopedFunction c]
fs,[FunctionVisibility c]
vs)
merge FunctionVisibility c
_ (Right FunctionVisibility c
v:[Either (ScopedFunction c) (FunctionVisibility c)]
ps) = do
([ScopedFunction c]
fs,[FunctionVisibility c]
vs) <- FunctionVisibility c
-> [Either (ScopedFunction c) (FunctionVisibility c)]
-> m ([ScopedFunction c], [FunctionVisibility c])
merge FunctionVisibility c
v [Either (ScopedFunction c) (FunctionVisibility c)]
ps
([ScopedFunction c], [FunctionVisibility c])
-> m ([ScopedFunction c], [FunctionVisibility c])
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([ScopedFunction c]
fs,FunctionVisibility c
vFunctionVisibility c
-> [FunctionVisibility c] -> [FunctionVisibility c]
forall a. a -> [a] -> [a]
:[FunctionVisibility c]
vs)
merge FunctionVisibility c
_ [Either (ScopedFunction c) (FunctionVisibility c)]
_ = ([ScopedFunction c], [FunctionVisibility c])
-> m ([ScopedFunction c], [FunctionVisibility c])
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([],[])
setVis :: FunctionVisibility c -> ScopedFunction c -> ScopedFunction c
setVis FunctionVisibility c
v (ScopedFunction [c]
c FunctionName
n CategoryName
t SymbolScope
s FunctionVisibility c
_ Positional (PassedValue c, Maybe (CallArgLabel c))
as Positional (PassedValue c)
rs Positional (ValueParam c)
ps [ParamFilter c]
fs [ScopedFunction c]
ms) = ([c]
-> FunctionName
-> CategoryName
-> SymbolScope
-> FunctionVisibility c
-> Positional (PassedValue c, Maybe (CallArgLabel c))
-> Positional (PassedValue c)
-> Positional (ValueParam c)
-> [ParamFilter c]
-> [ScopedFunction c]
-> ScopedFunction c
forall c.
[c]
-> FunctionName
-> CategoryName
-> SymbolScope
-> FunctionVisibility c
-> Positional (PassedValue c, Maybe (CallArgLabel c))
-> Positional (PassedValue c)
-> Positional (ValueParam c)
-> [ParamFilter c]
-> [ScopedFunction c]
-> ScopedFunction c
ScopedFunction [c]
c FunctionName
n CategoryName
t SymbolScope
s FunctionVisibility c
v Positional (PassedValue c, Maybe (CallArgLabel c))
as Positional (PassedValue c)
rs Positional (ValueParam c)
ps [ParamFilter c]
fs [ScopedFunction c]
ms)
parseScopedFunction ::
TextParser SymbolScope -> TextParser CategoryName -> TextParser (ScopedFunction SourceContext)
parseScopedFunction :: TextParser SymbolScope
-> TextParser CategoryName
-> TextParser (ScopedFunction SourceContext)
parseScopedFunction TextParser SymbolScope
sp TextParser CategoryName
tp = String
-> TextParser (ScopedFunction SourceContext)
-> TextParser (ScopedFunction SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"function" (TextParser (ScopedFunction SourceContext)
-> TextParser (ScopedFunction SourceContext))
-> TextParser (ScopedFunction SourceContext)
-> TextParser (ScopedFunction SourceContext)
forall a b. (a -> b) -> a -> b
$ do
SourceContext
c <- TextParser SourceContext
getSourceContext
(SymbolScope
s,CategoryName
t,FunctionName
n) <- ParsecT
CompilerMessage
String
Identity
(SymbolScope, CategoryName, FunctionName)
-> ParsecT
CompilerMessage
String
Identity
(SymbolScope, CategoryName, FunctionName)
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try ParsecT
CompilerMessage
String
Identity
(SymbolScope, CategoryName, FunctionName)
parseName
Positional (ValueParam SourceContext)
ps <- ([ValueParam SourceContext]
-> Positional (ValueParam SourceContext))
-> TextParser [ValueParam SourceContext]
-> ParsecT
CompilerMessage
String
Identity
(Positional (ValueParam SourceContext))
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [ValueParam SourceContext] -> Positional (ValueParam SourceContext)
forall a. [a] -> Positional a
Positional (TextParser [ValueParam SourceContext]
-> ParsecT
CompilerMessage
String
Identity
(Positional (ValueParam SourceContext)))
-> TextParser [ValueParam SourceContext]
-> ParsecT
CompilerMessage
String
Identity
(Positional (ValueParam SourceContext))
forall a b. (a -> b) -> a -> b
$ TextParser [ValueParam SourceContext]
forall {a}. ParsecT CompilerMessage String Identity [a]
noParams TextParser [ValueParam SourceContext]
-> TextParser [ValueParam SourceContext]
-> TextParser [ValueParam SourceContext]
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser [ValueParam SourceContext]
someParams
[ParamFilter SourceContext]
fa <- TextParser [ParamFilter SourceContext]
parseFilters
Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
as <- ([(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))]
-> Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext)))
-> ParsecT
CompilerMessage
String
Identity
[(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))]
-> ParsecT
CompilerMessage
String
Identity
(Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext)))
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))]
-> Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
forall a. [a] -> Positional a
Positional (ParsecT
CompilerMessage
String
Identity
[(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))]
-> ParsecT
CompilerMessage
String
Identity
(Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))))
-> ParsecT
CompilerMessage
String
Identity
[(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))]
-> ParsecT
CompilerMessage
String
Identity
(Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext)))
forall a b. (a -> b) -> a -> b
$ String
-> TextParser
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
-> ParsecT
CompilerMessage
String
Identity
[(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))]
forall {a}.
String
-> TextParser a -> ParsecT CompilerMessage String Identity [a]
typeList String
"arg label" TextParser
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
singleArg
ParsecT CompilerMessage String Identity (Tokens String)
-> TextParser ()
forall a.
ParsecT CompilerMessage String Identity a -> TextParser ()
sepAfter_ (Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
"->")
Positional (PassedValue SourceContext)
rs <- ([PassedValue SourceContext]
-> Positional (PassedValue SourceContext))
-> ParsecT
CompilerMessage String Identity [PassedValue SourceContext]
-> ParsecT
CompilerMessage
String
Identity
(Positional (PassedValue SourceContext))
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap [PassedValue SourceContext]
-> Positional (PassedValue SourceContext)
forall a. [a] -> Positional a
Positional (ParsecT
CompilerMessage String Identity [PassedValue SourceContext]
-> ParsecT
CompilerMessage
String
Identity
(Positional (PassedValue SourceContext)))
-> ParsecT
CompilerMessage String Identity [PassedValue SourceContext]
-> ParsecT
CompilerMessage
String
Identity
(Positional (PassedValue SourceContext))
forall a b. (a -> b) -> a -> b
$ String
-> TextParser (PassedValue SourceContext)
-> ParsecT
CompilerMessage String Identity [PassedValue SourceContext]
forall {a}.
String
-> TextParser a -> ParsecT CompilerMessage String Identity [a]
typeList String
"return type" TextParser (PassedValue SourceContext)
singleReturn
ScopedFunction SourceContext
-> TextParser (ScopedFunction SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (ScopedFunction SourceContext
-> TextParser (ScopedFunction SourceContext))
-> ScopedFunction SourceContext
-> TextParser (ScopedFunction SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> FunctionName
-> CategoryName
-> SymbolScope
-> FunctionVisibility SourceContext
-> Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
-> Positional (PassedValue SourceContext)
-> Positional (ValueParam SourceContext)
-> [ParamFilter SourceContext]
-> [ScopedFunction SourceContext]
-> ScopedFunction SourceContext
forall c.
[c]
-> FunctionName
-> CategoryName
-> SymbolScope
-> FunctionVisibility c
-> Positional (PassedValue c, Maybe (CallArgLabel c))
-> Positional (PassedValue c)
-> Positional (ValueParam c)
-> [ParamFilter c]
-> [ScopedFunction c]
-> ScopedFunction c
ScopedFunction [SourceContext
c] FunctionName
n CategoryName
t SymbolScope
s FunctionVisibility SourceContext
forall c. FunctionVisibility c
FunctionVisibilityDefault Positional
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
as Positional (PassedValue SourceContext)
rs Positional (ValueParam SourceContext)
ps [ParamFilter SourceContext]
fa []
where
parseName :: ParsecT
CompilerMessage
String
Identity
(SymbolScope, CategoryName, FunctionName)
parseName = do
SymbolScope
s <- TextParser SymbolScope
sp
CategoryName
t <- TextParser CategoryName
tp
FunctionName
n <- TextParser FunctionName
forall a. ParseFromSource a => TextParser a
sourceParser
(SymbolScope, CategoryName, FunctionName)
-> ParsecT
CompilerMessage
String
Identity
(SymbolScope, CategoryName, FunctionName)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (SymbolScope
s,CategoryName
t,FunctionName
n)
noParams :: ParsecT CompilerMessage String Identity [a]
noParams = ParsecT CompilerMessage String Identity (Tokens String)
-> TextParser ()
forall a.
ParsecT CompilerMessage String Identity a -> TextParser ()
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m ()
notFollowedBy (Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
"<") TextParser ()
-> ParsecT CompilerMessage String Identity [a]
-> ParsecT CompilerMessage String Identity [a]
forall a b.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> [a] -> ParsecT CompilerMessage String Identity [a]
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return []
someParams :: TextParser [ValueParam SourceContext]
someParams = TextParser ()
-> TextParser ()
-> TextParser [ValueParam SourceContext]
-> TextParser [ValueParam SourceContext]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"<")
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
">")
(ParsecT CompilerMessage String Identity (ValueParam SourceContext)
-> ParsecT CompilerMessage String Identity (Tokens String)
-> TextParser [ValueParam SourceContext]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy ParsecT CompilerMessage String Identity (ValueParam SourceContext)
singleParam (ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String)
forall a. TextParser a -> TextParser a
sepAfter (ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String))
-> ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String)
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
","))
singleParam :: ParsecT CompilerMessage String Identity (ValueParam SourceContext)
singleParam = String
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext)
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext)
forall a. String -> TextParser a -> TextParser a
labeled String
"param declaration" (ParsecT CompilerMessage String Identity (ValueParam SourceContext)
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext))
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext)
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext)
forall a b. (a -> b) -> a -> b
$ do
TextParser ()
noParamSelf
SourceContext
c <- TextParser SourceContext
getSourceContext
ParamName
n <- TextParser ParamName
forall a. ParseFromSource a => TextParser a
sourceParser
ValueParam SourceContext
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (ValueParam SourceContext
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext))
-> ValueParam SourceContext
-> ParsecT
CompilerMessage String Identity (ValueParam SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext]
-> ParamName -> Variance -> ValueParam SourceContext
forall c. [c] -> ParamName -> Variance -> ValueParam c
ValueParam [SourceContext
c] ParamName
n Variance
Invariant
typeList :: String
-> TextParser a -> ParsecT CompilerMessage String Identity [a]
typeList String
l TextParser a
parseVal = TextParser ()
-> TextParser ()
-> ParsecT CompilerMessage String Identity [a]
-> ParsecT CompilerMessage String Identity [a]
forall (m :: * -> *) open close a.
Applicative m =>
m open -> m close -> m a -> m a
between (TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
"(")
(TextParser () -> TextParser ()
forall a. TextParser a -> TextParser a
sepAfter (TextParser () -> TextParser ()) -> TextParser () -> TextParser ()
forall a b. (a -> b) -> a -> b
$ String -> TextParser ()
string_ String
")")
(TextParser a
-> ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity [a]
forall (m :: * -> *) a sep. MonadPlus m => m a -> m sep -> m [a]
sepBy (String -> TextParser a -> TextParser a
forall a. String -> TextParser a -> TextParser a
labeled String
l (TextParser a -> TextParser a) -> TextParser a -> TextParser a
forall a b. (a -> b) -> a -> b
$ TextParser a
parseVal) (ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String)
forall a. TextParser a -> TextParser a
sepAfter (ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String))
-> ParsecT CompilerMessage String Identity (Tokens String)
-> ParsecT CompilerMessage String Identity (Tokens String)
forall a b. (a -> b) -> a -> b
$ Tokens String
-> ParsecT CompilerMessage String Identity (Tokens String)
forall e s (m :: * -> *).
MonadParsec e s m =>
Tokens s -> m (Tokens s)
string String
Tokens String
","))
singleArg :: TextParser
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
singleArg = do
SourceContext
c <- TextParser SourceContext
getSourceContext
ValueType
t <- TextParser ValueType
forall a. ParseFromSource a => TextParser a
sourceParser
TextParser ()
optionalSpace
Maybe (CallArgLabel SourceContext)
n <- (CallArgLabel SourceContext -> Maybe (CallArgLabel SourceContext))
-> TextParser (CallArgLabel SourceContext)
-> ParsecT
CompilerMessage
String
Identity
(Maybe (CallArgLabel SourceContext))
forall a b.
(a -> b)
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap CallArgLabel SourceContext -> Maybe (CallArgLabel SourceContext)
forall a. a -> Maybe a
Just TextParser (CallArgLabel SourceContext)
forall a. ParseFromSource a => TextParser a
sourceParser ParsecT
CompilerMessage
String
Identity
(Maybe (CallArgLabel SourceContext))
-> ParsecT
CompilerMessage
String
Identity
(Maybe (CallArgLabel SourceContext))
-> ParsecT
CompilerMessage
String
Identity
(Maybe (CallArgLabel SourceContext))
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Maybe (CallArgLabel SourceContext)
-> ParsecT
CompilerMessage
String
Identity
(Maybe (CallArgLabel SourceContext))
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (CallArgLabel SourceContext)
forall a. Maybe a
Nothing
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
-> TextParser
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return ((PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
-> TextParser
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext)))
-> (PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
-> TextParser
(PassedValue SourceContext, Maybe (CallArgLabel SourceContext))
forall a b. (a -> b) -> a -> b
$ ([SourceContext] -> ValueType -> PassedValue SourceContext
forall c. [c] -> ValueType -> PassedValue c
PassedValue [SourceContext
c] ValueType
t,Maybe (CallArgLabel SourceContext)
n)
singleReturn :: TextParser (PassedValue SourceContext)
singleReturn = do
SourceContext
c <- TextParser SourceContext
getSourceContext
ValueType
t <- TextParser ValueType
forall a. ParseFromSource a => TextParser a
sourceParser
PassedValue SourceContext -> TextParser (PassedValue SourceContext)
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return (PassedValue SourceContext
-> TextParser (PassedValue SourceContext))
-> PassedValue SourceContext
-> TextParser (PassedValue SourceContext)
forall a b. (a -> b) -> a -> b
$ [SourceContext] -> ValueType -> PassedValue SourceContext
forall c. [c] -> ValueType -> PassedValue c
PassedValue [SourceContext
c] ValueType
t
parseScope :: TextParser SymbolScope
parseScope :: TextParser SymbolScope
parseScope = TextParser SymbolScope -> TextParser SymbolScope
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try TextParser SymbolScope
categoryScope TextParser SymbolScope
-> TextParser SymbolScope -> TextParser SymbolScope
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser SymbolScope -> TextParser SymbolScope
forall a. TextParser a -> TextParser a
forall e s (m :: * -> *) a. MonadParsec e s m => m a -> m a
try TextParser SymbolScope
typeScope TextParser SymbolScope
-> TextParser SymbolScope -> TextParser SymbolScope
forall a.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> TextParser SymbolScope
valueScope
categoryScope :: TextParser SymbolScope
categoryScope :: TextParser SymbolScope
categoryScope = TextParser ()
kwCategory TextParser () -> TextParser SymbolScope -> TextParser SymbolScope
forall a b.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SymbolScope -> TextParser SymbolScope
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
CategoryScope
typeScope :: TextParser SymbolScope
typeScope :: TextParser SymbolScope
typeScope = TextParser ()
kwType TextParser () -> TextParser SymbolScope -> TextParser SymbolScope
forall a b.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SymbolScope -> TextParser SymbolScope
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
TypeScope
valueScope :: TextParser SymbolScope
valueScope :: TextParser SymbolScope
valueScope = TextParser ()
kwValue TextParser () -> TextParser SymbolScope -> TextParser SymbolScope
forall a b.
ParsecT CompilerMessage String Identity a
-> ParsecT CompilerMessage String Identity b
-> ParsecT CompilerMessage String Identity b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SymbolScope -> TextParser SymbolScope
forall a. a -> ParsecT CompilerMessage String Identity a
forall (m :: * -> *) a. Monad m => a -> m a
return SymbolScope
ValueScope