{-#LANGUAGE TupleSections #-}
{-#LANGUAGE OverloadedStrings #-}
{-#LANGUAGE ScopedTypeVariables #-}
{-#LANGUAGE DeriveGeneric #-}
{-#LANGUAGE FlexibleInstances #-}
{-#LANGUAGE MultiParamTypeClasses #-}
module Text.Ginger.Parse
( parseGinger
, parseGingerFile
, parseGinger'
, parseGingerFile'
, ParserError (..)
, ParserOptions (..)
, mkParserOptions
, Delimiters (..)
, defDelimiters
, formatParserError
, IncludeResolver
, Source, SourceName
, SourcePos (..)
, sourceName
, sourceLine
, sourceColumn
, setSourceName
)
where
import Text.Parsec ( ParseError (..)
, SourcePos (..)
, SourceName (..)
, sourceName
, sourceLine
, sourceColumn
, setSourceName
, ParsecT
, runParserT
, try, lookAhead
, manyTill, oneOf, string, notFollowedBy, between, sepBy
, eof, space, spaces, anyChar, noneOf, char
, choice, option, optionMaybe
, unexpected
, digit
, getState, modifyState, putState
, (<?>)
, getPosition
)
import Text.Parsec.Error ( errorMessages
, errorPos
, showErrorMessages
)
import Text.Ginger.AST
import Text.Ginger.Html ( unsafeRawHtml )
import Text.Ginger.GVal (GVal, ToGVal (..), dict, (~>))
import Control.Monad (when)
import Control.Monad.Reader ( ReaderT
, runReaderT
, ask, asks
)
import Control.Monad.Trans.Class ( lift )
import Control.Applicative
import Control.Exception (Exception)
import GHC.Generics
import Safe ( readMay )
import Data.Text (Text)
import Data.Maybe ( fromMaybe, catMaybes, listToMaybe )
import Data.Scientific ( Scientific )
import qualified Data.Text as Text
import Data.List ( foldr, nub, sort )
import Data.HashMap.Strict (HashMap)
import qualified Data.HashMap.Strict as HashMap
import Data.Default ( Default (..) )
import Data.Monoid ( (<>) )
import Data.Char (isSpace)
import System.FilePath ( takeDirectory, (</>) )
import Text.Printf ( printf )
type Source = String
type IncludeResolver m = SourceName -> m (Maybe Source)
instance ToGVal m SourcePos where
toGVal :: SourcePos -> GVal m
toGVal SourcePos
p =
[Pair m] -> GVal m
forall (m :: * -> *). [Pair m] -> GVal m
dict [ VarName
"name" VarName -> SourceName -> Pair m
forall (m :: * -> *) a. ToGVal m a => VarName -> a -> Pair m
~> SourcePos -> SourceName
sourceName SourcePos
p
, VarName
"line" VarName -> Line -> Pair m
forall (m :: * -> *) a. ToGVal m a => VarName -> a -> Pair m
~> SourcePos -> Line
sourceLine SourcePos
p
, VarName
"column" VarName -> Line -> Pair m
forall (m :: * -> *) a. ToGVal m a => VarName -> a -> Pair m
~> SourcePos -> Line
sourceColumn SourcePos
p
]
data ParserError =
ParserError
{ ParserError -> SourceName
peErrorMessage :: String
, ParserError -> Maybe SourcePos
peSourcePosition :: Maybe SourcePos
}
deriving (Line -> ParserError -> ShowS
[ParserError] -> ShowS
ParserError -> SourceName
(Line -> ParserError -> ShowS)
-> (ParserError -> SourceName)
-> ([ParserError] -> ShowS)
-> Show ParserError
forall a.
(Line -> a -> ShowS)
-> (a -> SourceName) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Line -> ParserError -> ShowS
showsPrec :: Line -> ParserError -> ShowS
$cshow :: ParserError -> SourceName
show :: ParserError -> SourceName
$cshowList :: [ParserError] -> ShowS
showList :: [ParserError] -> ShowS
Show, (forall x. ParserError -> Rep ParserError x)
-> (forall x. Rep ParserError x -> ParserError)
-> Generic ParserError
forall x. Rep ParserError x -> ParserError
forall x. ParserError -> Rep ParserError x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ParserError -> Rep ParserError x
from :: forall x. ParserError -> Rep ParserError x
$cto :: forall x. Rep ParserError x -> ParserError
to :: forall x. Rep ParserError x -> ParserError
Generic)
instance Exception ParserError where
formatParserError :: Maybe String
-> ParserError
-> String
formatParserError :: Maybe SourceName -> ParserError -> SourceName
formatParserError Maybe SourceName
tplSrc ParserError
e =
let sourceLocation :: Maybe SourceName
sourceLocation = do
SourcePos
pos <- ParserError -> Maybe SourcePos
peSourcePosition ParserError
e
SourceName -> Maybe SourceName
forall a. a -> Maybe a
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceName -> Maybe SourceName) -> SourceName -> Maybe SourceName
forall a b. (a -> b) -> a -> b
$ SourceName -> SourceName -> Line -> Line -> SourceName
forall r. PrintfType r => SourceName -> r
printf SourceName
"%s:%i:%i\n"
(SourcePos -> SourceName
sourceName SourcePos
pos)
(SourcePos -> Line
sourceLine SourcePos
pos)
(SourcePos -> Line
sourceColumn SourcePos
pos)
markerLines :: Maybe SourceName
markerLines = do
[SourceName]
sourceLines <- SourceName -> [SourceName]
lines (SourceName -> [SourceName])
-> Maybe SourceName -> Maybe [SourceName]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe SourceName
tplSrc
SourcePos
pos <- ParserError -> Maybe SourcePos
peSourcePosition ParserError
e
let lineNum :: Line
lineNum = SourcePos -> Line
sourceLine SourcePos
pos
SourceName
offendingLine <- [SourceName] -> Maybe SourceName
forall a. [a] -> Maybe a
listToMaybe ([SourceName] -> Maybe SourceName)
-> ([SourceName] -> [SourceName])
-> [SourceName]
-> Maybe SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Line -> [SourceName] -> [SourceName]
forall a. Line -> [a] -> [a]
drop (Line -> Line
forall a. Enum a => a -> a
pred Line
lineNum) ([SourceName] -> Maybe SourceName)
-> [SourceName] -> Maybe SourceName
forall a b. (a -> b) -> a -> b
$ [SourceName]
sourceLines
let offendingColumn :: Line
offendingColumn = SourcePos -> Line
sourceColumn SourcePos
pos
SourceName -> Maybe SourceName
forall a. a -> Maybe a
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceName -> Maybe SourceName)
-> ([SourceName] -> SourceName) -> [SourceName] -> Maybe SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [SourceName] -> SourceName
unlines ([SourceName] -> Maybe SourceName)
-> [SourceName] -> Maybe SourceName
forall a b. (a -> b) -> a -> b
$
[ SourceName
offendingLine
, (Line -> Char -> SourceName
forall a. Line -> a -> [a]
replicate (Line -> Line
forall a. Enum a => a -> a
pred Line
offendingColumn) Char
' ') SourceName -> ShowS
forall a. Semigroup a => a -> a -> a
<> SourceName
"^"
]
in [SourceName] -> SourceName
unlines ([SourceName] -> SourceName)
-> ([Maybe SourceName] -> [SourceName])
-> [Maybe SourceName]
-> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Maybe SourceName] -> [SourceName]
forall a. [Maybe a] -> [a]
catMaybes ([Maybe SourceName] -> SourceName)
-> [Maybe SourceName] -> SourceName
forall a b. (a -> b) -> a -> b
$
[ Maybe SourceName
sourceLocation
, Maybe SourceName
markerLines
, SourceName -> Maybe SourceName
forall a. a -> Maybe a
Just (ParserError -> SourceName
peErrorMessage ParserError
e)
]
fromParsecError :: ParseError -> ParserError
fromParsecError :: ParseError -> ParserError
fromParsecError ParseError
e =
SourceName -> Maybe SourcePos -> ParserError
ParserError
((Char -> Bool) -> ShowS
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\n') ShowS -> ([Message] -> SourceName) -> [Message] -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
SourceName
-> SourceName
-> SourceName
-> SourceName
-> SourceName
-> [Message]
-> SourceName
showErrorMessages
SourceName
"or"
SourceName
"unknown parse error"
SourceName
"expecting"
SourceName
"unexpected"
SourceName
"end of input"
([Message] -> SourceName) -> [Message] -> SourceName
forall a b. (a -> b) -> a -> b
$ ParseError -> [Message]
errorMessages ParseError
e)
(SourcePos -> Maybe SourcePos
forall a. a -> Maybe a
Just (SourcePos -> Maybe SourcePos) -> SourcePos -> Maybe SourcePos
forall a b. (a -> b) -> a -> b
$ ParseError -> SourcePos
errorPos ParseError
e)
parseGingerFile :: forall m. Monad m
=> IncludeResolver m
-> SourceName
-> m (Either ParserError (Template SourcePos))
parseGingerFile :: forall (m :: * -> *).
Monad m =>
IncludeResolver m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGingerFile IncludeResolver m
resolver SourceName
sourceName =
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
forall (m :: * -> *).
Monad m =>
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGingerFile' ParserOptions m
opts SourceName
sourceName
where
opts :: ParserOptions m
opts :: ParserOptions m
opts =
(IncludeResolver m -> ParserOptions m
forall (m :: * -> *).
Monad m =>
IncludeResolver m -> ParserOptions m
mkParserOptions IncludeResolver m
resolver)
{ poSourceName = Just sourceName }
parseGinger :: forall m. Monad m
=> IncludeResolver m
-> Maybe SourceName
-> Source
-> m (Either ParserError (Template SourcePos))
parseGinger :: forall (m :: * -> *).
Monad m =>
IncludeResolver m
-> Maybe SourceName
-> SourceName
-> m (Either ParserError (Template SourcePos))
parseGinger IncludeResolver m
resolver Maybe SourceName
sourceName SourceName
source =
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
forall (m :: * -> *).
Monad m =>
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGinger' ParserOptions m
opts SourceName
source
where
opts :: ParserOptions m
opts :: ParserOptions m
opts =
(IncludeResolver m -> ParserOptions m
forall (m :: * -> *).
Monad m =>
IncludeResolver m -> ParserOptions m
mkParserOptions IncludeResolver m
resolver)
{ poSourceName = sourceName }
parseGingerFile' :: Monad m => ParserOptions m -> SourceName -> m (Either ParserError (Template SourcePos))
parseGingerFile' :: forall (m :: * -> *).
Monad m =>
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGingerFile' ParserOptions m
opts' SourceName
fn = do
let opts :: ParserOptions m
opts = ParserOptions m
opts' { poSourceName = Just fn }
let resolve :: IncludeResolver m
resolve = ParserOptions m -> IncludeResolver m
forall (m :: * -> *). ParserOptions m -> IncludeResolver m
poIncludeResolver ParserOptions m
opts
Maybe SourceName
srcMay <- IncludeResolver m
resolve SourceName
fn
case Maybe SourceName
srcMay of
Maybe SourceName
Nothing -> Either ParserError (Template SourcePos)
-> m (Either ParserError (Template SourcePos))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ParserError (Template SourcePos)
-> m (Either ParserError (Template SourcePos)))
-> (ParserError -> Either ParserError (Template SourcePos))
-> ParserError
-> m (Either ParserError (Template SourcePos))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserError -> Either ParserError (Template SourcePos)
forall a b. a -> Either a b
Left (ParserError -> m (Either ParserError (Template SourcePos)))
-> ParserError -> m (Either ParserError (Template SourcePos))
forall a b. (a -> b) -> a -> b
$
ParserError
{ peErrorMessage :: SourceName
peErrorMessage = SourceName
"Template source not found: " SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
fn
, peSourcePosition :: Maybe SourcePos
peSourcePosition = Maybe SourcePos
forall a. Maybe a
Nothing
}
Just SourceName
src -> ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
forall (m :: * -> *).
Monad m =>
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGinger' ParserOptions m
opts SourceName
src
parseGinger' :: Monad m => ParserOptions m -> Source -> m (Either ParserError (Template SourcePos))
parseGinger' :: forall (m :: * -> *).
Monad m =>
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGinger' ParserOptions m
opts SourceName
src = do
Either ParseError (Template SourcePos)
result <-
ReaderT
(ParserOptions m) m (Either ParseError (Template SourcePos))
-> ParserOptions m -> m (Either ParseError (Template SourcePos))
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT
( ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos)
-> ParseState
-> SourceName
-> SourceName
-> ReaderT
(ParserOptions m) m (Either ParseError (Template SourcePos))
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> u -> SourceName -> s -> m (Either ParseError a)
runParserT
(ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos)
forall (m :: * -> *). Monad m => Parser m (Template SourcePos)
templateP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
`before` ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof)
ParseState
defParseState { psDelimiters = poDelimiters opts }
(SourceName -> Maybe SourceName -> SourceName
forall a. a -> Maybe a -> a
fromMaybe SourceName
"<<unknown>>" (Maybe SourceName -> SourceName) -> Maybe SourceName -> SourceName
forall a b. (a -> b) -> a -> b
$ ParserOptions m -> Maybe SourceName
forall (m :: * -> *). ParserOptions m -> Maybe SourceName
poSourceName ParserOptions m
opts)
SourceName
src
)
ParserOptions m
opts
case Either ParseError (Template SourcePos)
result of
Right Template SourcePos
t -> Either ParserError (Template SourcePos)
-> m (Either ParserError (Template SourcePos))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ParserError (Template SourcePos)
-> m (Either ParserError (Template SourcePos)))
-> (Template SourcePos -> Either ParserError (Template SourcePos))
-> Template SourcePos
-> m (Either ParserError (Template SourcePos))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Template SourcePos -> Either ParserError (Template SourcePos)
forall a b. b -> Either a b
Right (Template SourcePos -> m (Either ParserError (Template SourcePos)))
-> Template SourcePos
-> m (Either ParserError (Template SourcePos))
forall a b. (a -> b) -> a -> b
$ Template SourcePos
t
Left ParseError
e -> Either ParserError (Template SourcePos)
-> m (Either ParserError (Template SourcePos))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Either ParserError (Template SourcePos)
-> m (Either ParserError (Template SourcePos)))
-> (ParserError -> Either ParserError (Template SourcePos))
-> ParserError
-> m (Either ParserError (Template SourcePos))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParserError -> Either ParserError (Template SourcePos)
forall a b. a -> Either a b
Left (ParserError -> m (Either ParserError (Template SourcePos)))
-> ParserError -> m (Either ParserError (Template SourcePos))
forall a b. (a -> b) -> a -> b
$ ParseError -> ParserError
fromParsecError ParseError
e
data Delimiters
= Delimiters
{ Delimiters -> SourceName
delimOpenInterpolation :: String
, Delimiters -> SourceName
delimCloseInterpolation :: String
, Delimiters -> SourceName
delimOpenTag :: String
, Delimiters -> SourceName
delimCloseTag :: String
, :: String
, :: String
}
defDelimiters :: Delimiters
defDelimiters :: Delimiters
defDelimiters
= Delimiters
{ delimOpenInterpolation :: SourceName
delimOpenInterpolation = SourceName
"{{"
, delimCloseInterpolation :: SourceName
delimCloseInterpolation = SourceName
"}}"
, delimOpenTag :: SourceName
delimOpenTag = SourceName
"{%"
, delimCloseTag :: SourceName
delimCloseTag = SourceName
"%}"
, delimOpenComment :: SourceName
delimOpenComment = SourceName
"{#"
, delimCloseComment :: SourceName
delimCloseComment = SourceName
"#}"
}
data ParserOptions m
= ParserOptions
{
forall (m :: * -> *). ParserOptions m -> IncludeResolver m
poIncludeResolver :: IncludeResolver m
, forall (m :: * -> *). ParserOptions m -> Maybe SourceName
poSourceName :: Maybe SourceName
, forall (m :: * -> *). ParserOptions m -> Bool
poKeepTrailingNewline :: Bool
, forall (m :: * -> *). ParserOptions m -> Bool
poLStripBlocks :: Bool
, forall (m :: * -> *). ParserOptions m -> Bool
poTrimBlocks :: Bool
, forall (m :: * -> *). ParserOptions m -> Delimiters
poDelimiters :: Delimiters
}
mkParserOptions :: Monad m => IncludeResolver m -> ParserOptions m
mkParserOptions :: forall (m :: * -> *).
Monad m =>
IncludeResolver m -> ParserOptions m
mkParserOptions IncludeResolver m
resolver =
ParserOptions
{ poIncludeResolver :: IncludeResolver m
poIncludeResolver = IncludeResolver m
resolver
, poSourceName :: Maybe SourceName
poSourceName = Maybe SourceName
forall a. Maybe a
Nothing
, poKeepTrailingNewline :: Bool
poKeepTrailingNewline = Bool
False
, poLStripBlocks :: Bool
poLStripBlocks = Bool
False
, poTrimBlocks :: Bool
poTrimBlocks = Bool
False
, poDelimiters :: Delimiters
poDelimiters = Delimiters
defDelimiters
}
data ParseState
= ParseState
{ ParseState -> HashMap VarName (Block SourcePos)
psBlocks :: HashMap VarName (Block SourcePos)
, ParseState -> SourceName
psStripIndent :: String
, ParseState -> Delimiters
psDelimiters :: Delimiters
}
defParseState :: ParseState
defParseState :: ParseState
defParseState =
ParseState
{ psBlocks :: HashMap VarName (Block SourcePos)
psBlocks = HashMap VarName (Block SourcePos)
forall k v. HashMap k v
HashMap.empty
, psStripIndent :: SourceName
psStripIndent = SourceName
""
, psDelimiters :: Delimiters
psDelimiters = Delimiters
defDelimiters
}
type Parser m a = ParsecT String ParseState (ReaderT (ParserOptions m) m) a
ignore :: Monad m => m a -> m ()
ignore :: forall (m :: * -> *) a. Monad m => m a -> m ()
ignore = (m a -> m () -> m ()
forall a b. m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> () -> m ()
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
ifFlag :: Monad m => (ParserOptions m -> Bool) -> Parser m () -> Parser m () -> Parser m ()
ifFlag :: forall (m :: * -> *).
Monad m =>
(ParserOptions m -> Bool)
-> Parser m () -> Parser m () -> Parser m ()
ifFlag ParserOptions m -> Bool
flag Parser m ()
yes Parser m ()
no = do
Bool
cond <- (ParserOptions m -> Bool)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ParserOptions m -> Bool
flag
if Bool
cond then Parser m ()
yes else Parser m ()
no
whenFlag :: Monad m => (ParserOptions m -> Bool) -> Parser m () -> Parser m ()
whenFlag :: forall (m :: * -> *).
Monad m =>
(ParserOptions m -> Bool) -> Parser m () -> Parser m ()
whenFlag ParserOptions m -> Bool
flag Parser m ()
yes = do
Bool
cond <- (ParserOptions m -> Bool)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ParserOptions m -> Bool
flag
Bool -> Parser m () -> Parser m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when Bool
cond Parser m ()
yes
unlessFlag :: Monad m => (ParserOptions m -> Bool) -> Parser m () -> Parser m ()
unlessFlag :: forall (m :: * -> *).
Monad m =>
(ParserOptions m -> Bool) -> Parser m () -> Parser m ()
unlessFlag ParserOptions m -> Bool
flag Parser m ()
no = do
Bool
cond <- (ParserOptions m -> Bool)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Bool
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ParserOptions m -> Bool
flag
Bool -> Parser m () -> Parser m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not Bool
cond) Parser m ()
no
getResolver :: Monad m => Parser m (IncludeResolver m)
getResolver :: forall (m :: * -> *). Monad m => Parser m (IncludeResolver m)
getResolver = (ParserOptions m -> IncludeResolver m)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(IncludeResolver m)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ParserOptions m -> IncludeResolver m
forall (m :: * -> *). ParserOptions m -> IncludeResolver m
poIncludeResolver
include :: Monad m => SourceName -> Parser m (Statement SourcePos)
include :: forall (m :: * -> *).
Monad m =>
SourceName -> Parser m (Statement SourcePos)
include SourceName
sourceName =
SourcePos -> Template SourcePos -> Statement SourcePos
forall a. a -> Template a -> Statement a
PreprocessedIncludeS
(SourcePos -> Template SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos -> Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos -> Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Template SourcePos)
forall (m :: * -> *).
Monad m =>
SourceName -> Parser m (Template SourcePos)
includeTemplate SourceName
sourceName
includeTemplate :: Monad m => SourceName -> Parser m (Template SourcePos)
includeTemplate :: forall (m :: * -> *).
Monad m =>
SourceName -> Parser m (Template SourcePos)
includeTemplate SourceName
sourceName = do
IncludeResolver m
resolver <- Parser m (IncludeResolver m)
forall (m :: * -> *). Monad m => Parser m (IncludeResolver m)
getResolver
SourceName
currentSource <- SourceName -> Maybe SourceName -> SourceName
forall a. a -> Maybe a -> a
fromMaybe SourceName
"" (Maybe SourceName -> SourceName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (ParserOptions m -> Maybe SourceName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName)
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
asks ParserOptions m -> Maybe SourceName
forall (m :: * -> *). ParserOptions m -> Maybe SourceName
poSourceName
let includeSourceName :: SourceName
includeSourceName = ShowS
takeDirectory SourceName
currentSource SourceName -> ShowS
</> SourceName
sourceName
ParserOptions m
opts <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(ParserOptions m)
forall r (m :: * -> *). MonadReader r m => m r
ask
Either ParserError (Template SourcePos)
pres <- ReaderT
(ParserOptions m) m (Either ParserError (Template SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Either ParserError (Template SourcePos))
forall (m :: * -> *) a.
Monad m =>
m a -> ParsecT SourceName ParseState m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ReaderT
(ParserOptions m) m (Either ParserError (Template SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Either ParserError (Template SourcePos)))
-> (m (Either ParserError (Template SourcePos))
-> ReaderT
(ParserOptions m) m (Either ParserError (Template SourcePos)))
-> m (Either ParserError (Template SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Either ParserError (Template SourcePos))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m (Either ParserError (Template SourcePos))
-> ReaderT
(ParserOptions m) m (Either ParserError (Template SourcePos))
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (ParserOptions m) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Either ParserError (Template SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Either ParserError (Template SourcePos)))
-> m (Either ParserError (Template SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Either ParserError (Template SourcePos))
forall a b. (a -> b) -> a -> b
$ ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
forall (m :: * -> *).
Monad m =>
ParserOptions m
-> SourceName -> m (Either ParserError (Template SourcePos))
parseGingerFile' ParserOptions m
opts SourceName
includeSourceName
case Either ParserError (Template SourcePos)
pres of
Right Template SourcePos
t -> Template SourcePos -> Parser m (Template SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Template SourcePos
t
Left ParserError
err -> SourceName -> Parser m (Template SourcePos)
forall a.
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. MonadFail m => SourceName -> m a
fail (ParserError -> SourceName
forall a. Show a => a -> SourceName
show ParserError
err)
reduceStatements :: SourcePos -> [(Statement SourcePos)] -> (Statement SourcePos)
reduceStatements :: SourcePos -> [Statement SourcePos] -> Statement SourcePos
reduceStatements SourcePos
pos [] = SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS SourcePos
pos
reduceStatements SourcePos
pos [Statement SourcePos
x] = Statement SourcePos
x
reduceStatements SourcePos
pos [Statement SourcePos]
xs = SourcePos -> [Statement SourcePos] -> Statement SourcePos
forall a. a -> [Statement a] -> Statement a
MultiS SourcePos
pos [Statement SourcePos]
xs
templateP :: Monad m => Parser m (Template SourcePos)
templateP :: forall (m :: * -> *). Monad m => Parser m (Template SourcePos)
templateP = Parser m (Template SourcePos)
forall (m :: * -> *). Monad m => Parser m (Template SourcePos)
derivedTemplateP Parser m (Template SourcePos)
-> Parser m (Template SourcePos) -> Parser m (Template SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Template SourcePos)
forall (m :: * -> *). Monad m => Parser m (Template SourcePos)
baseTemplateP
derivedTemplateP :: Monad m => Parser m (Template SourcePos)
derivedTemplateP :: forall (m :: * -> *). Monad m => Parser m (Template SourcePos)
derivedTemplateP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourceName
parentName <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"extends" ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
stringLiteralP)
Template SourcePos
parentTemplate <- SourceName -> Parser m (Template SourcePos)
forall (m :: * -> *).
Monad m =>
SourceName -> Parser m (Template SourcePos)
includeTemplate SourceName
parentName
HashMap VarName (Block SourcePos)
topLevelBlocks <- [(VarName, Block SourcePos)] -> HashMap VarName (Block SourcePos)
forall k v. (Eq k, Hashable k) => [(k, v)] -> HashMap k v
HashMap.fromList ([(VarName, Block SourcePos)] -> HashMap VarName (Block SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(VarName, Block SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(HashMap VarName (Block SourcePos))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Block SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(VarName, Block SourcePos)]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Block SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (VarName, Block SourcePos)
blockP
HashMap VarName (Block SourcePos)
nestedBlocks <- ParseState -> HashMap VarName (Block SourcePos)
psBlocks (ParseState -> HashMap VarName (Block SourcePos))
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(HashMap VarName (Block SourcePos))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let blocks :: HashMap VarName (Block SourcePos)
blocks = HashMap VarName (Block SourcePos)
topLevelBlocks HashMap VarName (Block SourcePos)
-> HashMap VarName (Block SourcePos)
-> HashMap VarName (Block SourcePos)
forall a. Semigroup a => a -> a -> a
<> HashMap VarName (Block SourcePos)
nestedBlocks
Template SourcePos -> Parser m (Template SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return
Template
{ templateBody :: Statement SourcePos
templateBody = SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS SourcePos
pos
, templateParent :: Maybe (Template SourcePos)
templateParent = Template SourcePos -> Maybe (Template SourcePos)
forall a. a -> Maybe a
Just Template SourcePos
parentTemplate
, templateBlocks :: HashMap VarName (Block SourcePos)
templateBlocks = HashMap VarName (Block SourcePos)
blocks
}
baseTemplateP :: Monad m => Parser m (Template SourcePos)
baseTemplateP :: forall (m :: * -> *). Monad m => Parser m (Template SourcePos)
baseTemplateP = do
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
HashMap VarName (Block SourcePos)
blocks <- ParseState -> HashMap VarName (Block SourcePos)
psBlocks (ParseState -> HashMap VarName (Block SourcePos))
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(HashMap VarName (Block SourcePos))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Template SourcePos -> Parser m (Template SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return
Template
{ templateBody :: Statement SourcePos
templateBody = Statement SourcePos
body
, templateParent :: Maybe (Template SourcePos)
templateParent = Maybe (Template SourcePos)
forall a. Maybe a
Nothing
, templateBlocks :: HashMap VarName (Block SourcePos)
templateBlocks = HashMap VarName (Block SourcePos)
blocks
}
isNullS :: Statement a -> Bool
isNullS (NullS a
_) = Bool
True
isNullS Statement a
_ = Bool
False
statementsP :: Monad m => Parser m (Statement SourcePos)
statementsP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourcePos -> [Statement SourcePos] -> Statement SourcePos
reduceStatements SourcePos
pos ([Statement SourcePos] -> Statement SourcePos)
-> ([Statement SourcePos] -> [Statement SourcePos])
-> [Statement SourcePos]
-> Statement SourcePos
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Statement SourcePos -> Bool)
-> [Statement SourcePos] -> [Statement SourcePos]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (Statement SourcePos -> Bool) -> Statement SourcePos -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Statement SourcePos -> Bool
forall {a}. Statement a -> Bool
isNullS) ([Statement SourcePos] -> Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Statement SourcePos]
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Statement SourcePos]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementP)
scriptStatementsP :: Monad m => Parser m (Statement SourcePos)
scriptStatementsP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementsP = do
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourcePos -> [Statement SourcePos] -> Statement SourcePos
reduceStatements SourcePos
pos ([Statement SourcePos] -> Statement SourcePos)
-> ([Statement SourcePos] -> [Statement SourcePos])
-> [Statement SourcePos]
-> Statement SourcePos
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Statement SourcePos -> Bool)
-> [Statement SourcePos] -> [Statement SourcePos]
forall a. (a -> Bool) -> [a] -> [a]
filter (Bool -> Bool
not (Bool -> Bool)
-> (Statement SourcePos -> Bool) -> Statement SourcePos -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Statement SourcePos -> Bool
forall {a}. Statement a -> Bool
isNullS) ([Statement SourcePos] -> Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Statement SourcePos]
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>
Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Statement SourcePos]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP)
scriptStatementBlockP :: Monad m => Parser m (Statement SourcePos)
scriptStatementBlockP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementBlockP = do
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'{'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
inner <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementsP
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Statement SourcePos
inner
statementP :: Monad m => Parser m (Statement SourcePos)
statementP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementP = Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
interpolationStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
commentStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
tryCatchStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
ifStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
switchStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
setStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
forStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
includeP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
macroStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
blockStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
callStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scopeStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
indentStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
literalStmtP
scriptStatementP :: Monad m => Parser m (Statement SourcePos)
scriptStatementP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP = Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementBlockP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptEchoStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptIfStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptSwitchStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptSetStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptForStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptIncludeP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptMacroStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptScopeStmtP
Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptExprStmtP
interpolationStmtP :: Monad m => Parser m (Statement SourcePos)
interpolationStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
interpolationStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
openInterpolationP
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
expr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
closeInterpolationP
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> Expression SourcePos -> Statement SourcePos
forall a. a -> Expression a -> Statement a
InterpolationS SourcePos
pos Expression SourcePos
expr
scriptEchoStmtP :: Monad m => Parser m (Statement SourcePos)
scriptEchoStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptEchoStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"echo"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
Expression SourcePos
expr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
';'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> Expression SourcePos -> Statement SourcePos
forall a. a -> Expression a -> Statement a
InterpolationS SourcePos
pos Expression SourcePos
expr
literalStmtP :: Monad m => Parser m (Statement SourcePos)
literalStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
literalStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourceName
txt <- [SourceName] -> SourceName
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat ([SourceName] -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [SourceName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [SourceName]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
literalCharsP ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
endOfLiteralP
case SourceName
txt of
[] -> SourceName -> Parser m (Statement SourcePos)
forall s (m :: * -> *) t u a.
Stream s m t =>
SourceName -> ParsecT s u m a
unexpected SourceName
"{{"
SourceName
_ -> Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> (SourceName -> Statement SourcePos)
-> SourceName
-> Parser m (Statement SourcePos)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourcePos -> Html -> Statement SourcePos
forall a. a -> Html -> Statement a
LiteralS SourcePos
pos (Html -> Statement SourcePos)
-> (SourceName -> Html) -> SourceName -> Statement SourcePos
forall b c a. (b -> c) -> (a -> b) -> a -> c
. VarName -> Html
unsafeRawHtml (VarName -> Html) -> (SourceName -> VarName) -> SourceName -> Html
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceName -> VarName
Text.pack (SourceName -> Parser m (Statement SourcePos))
-> SourceName -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
txt
literalCharsP :: Monad m => Parser m [Char]
literalCharsP :: forall (m :: * -> *). Monad m => Parser m SourceName
literalCharsP = do
Delimiters
dlims <- ParseState -> Delimiters
psDelimiters (ParseState -> Delimiters)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) Delimiters
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
let forbiddenChars :: SourceName
forbiddenChars =
ShowS
forall a. Eq a => [a] -> [a]
nub ShowS -> ShowS -> ShowS
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
forall a. Ord a => [a] -> [a]
sort ShowS -> ShowS
forall a b. (a -> b) -> a -> b
$
SourceName
" \t\r\n" SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++
Delimiters -> SourceName
delimOpenInterpolation Delimiters
dlims SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++
Delimiters -> SourceName
delimOpenComment Delimiters
dlims SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++
Delimiters -> SourceName
delimOpenTag Delimiters
dlims
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
noneOf SourceName
forbiddenChars) Parser m SourceName -> Parser m SourceName -> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
((Char -> SourceName)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a b.
(a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Char -> ShowS
forall a. a -> [a] -> [a]
:[]) ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
literalNewlineP) Parser m SourceName -> Parser m SourceName -> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
space Parser m SourceName -> Parser m SourceName -> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
((Char -> SourceName)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a b.
(a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Char -> ShowS
forall a. a -> [a] -> [a]
:[]) ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar)
literalNewlineP :: Monad m => Parser m Char
literalNewlineP :: forall (m :: * -> *). Monad m => Parser m Char
literalNewlineP = do
SourceName
stripStr <- ParseState -> SourceName
psStripIndent (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
Char -> Parser m Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\n'
Bool
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ SourceName -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null SourceName
stripStr) (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName))
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName))
-> (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe SourceName)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
stripStr)
Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\n'
endOfLiteralP :: Monad m => Parser m ()
endOfLiteralP :: forall (m :: * -> *). Monad m => Parser m ()
endOfLiteralP =
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
openInterpolationP) ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
openTagP) ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m a
lookAhead (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
openCommentP) ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t u.
(Stream s m t, Show t) =>
ParsecT s u m ()
eof
commentStmtP :: Monad m => Parser m (Statement SourcePos)
= do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
openCommentP
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [()]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill
( (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
noneOf SourceName
"#" ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'#' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}'))
)
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
closeCommentP)
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS SourcePos
pos
scriptCommentP :: Monad m => Parser m ()
= do
Parser m () -> Parser m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (Parser m () -> Parser m ()) -> Parser m () -> Parser m ()
forall a b. (a -> b) -> a -> b
$ Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'#' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m () -> Parser m ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}')
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
endl
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
spacesOrComment :: Monad m => Parser m ()
= do
Parser m ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [()]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (Parser m ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [()])
-> Parser m ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [()]
forall a b. (a -> b) -> a -> b
$ Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
scriptCommentP Parser m () -> Parser m () -> Parser m ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf SourceName
" \t\r\n" ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m () -> Parser m ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> () -> Parser m ()
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ())
() -> Parser m ()
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
scriptExprStmtP :: Monad m => Parser m (Statement SourcePos)
scriptExprStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptExprStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
expr <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
';'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> Expression SourcePos -> Statement SourcePos
forall a. a -> Expression a -> Statement a
ExpressionS SourcePos
pos Expression SourcePos
expr
endl :: Monad m => Parser m Char
endl :: forall (m :: * -> *). Monad m => Parser m Char
endl = Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\n' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\r' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'\n')
scriptStmtP :: Monad m => Parser m (Statement SourcePos)
scriptStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStmtP =
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement 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
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"script")
(SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endscript")
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementsP
ifStmtP :: Monad m => Parser m (Statement SourcePos)
ifStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
ifStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
condExpr <- SourceName
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"if" Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Statement SourcePos
trueStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
Statement SourcePos
falseStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
elifBranchP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
elseBranchP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
SourceName -> Parser m ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endif"
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Expression a -> Statement a -> Statement a -> Statement a
IfS SourcePos
pos Expression SourcePos
condExpr Statement SourcePos
trueStmt Statement SourcePos
falseStmt
elseBranchP :: Monad m => Parser m (Statement SourcePos)
elseBranchP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
elseBranchP = do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"else"
Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
elifBranchP :: Monad m => Parser m (Statement SourcePos)
elifBranchP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
elifBranchP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
condExpr <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"elif" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Statement SourcePos
trueStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
Statement SourcePos
falseStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
elifBranchP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
elseBranchP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Expression a -> Statement a -> Statement a -> Statement a
IfS SourcePos
pos Expression SourcePos
condExpr Statement SourcePos
trueStmt Statement SourcePos
falseStmt
scriptIfStmtP :: Monad m => Parser m (Statement SourcePos)
scriptIfStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptIfStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"if"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
Expression SourcePos
condExpr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
trueStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
falseStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptElifP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptElseP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Expression a -> Statement a -> Statement a -> Statement a
IfS SourcePos
pos Expression SourcePos
condExpr Statement SourcePos
trueStmt Statement SourcePos
falseStmt
scriptElseP :: Monad m => Parser m (Statement SourcePos)
scriptElseP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptElseP = do
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"else"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
scriptElifP :: Monad m => Parser m (Statement SourcePos)
scriptElifP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptElifP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"elif"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
condExpr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
trueStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
falseStmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptElifP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptElseP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Expression a -> Statement a -> Statement a -> Statement a
IfS SourcePos
pos Expression SourcePos
condExpr Statement SourcePos
trueStmt Statement SourcePos
falseStmt
tryCatchStmtP :: Monad m => Parser m (Statement SourcePos)
tryCatchStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
tryCatchStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"try"
Statement SourcePos
tryS <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
[CatchBlock SourcePos]
catchesS <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(CatchBlock SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[CatchBlock SourcePos]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(CatchBlock SourcePos)
forall (m :: * -> *). Monad m => Parser m (CatchBlock SourcePos)
catchBranchP
Statement SourcePos
finallyS <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
finallyBranchP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endtry"
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Statement SourcePos
-> [CatchBlock SourcePos]
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Statement a -> [CatchBlock a] -> Statement a -> Statement a
TryCatchS SourcePos
pos Statement SourcePos
tryS [CatchBlock SourcePos]
catchesS Statement SourcePos
finallyS
catchBranchP :: Monad m => Parser m (CatchBlock SourcePos)
catchBranchP :: forall (m :: * -> *). Monad m => Parser m (CatchBlock SourcePos)
catchBranchP = do
(Maybe VarName
what, Maybe VarName
captureName) <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall a b. (a -> b) -> a -> b
$
SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"catch" (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Maybe VarName)
catchHeaderP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (Maybe VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Maybe VarName)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe VarName
forall a. Maybe a
Nothing, Maybe VarName
forall a. Maybe a
Nothing))
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
CatchBlock SourcePos -> Parser m (CatchBlock SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (CatchBlock SourcePos -> Parser m (CatchBlock SourcePos))
-> CatchBlock SourcePos -> Parser m (CatchBlock SourcePos)
forall a b. (a -> b) -> a -> b
$ Maybe VarName
-> Maybe VarName -> Statement SourcePos -> CatchBlock SourcePos
forall a.
Maybe VarName -> Maybe VarName -> Statement a -> CatchBlock a
Catch Maybe VarName
what Maybe VarName
captureName Statement SourcePos
body
suchThat :: Monad m => (a -> Bool) -> Parser m a -> Parser m a
suchThat :: forall (m :: * -> *) a.
Monad m =>
(a -> Bool) -> Parser m a -> Parser m a
suchThat a -> Bool
p Parser m a
action = do
a
val <- Parser m a
action
if a -> Bool
p a
val then a -> Parser m a
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return a
val else SourceName -> Parser m a
forall a.
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. MonadFail m => SourceName -> m a
fail SourceName
"Requirement not met"
catchHeaderP :: Monad m => Parser m (Maybe Text, Maybe VarName)
= do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
Maybe VarName
what <- Parser m (Maybe VarName)
forall (m :: * -> *). Monad m => Parser m (Maybe VarName)
catchWhatP
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
Maybe VarName
captureName <- Parser m (Maybe VarName)
forall (m :: * -> *). Monad m => Parser m (Maybe VarName)
catchCaptureP
(Maybe VarName, Maybe VarName)
-> Parser m (Maybe VarName, Maybe VarName)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Maybe VarName, Maybe VarName)
-> Parser m (Maybe VarName, Maybe VarName))
-> (Maybe VarName, Maybe VarName)
-> Parser m (Maybe VarName, Maybe VarName)
forall a b. (a -> b) -> a -> b
$ (Maybe VarName
what, Maybe VarName
captureName)
catchWhatP :: Monad m => Parser m (Maybe Text)
catchWhatP :: forall (m :: * -> *). Monad m => Parser m (Maybe VarName)
catchWhatP =
(Maybe VarName
forall a. Maybe a
Nothing Maybe VarName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall a b.
a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'*') ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(VarName -> Maybe VarName
forall a. a -> Maybe a
Just (VarName -> Maybe VarName)
-> (SourceName -> VarName) -> SourceName -> Maybe VarName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourceName -> VarName
Text.pack (SourceName -> Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
stringLiteralP) ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|>
(VarName -> Maybe VarName
forall a. a -> Maybe a
Just (VarName -> Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP)
catchCaptureP :: Monad m => Parser m (Maybe VarName)
catchCaptureP :: forall (m :: * -> *). Monad m => Parser m (Maybe VarName)
catchCaptureP = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName))
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe VarName)
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
"as" ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
identCharP)
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
finallyBranchP :: Monad m => Parser m (Statement SourcePos)
finallyBranchP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
finallyBranchP = do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"finally"
Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
switchStmtP :: Monad m => Parser m (Statement SourcePos)
switchStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
switchStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
pivotExpr <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"switch" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
[(Expression SourcePos, Statement SourcePos)]
cases <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Expression SourcePos, Statement SourcePos)]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, Statement SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, Statement SourcePos)
switchCaseP
Statement SourcePos
def <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
switchDefaultP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
SourceName -> Parser m ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endswitch"
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> [(Expression SourcePos, Statement SourcePos)]
-> Statement SourcePos
-> Statement SourcePos
forall a.
a
-> Expression a
-> [(Expression a, Statement a)]
-> Statement a
-> Statement a
SwitchS SourcePos
pos Expression SourcePos
pivotExpr [(Expression SourcePos, Statement SourcePos)]
cases Statement SourcePos
def
switchCaseP :: Monad m => Parser m ((Expression SourcePos), (Statement SourcePos))
switchCaseP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, Statement SourcePos)
switchCaseP = do
Expression SourcePos
cmpExpr <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"case" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
SourceName -> Parser m ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endcase"
(Expression SourcePos, Statement SourcePos)
-> Parser m (Expression SourcePos, Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos
cmpExpr, Statement SourcePos
body)
switchDefaultP :: Monad m => Parser m (Statement SourcePos)
switchDefaultP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
switchDefaultP = do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"default") ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP Parser m (Statement SourcePos)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Statement SourcePos)
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"enddefault"
scriptSwitchStmtP :: Monad m => Parser m (Statement SourcePos)
scriptSwitchStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptSwitchStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"switch"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
pivotExpr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'{'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[(Expression SourcePos, Statement SourcePos)]
cases <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Expression SourcePos, Statement SourcePos)]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, Statement SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, Statement SourcePos)
scriptSwitchCaseP
Statement SourcePos
def <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptSwitchDefaultP Parser m (Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Statement SourcePos
forall a. a -> Statement a
NullS (SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'}'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> [(Expression SourcePos, Statement SourcePos)]
-> Statement SourcePos
-> Statement SourcePos
forall a.
a
-> Expression a
-> [(Expression a, Statement a)]
-> Statement a
-> Statement a
SwitchS SourcePos
pos Expression SourcePos
pivotExpr [(Expression SourcePos, Statement SourcePos)]
cases Statement SourcePos
def
scriptSwitchCaseP :: Monad m => Parser m ((Expression SourcePos), (Statement SourcePos))
scriptSwitchCaseP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, Statement SourcePos)
scriptSwitchCaseP = do
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"case"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
cmpExpr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(Expression SourcePos, Statement SourcePos)
-> Parser m (Expression SourcePos, Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos
cmpExpr, Statement SourcePos
body)
scriptSwitchDefaultP :: Monad m => Parser m (Statement SourcePos)
scriptSwitchDefaultP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptSwitchDefaultP = do
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"default"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Statement SourcePos
body
setStmtP :: Monad m => Parser m (Statement SourcePos)
setStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
setStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourceName
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"set" (SourcePos -> Parser m (Statement SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos -> Parser m (Statement SourcePos)
setStmtInnerP SourcePos
pos)
setStmtInnerP :: Monad m => SourcePos -> Parser m (Statement SourcePos)
setStmtInnerP :: forall (m :: * -> *).
Monad m =>
SourcePos -> Parser m (Statement SourcePos)
setStmtInnerP SourcePos
pos = do
VarName
name <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'='
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
val <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> VarName -> Expression SourcePos -> Statement SourcePos
forall a. a -> VarName -> Expression a -> Statement a
SetVarS SourcePos
pos VarName
name Expression SourcePos
val
scriptSetStmtP :: Monad m => Parser m (Statement SourcePos)
scriptSetStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptSetStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"set"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
VarName
name <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'='
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
val <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
';'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> VarName -> Expression SourcePos -> Statement SourcePos
forall a. a -> VarName -> Expression a -> Statement a
SetVarS SourcePos
pos VarName
name Expression SourcePos
val
defineBlock :: VarName -> Block SourcePos -> ParseState -> ParseState
defineBlock :: VarName -> Block SourcePos -> ParseState -> ParseState
defineBlock VarName
name Block SourcePos
block ParseState
s =
ParseState
s { psBlocks = HashMap.insert name block (psBlocks s) }
blockStmtP :: Monad m => Parser m (Statement SourcePos)
blockStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
blockStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
(VarName
name, Block SourcePos
block) <- Parser m (VarName, Block SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (VarName, Block SourcePos)
blockP
(ParseState -> ParseState)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
modifyState (VarName -> Block SourcePos -> ParseState -> ParseState
defineBlock VarName
name Block SourcePos
block)
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> VarName -> Statement SourcePos
forall a. a -> VarName -> Statement a
BlockRefS SourcePos
pos VarName
name
blockP :: Monad m => Parser m (VarName, (Block SourcePos))
blockP :: forall (m :: * -> *).
Monad m =>
Parser m (VarName, Block SourcePos)
blockP = do
VarName
name <- SourceName -> Parser m VarName -> Parser m VarName
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"block" Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
SourceName -> Parser m (Maybe ()) -> Parser m (Maybe ())
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"endblock" (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Maybe ())
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Maybe ()))
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Maybe ())
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string (VarName -> SourceName
Text.unpack VarName
name) ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
(VarName, Block SourcePos) -> Parser m (VarName, Block SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarName
name, Statement SourcePos -> Block SourcePos
forall a. Statement a -> Block a
Block Statement SourcePos
body)
macroStmtP :: Monad m => Parser m (Statement SourcePos)
macroStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
macroStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
(VarName
name, [VarName]
args) <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName]))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"macro" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, [VarName])
forall (m :: * -> *). Monad m => Parser m (VarName, [VarName])
macroHeadP
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
SourceName -> Parser m (Maybe ()) -> Parser m (Maybe ())
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"endmacro" (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Maybe ())
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Maybe ()))
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Maybe ())
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string (VarName -> SourceName
Text.unpack VarName
name) ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> VarName -> Macro SourcePos -> Statement SourcePos
forall a. a -> VarName -> Macro a -> Statement a
DefMacroS SourcePos
pos VarName
name ([VarName] -> Statement SourcePos -> Macro SourcePos
forall a. [VarName] -> Statement a -> Macro a
Macro [VarName]
args Statement SourcePos
body)
scriptMacroStmtP :: Monad m => Parser m (Statement SourcePos)
scriptMacroStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptMacroStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"macro"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
VarName
name <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[VarName]
args <- [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName])
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall a b. (a -> b) -> a -> b
$ SourceName
-> SourceName
-> Parser m VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"(" SourceName
")" Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> VarName -> Macro SourcePos -> Statement SourcePos
forall a. a -> VarName -> Macro a -> Statement a
DefMacroS SourcePos
pos VarName
name ([VarName] -> Statement SourcePos -> Macro SourcePos
forall a. [VarName] -> Statement a -> Macro a
Macro [VarName]
args Statement SourcePos
body)
macroHeadP :: Monad m => Parser m (VarName, [VarName])
macroHeadP :: forall (m :: * -> *). Monad m => Parser m (VarName, [VarName])
macroHeadP = do
VarName
name <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[VarName]
args <- [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName])
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall a b. (a -> b) -> a -> b
$ SourceName
-> SourceName
-> Parser m VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"(" SourceName
")" Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(VarName, [VarName]) -> Parser m (VarName, [VarName])
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarName
name, [VarName]
args)
callStmtP :: Monad m => Parser m (Statement SourcePos)
callStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
callStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
([VarName]
callerArgs, Expression SourcePos
call) <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"call" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([VarName], Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m ([VarName], Expression SourcePos)
callHeadP
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
SourceName -> Parser m ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endcall"
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (
SourcePos -> Statement SourcePos -> Statement SourcePos
forall a. a -> Statement a -> Statement a
ScopedS SourcePos
pos (
SourcePos -> [Statement SourcePos] -> Statement SourcePos
forall a. a -> [Statement a] -> Statement a
MultiS SourcePos
pos
[ SourcePos -> VarName -> Macro SourcePos -> Statement SourcePos
forall a. a -> VarName -> Macro a -> Statement a
DefMacroS SourcePos
pos VarName
"caller" ([VarName] -> Statement SourcePos -> Macro SourcePos
forall a. [VarName] -> Statement a -> Macro a
Macro [VarName]
callerArgs Statement SourcePos
body)
, SourcePos -> Expression SourcePos -> Statement SourcePos
forall a. a -> Expression a -> Statement a
InterpolationS SourcePos
pos Expression SourcePos
call
]))
callHeadP :: Monad m => Parser m ([Text], (Expression SourcePos))
callHeadP :: forall (m :: * -> *).
Monad m =>
Parser m ([VarName], Expression SourcePos)
callHeadP = do
[VarName]
callerArgs <- [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName])
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall a b. (a -> b) -> a -> b
$ SourceName
-> SourceName
-> Parser m VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"(" SourceName
")" Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
call <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
([VarName], Expression SourcePos)
-> Parser m ([VarName], Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ([VarName]
callerArgs, Expression SourcePos
call)
scopeStmtP :: Monad m => Parser m (Statement SourcePos)
scopeStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scopeStmtP =
SourcePos -> Statement SourcePos -> Statement SourcePos
forall a. a -> Statement a -> Statement a
ScopedS
(SourcePos -> Statement SourcePos -> Statement SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos -> Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos -> Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement 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
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"scope")
(SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endscope")
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
indentStmtP :: Monad m => Parser m (Statement SourcePos)
indentStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
indentStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
indentExpr <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"indent" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
indentHeadP
SourceName
preIndent <- ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf SourceName
" \t")
ParseState
oldState <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState
(ParseState -> ParseState)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) u s. Monad m => (u -> u) -> ParsecT s u m ()
modifyState ((ParseState -> ParseState)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParseState -> ParseState)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ \ParseState
state ->
ParseState
state { psStripIndent = preIndent }
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
ParseState
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) u s. Monad m => u -> ParsecT s u m ()
putState ParseState
oldState
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endindent"
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a. a -> Expression a -> Statement a -> Statement a
IndentS SourcePos
pos Expression SourcePos
indentExpr Statement SourcePos
body
indentHeadP :: Monad m => Parser m (Expression SourcePos)
indentHeadP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
indentHeadP =
(Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> VarName -> Expression SourcePos
forall a. a -> VarName -> Expression a
StringLiteralE (SourcePos -> VarName -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName -> Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> Parser m (Expression SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure VarName
" ")) Parser m (Expression SourcePos)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m (Expression SourcePos)
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
scriptScopeStmtP :: Monad m => Parser m (Statement SourcePos)
scriptScopeStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptScopeStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"scope"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourcePos -> Statement SourcePos -> Statement SourcePos
forall a. a -> Statement a -> Statement a
ScopedS SourcePos
pos (Statement SourcePos -> Statement SourcePos)
-> Parser m (Statement SourcePos) -> Parser m (Statement SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
forStmtP :: Monad m => Parser m (Statement SourcePos)
forStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
forStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
(Expression SourcePos
iteree, VarName
varNameVal, Maybe VarName
varNameIndex) <- SourceName
-> Parser m (Expression SourcePos, VarName, Maybe VarName)
-> Parser m (Expression SourcePos, VarName, Maybe VarName)
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"for" Parser m (Expression SourcePos, VarName, Maybe VarName)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadP
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
Maybe (Statement SourcePos)
elseBranchMay <- Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe (Statement SourcePos))
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe (Statement SourcePos)))
-> Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe (Statement SourcePos))
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"else"
Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
statementsP
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
"endfor"
let forLoop :: Statement SourcePos
forLoop = SourcePos
-> Maybe VarName
-> VarName
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a
-> Maybe VarName
-> VarName
-> Expression a
-> Statement a
-> Statement a
ForS SourcePos
pos Maybe VarName
varNameIndex VarName
varNameVal Expression SourcePos
iteree Statement SourcePos
body
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ Statement SourcePos
-> (Statement SourcePos -> Statement SourcePos)
-> Maybe (Statement SourcePos)
-> Statement SourcePos
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
Statement SourcePos
forLoop
(SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Expression a -> Statement a -> Statement a -> Statement a
IfS SourcePos
pos Expression SourcePos
iteree Statement SourcePos
forLoop)
Maybe (Statement SourcePos)
elseBranchMay
scriptForStmtP :: Monad m => Parser m (Statement SourcePos)
scriptForStmtP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptForStmtP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"for"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
(Expression SourcePos
iteree, VarName
varNameVal, Maybe VarName
varNameIndex) <- Parser m (Expression SourcePos, VarName, Maybe VarName)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
body <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Maybe (Statement SourcePos)
elseBranchMay <- Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe (Statement SourcePos))
forall s (m :: * -> *) t u a.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m (Maybe a)
optionMaybe (Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe (Statement SourcePos)))
-> Parser m (Statement SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe (Statement SourcePos))
forall a b. (a -> b) -> a -> b
$ do
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"else"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
let forLoop :: Statement SourcePos
forLoop = SourcePos
-> Maybe VarName
-> VarName
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a
-> Maybe VarName
-> VarName
-> Expression a
-> Statement a
-> Statement a
ForS SourcePos
pos Maybe VarName
varNameIndex VarName
varNameVal Expression SourcePos
iteree Statement SourcePos
body
Statement SourcePos -> Parser m (Statement SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Statement SourcePos -> Parser m (Statement SourcePos))
-> Statement SourcePos -> Parser m (Statement SourcePos)
forall a b. (a -> b) -> a -> b
$ Statement SourcePos
-> (Statement SourcePos -> Statement SourcePos)
-> Maybe (Statement SourcePos)
-> Statement SourcePos
forall b a. b -> (a -> b) -> Maybe a -> b
maybe
Statement SourcePos
forLoop
(SourcePos
-> Expression SourcePos
-> Statement SourcePos
-> Statement SourcePos
-> Statement SourcePos
forall a.
a -> Expression a -> Statement a -> Statement a -> Statement a
IfS SourcePos
pos Expression SourcePos
iteree Statement SourcePos
forLoop)
Maybe (Statement SourcePos)
elseBranchMay
includeP :: Monad m => Parser m (Statement SourcePos)
includeP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
includeP = do
SourceName
sourceName <- SourceName -> Parser m SourceName -> Parser m SourceName
forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
"include" Parser m SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
stringLiteralP
SourceName -> Parser m (Statement SourcePos)
forall (m :: * -> *).
Monad m =>
SourceName -> Parser m (Statement SourcePos)
include SourceName
sourceName
scriptIncludeP :: Monad m => Parser m (Statement SourcePos)
scriptIncludeP :: forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptIncludeP = do
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"include"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
SourceName
sourceName <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
stringLiteralP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
';'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName -> Parser m (Statement SourcePos)
forall (m :: * -> *).
Monad m =>
SourceName -> Parser m (Statement SourcePos)
include SourceName
sourceName
forHeadP :: Monad m => Parser m ((Expression SourcePos), VarName, Maybe VarName)
forHeadP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadP =
(ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadInP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadAsP) ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe ())
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos, VarName, Maybe VarName)
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f a
<* ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe ())
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"recursive" Parser m SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
forIteratorP :: Monad m => Parser m (VarName, Maybe VarName)
forIteratorP :: forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forIteratorP = ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forIndexedIteratorP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forSimpleIteratorP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
-> SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName, Maybe VarName)
forall s u (m :: * -> *) a.
ParsecT s u m a -> SourceName -> ParsecT s u m a
<?> SourceName
"iteration variables"
forIndexedIteratorP :: Monad m => Parser m (VarName, Maybe VarName)
forIndexedIteratorP :: forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forIndexedIteratorP = do
VarName
indexIdent <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
','
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
VarName
varIdent <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(VarName, Maybe VarName) -> Parser m (VarName, Maybe VarName)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarName
varIdent, VarName -> Maybe VarName
forall a. a -> Maybe a
Just VarName
indexIdent)
forSimpleIteratorP :: Monad m => Parser m (VarName, Maybe VarName)
forSimpleIteratorP :: forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forSimpleIteratorP = do
VarName
varIdent <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(VarName, Maybe VarName) -> Parser m (VarName, Maybe VarName)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarName
varIdent, Maybe VarName
forall a. Maybe a
Nothing)
forHeadInP :: Monad m => Parser m ((Expression SourcePos), VarName, Maybe VarName)
forHeadInP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadInP = do
(VarName
varIdent, Maybe VarName
indexIdent) <- Parser m (VarName, Maybe VarName)
forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forIteratorP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"in"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
iteree <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
(Expression SourcePos, VarName, Maybe VarName)
-> Parser m (Expression SourcePos, VarName, Maybe VarName)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos
iteree, VarName
varIdent, Maybe VarName
indexIdent)
forHeadAsP :: Monad m => Parser m ((Expression SourcePos), VarName, Maybe VarName)
forHeadAsP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, VarName, Maybe VarName)
forHeadAsP = do
Expression SourcePos
iteree <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"as"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(VarName
varIdent, Maybe VarName
indexIdent) <- Parser m (VarName, Maybe VarName)
forall (m :: * -> *). Monad m => Parser m (VarName, Maybe VarName)
forIteratorP
(Expression SourcePos, VarName, Maybe VarName)
-> Parser m (Expression SourcePos, VarName, Maybe VarName)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos
iteree, VarName
varIdent, Maybe VarName
indexIdent)
fancyTagP :: Monad m => String -> Parser m a -> Parser m a
fancyTagP :: forall (m :: * -> *) a.
Monad m =>
SourceName -> Parser m a -> Parser m a
fancyTagP SourceName
tagName =
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
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
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
openTagP
SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
tagName
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
closeTagP
simpleTagP :: Monad m => String -> Parser m ()
simpleTagP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
simpleTagP SourceName
tagName = Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
openTagP Parser m ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
tagName ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> Parser m () -> Parser m ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
closeTagP
openInterpolationP :: Monad m => Parser m ()
openInterpolationP :: forall (m :: * -> *). Monad m => Parser m ()
openInterpolationP =
Delimiters -> SourceName
delimOpenInterpolation (Delimiters -> SourceName)
-> (ParseState -> Delimiters) -> ParseState -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseState -> Delimiters
psDelimiters (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openP
closeInterpolationP :: Monad m => Parser m ()
closeInterpolationP :: forall (m :: * -> *). Monad m => Parser m ()
closeInterpolationP =
Delimiters -> SourceName
delimCloseInterpolation (Delimiters -> SourceName)
-> (ParseState -> Delimiters) -> ParseState -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseState -> Delimiters
psDelimiters (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeP
openCommentP :: Monad m => Parser m ()
=
Delimiters -> SourceName
delimOpenComment (Delimiters -> SourceName)
-> (ParseState -> Delimiters) -> ParseState -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseState -> Delimiters
psDelimiters (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openP
closeCommentP :: Monad m => Parser m ()
=
Delimiters -> SourceName
delimCloseComment (Delimiters -> SourceName)
-> (ParseState -> Delimiters) -> ParseState -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseState -> Delimiters
psDelimiters (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeP
openTagP :: Monad m => Parser m ()
openTagP :: forall (m :: * -> *). Monad m => Parser m ()
openTagP =
Delimiters -> SourceName
delimOpenTag (Delimiters -> SourceName)
-> (ParseState -> Delimiters) -> ParseState -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseState -> Delimiters
psDelimiters (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openP
closeTagP :: Monad m => Parser m ()
closeTagP :: forall (m :: * -> *). Monad m => Parser m ()
closeTagP = do
Delimiters -> SourceName
delimCloseTag (Delimiters -> SourceName)
-> (ParseState -> Delimiters) -> ParseState -> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParseState -> Delimiters
psDelimiters (ParseState -> SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ParseState
forall (m :: * -> *) s u. Monad m => ParsecT s u m u
getState ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> (SourceName -> Parser m ()) -> Parser m ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= SourceName -> Parser m ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeP
(ParserOptions m -> Bool) -> Parser m () -> Parser m ()
forall (m :: * -> *).
Monad m =>
(ParserOptions m -> Bool) -> Parser m () -> Parser m ()
unlessFlag ParserOptions m -> Bool
forall (m :: * -> *). ParserOptions m -> Bool
poKeepTrailingNewline
(ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe Char)
-> Parser m ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe Char)
-> Parser m ())
-> (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe Char))
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (Maybe Char)
forall (f :: * -> *) a. Alternative f => f a -> f (Maybe a)
optional (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m ()
forall a b. (a -> b) -> a -> b
$ ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
literalNewlineP)
openP :: Monad m => String -> Parser m ()
openP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openWP SourceName
c)
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openFWP SourceName
c)
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openNWP SourceName
c)
openWP :: Monad m => String -> Parser m ()
openWP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openWP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
c SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
"-"
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
openFWP :: Monad m => String -> Parser m ()
openFWP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openFWP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
c SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
"+"
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
openNWP :: Monad m => String -> Parser m ()
openNWP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
openNWP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
(ParserOptions m -> Bool)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *).
Monad m =>
(ParserOptions m -> Bool) -> Parser m () -> Parser m ()
whenFlag ParserOptions m -> Bool
forall (m :: * -> *). ParserOptions m -> Bool
poLStripBlocks ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
c
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf SourceName
"+-"
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
closeP :: Monad m => String -> Parser m ()
closeP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeWP SourceName
c)
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeFWP SourceName
c)
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeNWP SourceName
c)
closeWP :: Monad m => String -> Parser m ()
closeWP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeWP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ Char
'-'Char -> ShowS
forall a. a -> [a] -> [a]
:SourceName
c
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
closeFWP :: Monad m => String -> Parser m ()
closeFWP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeFWP SourceName
c = ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ Char
'+'Char -> ShowS
forall a. a -> [a] -> [a]
:SourceName
c
closeNWP :: Monad m => String -> Parser m ()
closeNWP :: forall (m :: * -> *). Monad m => SourceName -> Parser m ()
closeNWP SourceName
c = ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ do
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
c
(ParserOptions m -> Bool)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *).
Monad m =>
(ParserOptions m -> Bool) -> Parser m () -> Parser m ()
whenFlag ParserOptions m -> Bool
forall (m :: * -> *). ParserOptions m -> Bool
poTrimBlocks ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m ()
spaces
expressionP :: Monad m => Parser m (Expression SourcePos)
expressionP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP = Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
lambdaExprP Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
ternaryExprP
lambdaExprP :: Monad m => Parser m (Expression SourcePos)
lambdaExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
lambdaExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
[VarName]
argNames <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName])
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall a b. (a -> b) -> a -> b
$ do
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'('
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[VarName]
argNames <- ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy (Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrCommentParser m ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP) (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) Char)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall a b. (a -> b) -> a -> b
$ Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrCommentParser m ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
',')
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
"->"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) [VarName]
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return [VarName]
argNames
Expression SourcePos
body <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> [VarName] -> Expression SourcePos -> Expression SourcePos
forall a. a -> [VarName] -> Expression a -> Expression a
LambdaE SourcePos
pos [VarName]
argNames Expression SourcePos
body
operativeExprP :: forall m. Monad m => Parser m (Expression SourcePos) -> [ (String, Text) ] -> Parser m (Expression SourcePos)
operativeExprP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
operativeExprP Parser m (Expression SourcePos)
operandP [(SourceName, VarName)]
operators = do
SourcePos
pos0 <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
lhs <- Parser m (Expression SourcePos)
operandP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[Expression SourcePos -> Expression SourcePos]
tails <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos])
-> (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos]
forall a b. (a -> b) -> a -> b
$ SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
operativeTail SourcePos
pos0
Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ (Expression SourcePos
-> (Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos)
-> Expression SourcePos
-> [Expression SourcePos -> Expression SourcePos]
-> Expression SourcePos
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (((Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos
-> (Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos -> Expression SourcePos
forall a b. (a -> b) -> a -> b
($)) Expression SourcePos
lhs [Expression SourcePos -> Expression SourcePos]
tails
where
opChars :: [Char]
opChars :: SourceName
opChars = ShowS
forall a. Eq a => [a] -> [a]
nub ShowS
-> ([(SourceName, VarName)] -> SourceName)
-> [(SourceName, VarName)]
-> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShowS
forall a. Ord a => [a] -> [a]
sort ShowS
-> ([(SourceName, VarName)] -> SourceName)
-> [(SourceName, VarName)]
-> SourceName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((SourceName, VarName) -> SourceName)
-> [(SourceName, VarName)] -> SourceName
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap (SourceName, VarName) -> SourceName
forall a b. (a, b) -> a
fst ([(SourceName, VarName)] -> SourceName)
-> [(SourceName, VarName)] -> SourceName
forall a b. (a -> b) -> a -> b
$ [(SourceName, VarName)]
operators
operativeTail :: SourcePos -> Parser m (Expression SourcePos -> Expression SourcePos)
operativeTail :: SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
operativeTail SourcePos
pos0 = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
VarName
funcName <-
(ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> [ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName]
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
(<|>) (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a.
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. MonadFail m => SourceName -> m a
fail SourceName
"operator")
[ Parser m () -> Parser m ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
op ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> Parser m () -> Parser m ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy (SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf SourceName
opChars)) Parser m ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return VarName
fn | (SourceName
op, VarName
fn) <- [(SourceName, VarName)]
operators ]
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
rhs <- Parser m (Expression SourcePos)
operandP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (\Expression SourcePos
lhs -> SourcePos
-> Expression SourcePos
-> [(Maybe VarName, Expression SourcePos)]
-> Expression SourcePos
forall a.
a
-> Expression a -> [(Maybe VarName, Expression a)] -> Expression a
CallE SourcePos
pos0 (SourcePos -> VarName -> Expression SourcePos
forall a. a -> VarName -> Expression a
VarE SourcePos
pos VarName
funcName) [(Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
lhs), (Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
rhs)])
ternaryExprP :: Monad m => Parser m (Expression SourcePos)
ternaryExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
ternaryExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
expr1 <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
booleanExprP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
SourcePos
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Expression SourcePos -> Parser m (Expression SourcePos)
cTernaryTailP SourcePos
pos Expression SourcePos
expr1 Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SourcePos
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Expression SourcePos -> Parser m (Expression SourcePos)
pyTernaryTailP SourcePos
pos Expression SourcePos
expr1 Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Expression SourcePos
expr1
cTernaryTailP :: Monad m => SourcePos -> (Expression SourcePos) -> Parser m (Expression SourcePos)
cTernaryTailP :: forall (m :: * -> *).
Monad m =>
SourcePos
-> Expression SourcePos -> Parser m (Expression SourcePos)
cTernaryTailP SourcePos
pos Expression SourcePos
condition = ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ do
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'?'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
yesBranch <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
noBranch <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Expression SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos))
-> Expression SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Expression SourcePos
-> Expression SourcePos
-> Expression SourcePos
forall a.
a -> Expression a -> Expression a -> Expression a -> Expression a
TernaryE SourcePos
pos Expression SourcePos
condition Expression SourcePos
yesBranch Expression SourcePos
noBranch
pyTernaryTailP :: Monad m => SourcePos -> (Expression SourcePos) -> Parser m (Expression SourcePos)
pyTernaryTailP :: forall (m :: * -> *).
Monad m =>
SourcePos
-> Expression SourcePos -> Parser m (Expression SourcePos)
pyTernaryTailP SourcePos
pos Expression SourcePos
yesBranch = do
SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"if"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
condition <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
booleanExprP
SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"else"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
noBranch <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos
-> Expression SourcePos
-> Expression SourcePos
-> Expression SourcePos
-> Expression SourcePos
forall a.
a -> Expression a -> Expression a -> Expression a -> Expression a
TernaryE SourcePos
pos Expression SourcePos
condition Expression SourcePos
yesBranch Expression SourcePos
noBranch
booleanExprP :: Monad m => Parser m (Expression SourcePos)
booleanExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
booleanExprP =
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
operativeExprP
Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
comparativeExprP
[ (SourceName
"or", VarName
"any")
, (SourceName
"||", VarName
"any")
, (SourceName
"and", VarName
"all")
, (SourceName
"&&", VarName
"all")
]
comparativeExprP :: Monad m => Parser m (Expression SourcePos)
comparativeExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
comparativeExprP =
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
operativeExprP
Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
additiveExprP
[ (SourceName
"==", VarName
"equals")
, (SourceName
"!=", VarName
"nequals")
, (SourceName
">=", VarName
"greaterEquals")
, (SourceName
"<=", VarName
"lessEquals")
, (SourceName
">", VarName
"greater")
, (SourceName
"<", VarName
"less")
]
additiveExprP :: Monad m => Parser m (Expression SourcePos)
additiveExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
additiveExprP =
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
operativeExprP
Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
multiplicativeExprP
[ (SourceName
"+", VarName
"sum")
, (SourceName
"-", VarName
"difference")
, (SourceName
"~", VarName
"concat")
]
multiplicativeExprP :: Monad m => Parser m (Expression SourcePos)
multiplicativeExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
multiplicativeExprP =
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos)
-> [(SourceName, VarName)] -> Parser m (Expression SourcePos)
operativeExprP
Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
postfixExprP
[ (SourceName
"*", VarName
"product")
, (SourceName
"//", VarName
"int_ratio")
, (SourceName
"/", VarName
"ratio")
, (SourceName
"%", VarName
"modulo")
]
postfixExprP :: Monad m => Parser m (Expression SourcePos)
postfixExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
postfixExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Expression SourcePos
base <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
atomicExprP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
[Expression SourcePos -> Expression SourcePos]
postfixes <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos]
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos])
-> (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos -> Expression SourcePos]
forall a b. (a -> b) -> a -> b
$ SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
postfixP SourcePos
pos ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> Parser m ()
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
`before`Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ (Expression SourcePos
-> (Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos)
-> Expression SourcePos
-> [Expression SourcePos -> Expression SourcePos]
-> Expression SourcePos
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl (((Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos
-> (Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Expression SourcePos -> Expression SourcePos)
-> Expression SourcePos -> Expression SourcePos
forall a b. (a -> b) -> a -> b
($)) Expression SourcePos
base [Expression SourcePos -> Expression SourcePos]
postfixes
postfixP :: Monad m => SourcePos -> Parser m ((Expression SourcePos) -> (Expression SourcePos))
postfixP :: forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
postfixP SourcePos
pos = SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
dotPostfixP SourcePos
pos
Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
arrayAccessP
Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
funcCallP
Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
filterP
Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
testExprP
dotPostfixP :: Monad m => SourcePos -> Parser m ((Expression SourcePos) -> (Expression SourcePos))
dotPostfixP :: forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
dotPostfixP SourcePos
pos = do
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
i <- SourcePos -> VarName -> Expression SourcePos
forall a. a -> VarName -> Expression a
StringLiteralE (SourcePos -> VarName -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName -> Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
(Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos))
-> (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ \Expression SourcePos
e -> SourcePos
-> Expression SourcePos
-> Expression SourcePos
-> Expression SourcePos
forall a. a -> Expression a -> Expression a -> Expression a
MemberLookupE SourcePos
pos Expression SourcePos
e Expression SourcePos
i
arrayAccessP :: Monad m => Parser m ((Expression SourcePos) -> (Expression SourcePos))
arrayAccessP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
arrayAccessP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourceName
-> SourceName
-> Parser m (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m a
bracedP SourceName
"[" SourceName
"]" (SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
inner SourcePos
pos)
where
inner :: SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
inner SourcePos
pos = ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
sliceInner SourcePos
pos) ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall (m :: * -> *).
Monad m =>
SourcePos
-> Parser m (Expression SourcePos -> Expression SourcePos)
indexInner SourcePos
pos
sliceInner :: SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
sliceInner SourcePos
pos = do
Expression SourcePos
offset <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Expression SourcePos
forall a. a -> Expression a
NullLiteralE (SourcePos -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
Expression SourcePos
length <- ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> (SourcePos -> Expression SourcePos
forall a. a -> Expression a
NullLiteralE (SourcePos -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition)
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos))
-> (Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ \Expression SourcePos
e ->
SourcePos
-> Expression SourcePos
-> [(Maybe VarName, Expression SourcePos)]
-> Expression SourcePos
forall a.
a
-> Expression a -> [(Maybe VarName, Expression a)] -> Expression a
CallE
SourcePos
pos
(SourcePos -> VarName -> Expression SourcePos
forall a. a -> VarName -> Expression a
VarE SourcePos
pos VarName
"slice")
[ (Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
e)
, (Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
offset)
, (Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
length)
]
indexInner :: SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
indexInner SourcePos
pos = do
Expression SourcePos
i <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
(Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos))
-> (Expression SourcePos -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos -> Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ \Expression SourcePos
e -> SourcePos
-> Expression SourcePos
-> Expression SourcePos
-> Expression SourcePos
forall a. a -> Expression a -> Expression a -> Expression a
MemberLookupE SourcePos
pos Expression SourcePos
e Expression SourcePos
i
funcCallP :: Monad m => Parser m ((Expression SourcePos) -> (Expression SourcePos))
funcCallP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
funcCallP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
[(Maybe VarName, Expression SourcePos)]
args <- SourceName
-> SourceName
-> Parser m (Maybe VarName, Expression SourcePos)
-> Parser m [(Maybe VarName, Expression SourcePos)]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"(" SourceName
")" Parser m (Maybe VarName, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
funcArgP
(Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos))
-> (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ \Expression SourcePos
e -> SourcePos
-> Expression SourcePos
-> [(Maybe VarName, Expression SourcePos)]
-> Expression SourcePos
forall a.
a
-> Expression a -> [(Maybe VarName, Expression a)] -> Expression a
CallE SourcePos
pos Expression SourcePos
e [(Maybe VarName, Expression SourcePos)]
args
funcArgP :: Monad m => Parser m (Maybe Text, (Expression SourcePos))
funcArgP :: forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
funcArgP = Parser m (Maybe VarName, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
namedFuncArgP Parser m (Maybe VarName, Expression SourcePos)
-> Parser m (Maybe VarName, Expression SourcePos)
-> Parser m (Maybe VarName, Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Maybe VarName, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
positionalFuncArgP
namedFuncArgP :: Monad m => Parser m (Maybe Text, (Expression SourcePos))
namedFuncArgP :: forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
namedFuncArgP = do
VarName
name <- ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall a b. (a -> b) -> a -> b
$ ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
`before` ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
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 ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment (SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
"=")
Expression SourcePos
expr <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
(Maybe VarName, Expression SourcePos)
-> Parser m (Maybe VarName, Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (VarName -> Maybe VarName
forall a. a -> Maybe a
Just VarName
name, Expression SourcePos
expr)
positionalFuncArgP :: Monad m => Parser m (Maybe Text, (Expression SourcePos))
positionalFuncArgP :: forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
positionalFuncArgP = ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos)
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ (Maybe VarName
forall a. Maybe a
Nothing,) (Expression SourcePos -> (Maybe VarName, Expression SourcePos))
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Maybe VarName, Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
filterP :: Monad m => Parser m ((Expression SourcePos) -> (Expression SourcePos))
filterP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
filterP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'|'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
func <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
atomicExprP
[(Maybe VarName, Expression SourcePos)]
args <- [(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall a b. (a -> b) -> a -> b
$ SourceName
-> SourceName
-> Parser m (Maybe VarName, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"(" SourceName
")" Parser m (Maybe VarName, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
funcArgP
(Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos))
-> (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ \Expression SourcePos
e -> SourcePos
-> Expression SourcePos
-> [(Maybe VarName, Expression SourcePos)]
-> Expression SourcePos
forall a.
a
-> Expression a -> [(Maybe VarName, Expression a)] -> Expression a
CallE SourcePos
pos Expression SourcePos
func ((Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
e)(Maybe VarName, Expression SourcePos)
-> [(Maybe VarName, Expression SourcePos)]
-> [(Maybe VarName, Expression SourcePos)]
forall a. a -> [a] -> [a]
:[(Maybe VarName, Expression SourcePos)]
args)
testExprP :: Monad m => Parser m ((Expression SourcePos) -> (Expression SourcePos))
testExprP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos -> Expression SourcePos)
testExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourceName -> Parser m SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"is"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
funcName <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
atomicExprP
[(Maybe VarName, Expression SourcePos)]
args <- [ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall s (m :: * -> *) t u a.
Stream s m t =>
[ParsecT s u m a] -> ParsecT s u m a
choice [SourceName
-> SourceName
-> Parser m (Maybe VarName, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"(" SourceName
")" Parser m (Maybe VarName, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
funcArgP
, [(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option [] (ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall a b. (a -> b) -> a -> b
$ Parser m (Maybe VarName, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Maybe VarName, Expression SourcePos)
funcArgP Parser m (Maybe VarName, Expression SourcePos)
-> ((Maybe VarName, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)])
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> (a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (\(Maybe VarName, Expression SourcePos)
a -> [(Maybe VarName, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Maybe VarName, Expression SourcePos)]
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return [(Maybe VarName, Expression SourcePos)
a])]
(Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return ((Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos))
-> (Expression SourcePos -> Expression SourcePos)
-> Parser m (Expression SourcePos -> Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ \Expression SourcePos
e -> SourcePos
-> Expression SourcePos
-> [(Maybe VarName, Expression SourcePos)]
-> Expression SourcePos
forall a.
a
-> Expression a -> [(Maybe VarName, Expression a)] -> Expression a
CallE SourcePos
pos (Expression SourcePos -> Expression SourcePos
forall a. Expression a -> Expression a
addIsPrefix Expression SourcePos
funcName) ((Maybe VarName
forall a. Maybe a
Nothing, Expression SourcePos
e)(Maybe VarName, Expression SourcePos)
-> [(Maybe VarName, Expression SourcePos)]
-> [(Maybe VarName, Expression SourcePos)]
forall a. a -> [a] -> [a]
:[(Maybe VarName, Expression SourcePos)]
args)
where
addIsPrefix :: Expression a -> Expression a
addIsPrefix :: forall a. Expression a -> Expression a
addIsPrefix Expression a
expr = case Expression a
expr of
(VarE a
a VarName
text) -> a -> VarName -> Expression a
forall a. a -> VarName -> Expression a
VarE a
a (VarName -> Expression a) -> VarName -> Expression a
forall a b. (a -> b) -> a -> b
$ VarName -> VarName -> VarName
Text.append (SourceName -> VarName
Text.pack SourceName
"is_") VarName
text
Expression a
_ -> Expression a
expr
atomicExprP :: Monad m => Parser m (Expression SourcePos)
atomicExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
atomicExprP = Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
doExprP
Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
parenthesizedExprP
Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
objectExprP
Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
listExprP
Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
stringLiteralExprP
Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
numberLiteralExprP
Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
-> Parser m (Expression SourcePos)
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
varExprP
parenthesizedExprP :: Monad m => Parser m (Expression SourcePos)
parenthesizedExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
parenthesizedExprP =
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression 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
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'(' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
')' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
doExprP :: Monad m => Parser m (Expression SourcePos)
doExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
doExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
"do"
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Statement SourcePos
stmt <- Parser m (Statement SourcePos)
forall (m :: * -> *). Monad m => Parser m (Statement SourcePos)
scriptStatementP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourcePos -> Statement SourcePos -> Expression SourcePos
forall a. a -> Statement a -> Expression a
DoE SourcePos
pos Statement SourcePos
stmt
listExprP :: Monad m => Parser m (Expression SourcePos)
listExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
listExprP =
SourcePos -> [Expression SourcePos] -> Expression SourcePos
forall a. a -> [Expression a] -> Expression a
ListE
(SourcePos -> [Expression SourcePos] -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([Expression SourcePos] -> Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([Expression SourcePos] -> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SourceName
-> SourceName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[Expression SourcePos]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"[" SourceName
"]" ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
objectExprP :: Monad m => Parser m (Expression SourcePos)
objectExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
objectExprP = SourcePos
-> [(Expression SourcePos, Expression SourcePos)]
-> Expression SourcePos
forall a. a -> [(Expression a, Expression a)] -> Expression a
ObjectE
(SourcePos
-> [(Expression SourcePos, Expression SourcePos)]
-> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([(Expression SourcePos, Expression SourcePos)]
-> Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
([(Expression SourcePos, Expression SourcePos)]
-> Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Expression SourcePos, Expression SourcePos)]
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> SourceName
-> SourceName
-> Parser m (Expression SourcePos, Expression SourcePos)
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
[(Expression SourcePos, Expression SourcePos)]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
"{" SourceName
"}" Parser m (Expression SourcePos, Expression SourcePos)
forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, Expression SourcePos)
expressionPairP
expressionPairP :: Monad m => Parser m ((Expression SourcePos), (Expression SourcePos))
expressionPairP :: forall (m :: * -> *).
Monad m =>
Parser m (Expression SourcePos, Expression SourcePos)
expressionPairP = do
Expression SourcePos
a <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
':'
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos
b <- Parser m (Expression SourcePos)
forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
expressionP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
(Expression SourcePos, Expression SourcePos)
-> Parser m (Expression SourcePos, Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos
a, Expression SourcePos
b)
groupP :: Monad m => String -> String -> Parser m a -> Parser m [a]
groupP :: forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m [a]
groupP SourceName
obr SourceName
cbr Parser m a
inner =
SourceName -> SourceName -> Parser m [a] -> Parser m [a]
forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m a
bracedP SourceName
obr SourceName
cbr
(Parser m a
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> Parser m [a]
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
sepBy (Parser m a
inner Parser m a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> Parser m a
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
`before` ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment) (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
"," ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
`before` ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment))
bracedP :: Monad m => String -> String -> Parser m a -> Parser m a
bracedP :: forall (m :: * -> *) a.
Monad m =>
SourceName -> SourceName -> Parser m a -> Parser m a
bracedP SourceName
obr SourceName
cbr =
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
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
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m a
try (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
obr ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
(ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *) a. Monad m => m a -> m ()
ignore (ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ())
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b. (a -> b) -> a -> b
$ SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
cbr ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall a b.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment)
varExprP :: Monad m => Parser m (Expression SourcePos)
varExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
varExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
VarName
litName <- Parser m VarName
forall (m :: * -> *). Monad m => Parser m VarName
identifierP
Parser m ()
forall (m :: * -> *). Monad m => Parser m ()
spacesOrComment
Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> Expression SourcePos -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ case VarName
litName of
VarName
"True" -> SourcePos -> Bool -> Expression SourcePos
forall a. a -> Bool -> Expression a
BoolLiteralE SourcePos
pos Bool
True
VarName
"true" -> SourcePos -> Bool -> Expression SourcePos
forall a. a -> Bool -> Expression a
BoolLiteralE SourcePos
pos Bool
True
VarName
"False" -> SourcePos -> Bool -> Expression SourcePos
forall a. a -> Bool -> Expression a
BoolLiteralE SourcePos
pos Bool
False
VarName
"false" -> SourcePos -> Bool -> Expression SourcePos
forall a. a -> Bool -> Expression a
BoolLiteralE SourcePos
pos Bool
False
VarName
"null" -> SourcePos -> Expression SourcePos
forall a. a -> Expression a
NullLiteralE SourcePos
pos
VarName
_ -> SourcePos -> VarName -> Expression SourcePos
forall a. a -> VarName -> Expression a
VarE SourcePos
pos VarName
litName
identifierP :: Monad m => Parser m Text
identifierP :: forall (m :: * -> *). Monad m => Parser m VarName
identifierP =
SourceName -> VarName
Text.pack (SourceName -> VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (
(:)
(Char -> ShowS)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ShowS
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf ([Char
'a'..Char
'z'] SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
'_'])
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ShowS
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
identCharP)
identCharP :: Monad m => Parser m Char
identCharP :: forall (m :: * -> *). Monad m => Parser m Char
identCharP = SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf ([Char
'a'..Char
'z'] SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
'A'..Char
'Z'] SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
'_'] SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
'0'..Char
'9'])
stringLiteralExprP :: Monad m => Parser m (Expression SourcePos)
stringLiteralExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
stringLiteralExprP =
SourcePos -> VarName -> Expression SourcePos
forall a. a -> VarName -> Expression a
StringLiteralE
(SourcePos -> VarName -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName -> Expression SourcePos)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(VarName -> Expression SourcePos)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
-> ParsecT
SourceName
ParseState
(ReaderT (ParserOptions m) m)
(Expression SourcePos)
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (SourceName -> VarName
Text.pack (SourceName -> VarName)
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) VarName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
stringLiteralP)
stringLiteralP :: Monad m => Parser m String
stringLiteralP :: forall (m :: * -> *). Monad m => Parser m SourceName
stringLiteralP = do
Char
d <- SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf [ Char
'\'', Char
'\"' ]
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall s (m :: * -> *) t u a end.
Stream s m t =>
ParsecT s u m a -> ParsecT s u m end -> ParsecT s u m [a]
manyTill ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
stringCharP (Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
d)
stringCharP :: Monad m => Parser m Char
stringCharP :: forall (m :: * -> *). Monad m => Parser m Char
stringCharP = do
Char
c1 <- Parser m Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar
case Char
c1 of
Char
'\\' -> do
Char
c2 <- Parser m Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
anyChar
case Char
c2 of
Char
'n' -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\n'
Char
'r' -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\r'
Char
'b' -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\b'
Char
'v' -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\v'
Char
'0' -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\0'
Char
't' -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
'\t'
Char
_ -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
c2
Char
_ -> Char -> Parser m Char
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return Char
c1
numberLiteralExprP :: Monad m => Parser m (Expression SourcePos)
numberLiteralExprP :: forall (m :: * -> *). Monad m => Parser m (Expression SourcePos)
numberLiteralExprP = do
SourcePos
pos <- ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) SourcePos
forall (m :: * -> *) s u. Monad m => ParsecT s u m SourcePos
getPosition
SourceName
str <- Parser m SourceName
forall (m :: * -> *). Monad m => Parser m SourceName
numberLiteralP
let nMay :: Maybe Scientific
nMay :: Maybe Scientific
nMay = SourceName -> Maybe Scientific
forall a. Read a => SourceName -> Maybe a
readMay SourceName
str
case Maybe Scientific
nMay of
Just Scientific
n -> Expression SourcePos -> Parser m (Expression SourcePos)
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (Expression SourcePos -> Parser m (Expression SourcePos))
-> (Scientific -> Expression SourcePos)
-> Scientific
-> Parser m (Expression SourcePos)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SourcePos -> Scientific -> Expression SourcePos
forall a. a -> Scientific -> Expression a
NumberLiteralE SourcePos
pos (Scientific -> Parser m (Expression SourcePos))
-> Scientific -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ Scientific
n
Maybe Scientific
Nothing -> SourceName -> Parser m (Expression SourcePos)
forall a.
SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. MonadFail m => SourceName -> m a
fail (SourceName -> Parser m (Expression SourcePos))
-> SourceName -> Parser m (Expression SourcePos)
forall a b. (a -> b) -> a -> b
$ SourceName
"Failed to parse " SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
str SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
" as a number"
numberLiteralP :: Monad m => Parser m String
numberLiteralP :: forall (m :: * -> *). Monad m => Parser m SourceName
numberLiteralP = do
SourceName
sign <- SourceName -> Parser m SourceName -> Parser m SourceName
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option SourceName
"" (Parser m SourceName -> Parser m SourceName)
-> Parser m SourceName -> Parser m SourceName
forall a b. (a -> b) -> a -> b
$ SourceName -> Parser m SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
"-"
SourceName
integral <- SourceName -> Parser m SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
"0" Parser m SourceName -> Parser m SourceName -> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> ((:) (Char -> ShowS)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ShowS
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> SourceName
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m Char
oneOf [Char
'1'..Char
'9'] ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ShowS
-> Parser m SourceName -> Parser m SourceName
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit)
SourceName
fractional <- SourceName -> Parser m SourceName -> Parser m SourceName
forall s (m :: * -> *) t a u.
Stream s m t =>
a -> ParsecT s u m a -> ParsecT s u m a
option SourceName
"" (Parser m SourceName -> Parser m SourceName)
-> Parser m SourceName -> Parser m SourceName
forall a b. (a -> b) -> a -> b
$ (:) (Char -> ShowS)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) ShowS
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u.
Stream s m Char =>
Char -> ParsecT s u m Char
char Char
'.' ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ShowS
-> Parser m SourceName -> Parser m SourceName
forall a b.
ParsecT
SourceName ParseState (ReaderT (ParserOptions m) m) (a -> b)
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> Parser m SourceName
forall a.
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
many ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
digit
SourceName -> Parser m SourceName
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return (SourceName -> Parser m SourceName)
-> SourceName -> Parser m SourceName
forall a b. (a -> b) -> a -> b
$ SourceName
sign SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
integral SourceName -> ShowS
forall a. [a] -> [a] -> [a]
++ SourceName
fractional
followedBy :: Monad m => m b -> m a -> m a
followedBy :: forall (m :: * -> *) b a. Monad m => m b -> m a -> m a
followedBy m b
b m a
a = m a
a m a -> (a -> m a) -> m a
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \a
x -> m b
b m b -> m a -> m a
forall a b. m a -> m b -> m b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>> a -> m a
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
x
before :: Monad m => m a -> m b -> m a
before :: forall (m :: * -> *) a b. Monad m => m a -> m b -> m a
before = (m b -> m a -> m a) -> m a -> m b -> m a
forall a b c. (a -> b -> c) -> b -> a -> c
flip m b -> m a -> m a
forall (m :: * -> *) b a. Monad m => m b -> m a -> m a
followedBy
keyword :: Monad m => String -> Parser m String
keyword :: forall (m :: * -> *). Monad m => SourceName -> Parser m SourceName
keyword SourceName
kw = do
SourceName -> Parser m SourceName
forall s (m :: * -> *) u.
Stream s m Char =>
SourceName -> ParsecT s u m SourceName
string SourceName
kw
ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
-> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) ()
forall s (m :: * -> *) t a u.
(Stream s m t, Show a) =>
ParsecT s u m a -> ParsecT s u m ()
notFollowedBy ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) Char
forall (m :: * -> *). Monad m => Parser m Char
identCharP
SourceName -> Parser m SourceName
forall a.
a -> ParsecT SourceName ParseState (ReaderT (ParserOptions m) m) a
forall (m :: * -> *) a. Monad m => a -> m a
return SourceName
kw