Added a new "dump AST" pass
This commit is contained in:
parent
63af1381f2
commit
cd6e2175f2
5
Main.hs
5
Main.hs
|
@ -56,7 +56,7 @@ type OptFunc = CompState -> IO CompState
|
||||||
options :: [OptDescr OptFunc]
|
options :: [OptDescr OptFunc]
|
||||||
options =
|
options =
|
||||||
[ Option [] ["mode"] (ReqArg optMode "MODE") "select mode (options: flowgraph, parse, compile, post-c, full)"
|
[ 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 [] ["frontend"] (ReqArg optFrontend "FRONTEND") "language frontend (options: occam, rain)"
|
||||||
, Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)"
|
, Option ['v'] ["verbose"] (NoArg $ optVerbose) "be more verbose (use multiple times for more detail)"
|
||||||
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
, Option ['o'] ["output"] (ReqArg optOutput "FILE") "output file (default \"-\")"
|
||||||
|
@ -79,6 +79,7 @@ optBackend s ps
|
||||||
= do backend <- case s of
|
= do backend <- case s of
|
||||||
"c" -> return BackendC
|
"c" -> return BackendC
|
||||||
"cppcsp" -> return BackendCPPCSP
|
"cppcsp" -> return BackendCPPCSP
|
||||||
|
"dumpast" -> return BackendDumpAST
|
||||||
_ -> dieIO (Nothing, "Unknown backend: " ++ s)
|
_ -> dieIO (Nothing, "Unknown backend: " ++ s)
|
||||||
return $ ps { csBackend = backend }
|
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:
|
-- For C++, just compile the source file directly into a binary:
|
||||||
BackendCPPCSP -> exec $ cxxCommand tempCPath destBin
|
BackendCPPCSP -> exec $ cxxCommand tempCPath destBin
|
||||||
|
_ -> dieReport (Nothing, "Cannot use specified backend: " ++ show (csBackend optsPS) ++ " with full-compile mode")
|
||||||
|
|
||||||
-- Finally, remove the temporary files:
|
-- Finally, remove the temporary files:
|
||||||
tempFiles <- get
|
tempFiles <- get
|
||||||
|
@ -284,6 +286,7 @@ compile mode fn outHandle
|
||||||
= case csBackend optsPS of
|
= case csBackend optsPS of
|
||||||
BackendC -> generateC
|
BackendC -> generateC
|
||||||
BackendCPPCSP -> generateCPPCSP
|
BackendCPPCSP -> generateCPPCSP
|
||||||
|
BackendDumpAST -> return . pshow
|
||||||
code <- generator ast2
|
code <- generator ast2
|
||||||
debug "}}}"
|
debug "}}}"
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,7 @@ data CompMode = ModeFlowGraph | ModeParse | ModeCompile | ModePostC | ModeFull
|
||||||
deriving (Show, Data, Typeable, Eq)
|
deriving (Show, Data, Typeable, Eq)
|
||||||
|
|
||||||
-- | Backends that Tock can use.
|
-- | Backends that Tock can use.
|
||||||
data CompBackend = BackendC | BackendCPPCSP
|
data CompBackend = BackendC | BackendCPPCSP | BackendDumpAST
|
||||||
deriving (Show, Data, Typeable, Eq)
|
deriving (Show, Data, Typeable, Eq)
|
||||||
|
|
||||||
-- | Frontends that Tock can use.
|
-- | Frontends that Tock can use.
|
||||||
|
|
|
@ -50,4 +50,5 @@ getPassList optsPS = concat [ if csFrontend optsPS == FrontendRain
|
||||||
, case csBackend optsPS of
|
, case csBackend optsPS of
|
||||||
BackendC -> genCPasses
|
BackendC -> genCPasses
|
||||||
BackendCPPCSP -> genCPPCSPPasses
|
BackendCPPCSP -> genCPPCSPPasses
|
||||||
|
_ -> []
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user