Added a CHP backend option to Tock

This commit is contained in:
Neil Brown 2008-11-26 12:24:21 +00:00
parent aa10b0113d
commit 78716a2727
4 changed files with 36 additions and 3 deletions

View File

@ -42,6 +42,7 @@ import CompState
import Errors
import FlowGraph
import GenerateC
import GenerateCHP
import GenerateCPPCSP
import LexOccam
import Metadata
@ -114,6 +115,7 @@ optBackend :: String -> OptFunc
optBackend s ps
= do backend <- case s of
"c" -> return BackendC
"chp" -> return BackendCHP
"cppcsp" -> return BackendCPPCSP
"dumpast" -> return BackendDumpAST
"src" -> return BackendSource
@ -481,8 +483,8 @@ compile mode fn (outHandles@(outHandle, _), headerName)
let generator :: A.AST -> PassM ()
generator
= case csBackend optsPS of
BackendC -> generateC outHandles headerName
BackendCPPCSP -> generateCPPCSP outHandles headerName
BackendC -> generateC outHandle
BackendCPPCSP -> generateCPPCSP outHandle
BackendDumpAST -> liftIO . hPutStr outHandle . pshow
BackendSource -> (liftIO . hPutStr outHandle) <.< showCode
generator ast2

View File

@ -143,6 +143,7 @@ tock_SOURCES_hs += backends/AnalyseAsm.hs
tock_SOURCES_hs += backends/BackendPasses.hs
tock_SOURCES_hs += backends/GenerateC.hs
tock_SOURCES_hs += backends/GenerateCBased.hs
tock_SOURCES_hs += backends/GenerateCHP.hs
tock_SOURCES_hs += backends/GenerateCPPCSP.hs
tock_SOURCES_hs += backends/TLP.hs
tock_SOURCES_hs += checks/ArrayUsageCheck.hs

30
backends/GenerateCHP.hs Normal file
View File

@ -0,0 +1,30 @@
{-
Tock: a compiler for parallel languages
Copyright (C) 2008 University of Kent
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 2 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
-}
-- | Generate CHP code from the AST
module GenerateCHP where
import System.IO
import qualified AST as A
import Pass
generateCHP :: Handle -> A.AST -> PassM ()
generateCHP h tr = genAST tr
genAST _ = return ()

View File

@ -45,7 +45,7 @@ data CompMode = ModeFlowGraph | ModeLex | ModeHTML | ModeParse | ModeCompile | M
deriving (Show, Data, Typeable, Eq)
-- | Backends that Tock can use.
data CompBackend = BackendC | BackendCPPCSP | BackendDumpAST | BackendSource
data CompBackend = BackendC | BackendCPPCSP | BackendCHP | BackendDumpAST | BackendSource
deriving (Show, Data, Typeable, Eq)
-- | Frontends that Tock can use.