X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Rakka%2FWiki%2FInterpreter.hs;h=32e1a3aa0e1760516d67e533b2fdb59a1942df43;hb=ea5fe90601fc93c7518cc2bf200b09f7667d7b48;hp=2abfc45e2947bad4f44627401d288bdc5c1df884;hpb=2ad43b49ecc25bdf87dd19037fd63c12428992ae;p=Rakka.git diff --git a/Rakka/Wiki/Interpreter.hs b/Rakka/Wiki/Interpreter.hs index 2abfc45..32e1a3a 100644 --- a/Rakka/Wiki/Interpreter.hs +++ b/Rakka/Wiki/Interpreter.hs @@ -1,10 +1,9 @@ module Rakka.Wiki.Interpreter ( Interpreter(..) + , InterpreterContext(..) , commandName -- private , commandType -- private - - , pureInlineInterp ) where @@ -12,29 +11,36 @@ import Rakka.Page import Rakka.Storage import Rakka.SystemConfig import Rakka.Wiki +import Text.XML.HXT.DOM.TypeDefs data Interpreter = InlineCommandInterpreter { - iciName :: String - , iciInterpret :: InlineCommand - -> Maybe Page - -> Storage - -> SystemConfig - -> IO InlineElement + iciName :: !String + , iciInterpret :: !(InterpreterContext -> InlineCommand -> IO InlineElement) + } + | BlockCommandInterpreter { + bciName :: !String + , bciInterpret :: !(InterpreterContext -> BlockCommand -> IO BlockElement) + } + + +data InterpreterContext + = InterpreterContext { + ctxPageName :: !(Maybe PageName) + , ctxMainPage :: !(Maybe XmlTree) + , ctxMainWiki :: !(Maybe WikiPage) + , ctxTargetWiki :: !WikiPage + , ctxStorage :: !Storage + , ctxSysConf :: !SystemConfig } commandName :: Interpreter -> String commandName (InlineCommandInterpreter name _) = name +commandName (BlockCommandInterpreter name _) = name commandType :: Interpreter -> CommandType commandType (InlineCommandInterpreter _ _) = InlineCommandType - - -pureInlineInterp :: String - -> (InlineCommand -> Maybe Page -> InlineElement) - -> Interpreter -pureInlineInterp name f - = InlineCommandInterpreter name $ \ cmd page _ _ -> return $ f cmd page +commandType (BlockCommandInterpreter _ _) = BlockCommandType