diff --git a/Main.hs b/Main.hs index 826752a..09cd788 100644 --- a/Main.hs +++ b/Main.hs @@ -56,7 +56,7 @@ type OptFunc = CompState -> IO CompState options :: [OptDescr OptFunc] options = [ Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, parse, compile, post-c, full)" - , Option [] ["backend"] (ReqArg optBackend "BACKEND") "code-generating backend (options: c, cppcsp)" + , Option [] ["backend"] (ReqArg optBackend "BACKEND") "code-generating backend (options: c, cppcsp, dumpast)" , Option [] ["frontend"] (ReqArg optFrontend "FRONTEND") "language frontend (options: occam, rain)" , Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)" , Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")" @@ -79,6 +79,7 @@ optBackend s ps = do backend <- case s of "c" -> return BackendC "cppcsp" -> return BackendCPPCSP + "dumpast" -> return BackendDumpAST _ -> dieIO (Nothing, "Unknown backend: " ++ s) return $ ps { csBackend = backend } @@ -195,6 +196,7 @@ compileFull fn = do optsPS <- lift get -- For C++, just compile the source file directly into a binary: BackendCPPCSP -> exec $ cxxCommand tempCPath destBin + _ -> dieReport (Nothing, "Cannot use specified backend: " ++ show (csBackend optsPS) ++ " with full-compile mode") -- Finally, remove the temporary files: tempFiles <- get @@ -284,6 +286,7 @@ compile mode fn outHandle = case csBackend optsPS of BackendC -> generateC BackendCPPCSP -> generateCPPCSP + BackendDumpAST -> return . pshow code <- generator ast2 debug "}}}" diff --git a/common/CompState.hs b/common/CompState.hs index e2da104..c5506ce 100644 --- a/common/CompState.hs +++ b/common/CompState.hs @@ -39,7 +39,7 @@ data CompMode = ModeFlowGraph | ModeParse | ModeCompile | ModePostC | ModeFull deriving (Show, Data, Typeable, Eq) -- | Backends that Tock can use. -data CompBackend = BackendC | BackendCPPCSP +data CompBackend = BackendC | BackendCPPCSP | BackendDumpAST deriving (Show, Data, Typeable, Eq) -- | Frontends that Tock can use. diff --git a/common/PassList.hs b/common/PassList.hs index fb2c3a6..4268f77 100644 --- a/common/PassList.hs +++ b/common/PassList.hs @@ -50,4 +50,5 @@ getPassList optsPS = concat [ if csFrontend optsPS == FrontendRain , case csBackend optsPS of BackendC -> genCPasses BackendCPPCSP -> genCPPCSPPasses + _ -> [] ]