1
1
mirror of https://github.com/github/semantic.git synced 2024-11-24 08:54:07 +03:00

Parse binding statements.

This commit is contained in:
Rob Rix 2019-07-22 15:04:46 -04:00
parent a39e7730ea
commit a77ecdbe78
No known key found for this signature in database
GPG Key ID: F188A01508EA1CF7

View File

@ -1,3 +1,4 @@
{-# LANGUAGE TypeOperators #-}
module Data.Core.Parser module Data.Core.Parser
( module Text.Trifecta ( module Text.Trifecta
, core , core
@ -67,7 +68,13 @@ atom = choice
] ]
comp :: (TokenParsing m, Monad m) => m (Term Core User) comp :: (TokenParsing m, Monad m) => m (Term Core User)
comp = braces (Core.block <$> sepEndByNonEmpty expr semi) <?> "compound statement" comp = braces (Core.do' <$> sepEndByNonEmpty statement semi) <?> "compound statement"
statement :: (TokenParsing m, Monad m) => m (Maybe (Named User) Core.:<- Term Core User)
statement
= try ((Core.:<-) . Just <$> name <* symbol "<-" <*> expr)
<|> (Nothing Core.:<-) <$> expr
<?> "statement"
ifthenelse :: (TokenParsing m, Monad m) => m (Term Core User) ifthenelse :: (TokenParsing m, Monad m) => m (Term Core User)
ifthenelse = Core.if' ifthenelse = Core.if'