diff options
Diffstat (limited to 'events/src/Events/Spec/Parse.hs')
-rw-r--r-- | events/src/Events/Spec/Parse.hs | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/events/src/Events/Spec/Parse.hs b/events/src/Events/Spec/Parse.hs index 44aabd0..2847372 100644 --- a/events/src/Events/Spec/Parse.hs +++ b/events/src/Events/Spec/Parse.hs | |||
@@ -1,15 +1,18 @@ | |||
1 | {-# LANGUAGE GADTs, DataKinds, OverloadedStrings #-} | 1 | {-# LANGUAGE GADTs, DataKinds, OverloadedStrings #-} |
2 | {-# LANGUAGE StandaloneDeriving #-} | 2 | {-# LANGUAGE StandaloneDeriving, FlexibleContexts #-} |
3 | 3 | ||
4 | module Events.Spec.Parse | 4 | module Events.Spec.Parse |
5 | ( parse | 5 | ( parse |
6 | , ParseError(..) | 6 | , ParseError(..) |
7 | , TypeError(..) | ||
7 | ) where | 8 | ) where |
8 | 9 | ||
9 | import Events.Spec.Types | 10 | import Events.Spec.Types |
11 | import Events.Spec.Parse.Token | ||
12 | import Events.Spec.Parse.AST | ||
10 | 13 | ||
11 | import Text.Parsec hiding (parse, ParseError) | 14 | import Text.Megaparsec hiding (parse) |
12 | import qualified Text.Parsec as Parsec (parse, ParseError) | 15 | import qualified Text.Megaparsec.Lexer as L |
13 | 16 | ||
14 | import Data.Text (Text) | 17 | import Data.Text (Text) |
15 | import qualified Data.Text as Text | 18 | import qualified Data.Text as Text |
@@ -23,13 +26,16 @@ import Data.Typeable (Typeable) | |||
23 | import Control.Monad.Catch (Exception(..), MonadThrow(..)) | 26 | import Control.Monad.Catch (Exception(..), MonadThrow(..)) |
24 | 27 | ||
25 | 28 | ||
26 | newtype ParseError = ParseError Parsec.ParseError | 29 | data TypeError = TypeError |
27 | deriving (Typeable, Show, Eq) | 30 | deriving (Typeable, Show) |
28 | instance Exception ParseError | ||
29 | 31 | ||
32 | instance Exception TypeError | ||
30 | 33 | ||
31 | parse :: MonadThrow m => SourceName -> Lazy.Text -> Eval m (Spec m) | ||
32 | parse name = either (throwM . ParseError) return <=< runParserT pSpec () name | ||
33 | 34 | ||
34 | pSpec :: ParsecT Lazy.Text () (Eval m) (Spec m) | 35 | parse :: (MonadIO m, MonadThrow m) => String -> Lazy.Text -> m (Spec m) |
35 | pSpec = mzero | 36 | parse name = typecheck <=< runParserT' pAST name <=< runParserT' pTokens name |
37 | where | ||
38 | runParserT' parser name = either throwM return <=< runParserT parser name | ||
39 | |||
40 | typecheck :: MonadThrow m => AST -> m (Spec m) | ||
41 | typecheck = undefined | ||