diff options
Diffstat (limited to 'events/src/Events/Spec/Parse')
-rw-r--r-- | events/src/Events/Spec/Parse/AST.hs | 19 | ||||
-rw-r--r-- | events/src/Events/Spec/Parse/Token.hs | 43 |
2 files changed, 62 insertions, 0 deletions
diff --git a/events/src/Events/Spec/Parse/AST.hs b/events/src/Events/Spec/Parse/AST.hs new file mode 100644 index 0000000..38c2c84 --- /dev/null +++ b/events/src/Events/Spec/Parse/AST.hs | |||
@@ -0,0 +1,19 @@ | |||
1 | {-# LANGUAGE GADTs, DataKinds, OverloadedStrings #-} | ||
2 | |||
3 | module Events.Spec.Parse.AST | ||
4 | ( AST(..) | ||
5 | , pAST | ||
6 | ) where | ||
7 | |||
8 | import Events.Spec.Types | ||
9 | import Events.Spec.Parse.Token | ||
10 | |||
11 | import Text.Megaparsec hiding (parse) | ||
12 | |||
13 | import Data.Typeable (Typeable) | ||
14 | |||
15 | data AST = AST | ||
16 | deriving (Typeable) | ||
17 | |||
18 | pAST :: ParsecT Dec [SpecToken] m AST | ||
19 | pAST = mzero {- TODO -} | ||
diff --git a/events/src/Events/Spec/Parse/Token.hs b/events/src/Events/Spec/Parse/Token.hs new file mode 100644 index 0000000..df6f09e --- /dev/null +++ b/events/src/Events/Spec/Parse/Token.hs | |||
@@ -0,0 +1,43 @@ | |||
1 | {-# LANGUAGE GADTs, DataKinds, OverloadedStrings #-} | ||
2 | {-# LANGUAGE StandaloneDeriving #-} | ||
3 | {-# LANGUAGE FlexibleInstances, TypeFamilies #-} | ||
4 | |||
5 | module Events.Spec.Parse.Token | ||
6 | ( SpecToken(..) | ||
7 | , pToken, pTokens | ||
8 | ) where | ||
9 | |||
10 | import Events.Spec.Types | ||
11 | |||
12 | import Text.Megaparsec hiding (parse) | ||
13 | import Text.Megaparsec.Pos | ||
14 | import qualified Text.Megaparsec.Lexer as L | ||
15 | |||
16 | import Data.Typeable (Typeable) | ||
17 | |||
18 | import Data.Text (Text) | ||
19 | import qualified Data.Text as Text | ||
20 | |||
21 | import Data.Text.Lazy as Lazy (Text) | ||
22 | import qualified Data.Text.Lazy as Lazy.Text | ||
23 | |||
24 | data SpecToken = Token | ||
25 | deriving (Typeable, Show, Eq, Ord) | ||
26 | |||
27 | instance Stream [SpecToken] where | ||
28 | type Token [SpecToken] = SpecToken | ||
29 | |||
30 | uncons [] = Nothing | ||
31 | uncons (s:ss) = Just (s, ss) | ||
32 | |||
33 | updatePos = undefined | ||
34 | |||
35 | |||
36 | tSpace :: ParsecT Dec Lazy.Text m () | ||
37 | tSpace = L.space (() <$ spaceChar) (L.skipLineComment "--") (L.skipBlockComment "{-" "-}") | ||
38 | |||
39 | pToken :: ParsecT Dec Lazy.Text m SpecToken | ||
40 | pToken = mzero {- TODO -} | ||
41 | |||
42 | pTokens :: ParsecT Dec Lazy.Text m [SpecToken] | ||
43 | pTokens = manyTill (tSpace *> pToken <* tSpace) eof | ||