Commit 3b7c5fde authored by Marc Coiffier's avatar Marc Coiffier
Browse files

Correct the capricon library so that Haste can understand it

parent 6255b2d5
......@@ -33,7 +33,7 @@ instance StackSymbol JS.JSString where
'}' | JSS.length c==1 -> Close
'\'' -> Quoted (drop 1 c)
'"' -> Quoted (take (JSS.length c-2) (drop 1 c))
':' -> Comment (drop 1 c)
':' -> Comment (TextComment $ drop 1 c)
_ -> maybe (Other c) Number $ matches Just readable (toString c)
instance IsCapriconString JS.JSString where
toString = JSS.unpack
......@@ -147,7 +147,7 @@ runWordsState :: [String] -> WiQEEState -> FSIO (WiQEEState,String)
runWordsState ws st = ($st) $ from (stateT.concatT) $^ do
foldr (\w tl -> do
x <- runExtraState (getl endState)
unless x $ do execSymbol runCOCBuiltin runComment w; tl) unit ws
unless x $ do execSymbol runCOCBuiltin runComment (atomClass w); tl) unit ws
out <- runExtraState (outputText <~ \x -> (id,x))
return (out "")
......
......@@ -197,6 +197,13 @@ modifyCOCEnv (Just (modE,ctx)) = do
runExtraState (context =- ctx)
modifyAllExprs modE
execSymbolOrComment :: forall str io m.
(MonadSubIO io m,IsCapriconString str,
MonadStack (COCState str) str (COCBuiltin io str) (COCValue io str) m,
IOListFormat io str,ListFormat str) =>
StackComment str :+: str -> m ()
execSymbolOrComment x = execSymbol (\b -> runCOCBuiltin b) outputComment $ (Comment <|> atomClass) x
runCOCBuiltin :: forall str io m.
(MonadSubIO io m,IsCapriconString str,
MonadStack (COCState str) str (COCBuiltin io str) (COCValue io str) m,
......@@ -233,8 +240,7 @@ runCOCBuiltin (COCB_Open (ReadImpl getResource)) = do
StackSymbol f:t -> do
runStackState $ put t
xs <- liftSubIO (getResource (f+".md")) >>= maybe undefined return . matches Just literate . (const "" <|> toString)
let ex = execSymbol runCOCBuiltin outputComment . (Comment <|> atomClass)
ex (Right "{") >> traverse_ ex xs >> ex (Right "}")
execSymbolOrComment (Right "{") >> traverse_ execSymbolOrComment xs >> execSymbolOrComment (Right "}")
_ -> return ()
runCOCBuiltin COCB_ToInt = runStackState $ modify $ \case
......@@ -528,6 +534,11 @@ cocDict version getResource getBResource writeResource writeBResource =
atP (h,[]) = at h
atP (h,x:t) = at h.l'Just (StackDict zero).t'StackDict.atP (x,t)
outputComment :: forall str io m.
(MonadSubIO io m,IsCapriconString str,
MonadStack (COCState str) str (COCBuiltin io str) (COCValue io str) m,
IOListFormat io str,ListFormat str) =>
StackComment str -> m ()
outputComment c = execProgram runCOCBuiltin (\_ -> unit) (renderComment c)
markSyntax str = fold [if isWord then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment