Fixed some indentation issues and added markers for things that are missing
This commit is contained in:
parent
5d0391c98d
commit
d7c61a70c0
|
@ -57,10 +57,11 @@ pushIndent :: CGen ()
|
||||||
pushIndent = modify $ \(hb, cur, indents) -> (hb, cur, length cur : indents)
|
pushIndent = modify $ \(hb, cur, indents) -> (hb, cur, length cur : indents)
|
||||||
|
|
||||||
popIndent :: CGen ()
|
popIndent :: CGen ()
|
||||||
popIndent = modify $ \(hb, cur, _:indents) ->
|
popIndent = do
|
||||||
|
(hb, cur, _:indents) <- get
|
||||||
if all (== ' ') cur
|
if all (== ' ') cur
|
||||||
then (hb, replicate (head indents) ' ', indents)
|
then put (hb, replicate (head indents) ' ', indents)
|
||||||
else (hb, cur, indents)
|
else tell ["\n"] >> popIndent
|
||||||
|
|
||||||
withIndent :: CGen () -> CGen ()
|
withIndent :: CGen () -> CGen ()
|
||||||
withIndent f = pushIndent >> f >> popIndent
|
withIndent f = pushIndent >> f >> popIndent
|
||||||
|
@ -91,8 +92,8 @@ genStructured True (A.Spec m spec scope)
|
||||||
genSpec spec
|
genSpec spec
|
||||||
tell ["in "]
|
tell ["in "]
|
||||||
withIndent $ genStructured True scope
|
withIndent $ genStructured True scope
|
||||||
genStructured addLet (A.ProcThen m proc scope) = genStructured addLet scope
|
genStructured addLet (A.ProcThen m proc scope) = tell ["{-genStructured-}\n"] >> genStructured addLet scope
|
||||||
genStructured _ (A.Only m item) = tell ["{-ONLY-}"]
|
genStructured _ (A.Only m item) = tell ["{-genStructured-}\n"]
|
||||||
genStructured addLet (A.Several m strs) = mapM_ (genStructured addLet) strs
|
genStructured addLet (A.Several m strs) = mapM_ (genStructured addLet) strs
|
||||||
|
|
||||||
-- | Should output a spec, or nothing
|
-- | Should output a spec, or nothing
|
||||||
|
@ -105,15 +106,17 @@ genSpec (A.Specification _ n (A.Proc _ _ params body))
|
||||||
tell [" CHP ()\n"]
|
tell [" CHP ()\n"]
|
||||||
genName n
|
genName n
|
||||||
sequence [genName pn >> tell [" "] | A.Formal _ _ pn <- params]
|
sequence [genName pn >> tell [" "] | A.Formal _ _ pn <- params]
|
||||||
tell ["= do\n "]
|
tell ["= "]
|
||||||
pushIndent
|
withIndent $ genProcess body
|
||||||
tell ["return ()\n"] -- TODO
|
|
||||||
popIndent
|
|
||||||
where
|
where
|
||||||
doFormalAndArrow :: A.Formal -> CGen ()
|
doFormalAndArrow :: A.Formal -> CGen ()
|
||||||
doFormalAndArrow (A.Formal _ t _)
|
doFormalAndArrow (A.Formal _ t _)
|
||||||
= genType t >> tell [" -> "]
|
= genType t >> tell [" -> "]
|
||||||
genSpec _ = return ()
|
genSpec _ = tell ["{-genSpec-}\n"]
|
||||||
|
|
||||||
|
genProcess :: A.Process -> CGen ()
|
||||||
|
genProcess (A.Seq _ str) = tell ["do "] >> withIndent (genStructured True str)
|
||||||
|
genProcess _ = tell ["{-genProcess-}\n"]
|
||||||
|
|
||||||
genType :: A.Type -> CGen ()
|
genType :: A.Type -> CGen ()
|
||||||
genType A.Int = tell ["Int#"]
|
genType A.Int = tell ["Int#"]
|
||||||
|
@ -124,4 +127,4 @@ genType (A.Chan dir attr inner)
|
||||||
A.DirUnknown -> "One2OneChannel"]
|
A.DirUnknown -> "One2OneChannel"]
|
||||||
genType inner
|
genType inner
|
||||||
tell [")"]
|
tell [")"]
|
||||||
genType _ = tell ["({-TYPE-})"]
|
genType _ = tell ["({-genType-})"]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user