blob: df6f09e124c22348864945fc077442c4fc429323 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{-# LANGUAGE GADTs, DataKinds, OverloadedStrings #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE FlexibleInstances, TypeFamilies #-}
module Events.Spec.Parse.Token
( SpecToken(..)
, pToken, pTokens
) where
import Events.Spec.Types
import Text.Megaparsec hiding (parse)
import Text.Megaparsec.Pos
import qualified Text.Megaparsec.Lexer as L
import Data.Typeable (Typeable)
import Data.Text (Text)
import qualified Data.Text as Text
import Data.Text.Lazy as Lazy (Text)
import qualified Data.Text.Lazy as Lazy.Text
data SpecToken = Token
deriving (Typeable, Show, Eq, Ord)
instance Stream [SpecToken] where
type Token [SpecToken] = SpecToken
uncons [] = Nothing
uncons (s:ss) = Just (s, ss)
updatePos = undefined
tSpace :: ParsecT Dec Lazy.Text m ()
tSpace = L.space (() <$ spaceChar) (L.skipLineComment "--") (L.skipBlockComment "{-" "-}")
pToken :: ParsecT Dec Lazy.Text m SpecToken
pToken = mzero {- TODO -}
pTokens :: ParsecT Dec Lazy.Text m [SpecToken]
pTokens = manyTill (tSpace *> pToken <* tSpace) eof
|