]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Wiki/Interpreter.hs
ad951f80a668beabf59cfea1f8f2d9796a763407
[Rakka.git] / Rakka / Wiki / Interpreter.hs
1 module Rakka.Wiki.Interpreter
2     ( Interpreter(..)
3     , InterpreterContext(..)
4
5     , commandName -- private
6     , commandType -- private
7     )
8     where
9
10 import           Rakka.Page
11 import           Rakka.Storage
12 import           Rakka.SystemConfig
13 import           Rakka.Wiki
14
15
16 data Interpreter
17     = InlineCommandInterpreter {
18         iciName      :: !String
19       , iciInterpret :: !(InterpreterContext -> InlineCommand -> IO InlineElement)
20       }
21     | BlockCommandInterpreter {
22         bciName      :: !String
23       , bciInterpret :: !(InterpreterContext -> BlockCommand -> IO BlockElement)
24       }
25
26
27 data InterpreterContext
28     = InterpreterContext {
29         ctxPageName   :: !PageName
30       , ctxMainPage   :: !(Maybe Page)
31       , ctxMainTree   :: !(Maybe WikiPage)
32       , ctxTargetTree :: !WikiPage
33       , ctxStorage    :: !Storage
34       , ctxSysConf    :: !SystemConfig
35       }
36
37
38 commandName :: Interpreter -> String
39 commandName (InlineCommandInterpreter name _) = name
40 commandName (BlockCommandInterpreter  name _) = name
41
42
43 commandType :: Interpreter -> CommandType
44 commandType (InlineCommandInterpreter _ _) = InlineCommandType
45 commandType (BlockCommandInterpreter  _ _) = BlockCommandType