summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GFC.hs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/GFC.hs b/src/GFC.hs
index 17c95eb30..4e06641f9 100644
--- a/src/GFC.hs
+++ b/src/GFC.hs
@@ -18,6 +18,15 @@ import System.FilePath
mainGFC :: Options -> [FilePath] -> IOE ()
mainGFC opts fs =
+ case () of
+ _ | null fs -> fail $ "No input files."
+ _ | all (extensionIs ".gf") fs -> compileSourceFiles opts fs
+ _ | all (extensionIs ".pgf") fs -> unionPGFFiles opts fs
+ _ -> fail $ "Don't know what to do with these input files: " ++ show fs
+ where extensionIs ext = (== ext) . takeExtension
+
+compileSourceFiles :: Options -> [FilePath] -> IOE ()
+compileSourceFiles opts fs =
do gr <- batchCompile opts fs
let cnc = justModuleName (last fs)
if flag optStopAfterPhase opts == Compile
@@ -25,6 +34,12 @@ mainGFC opts fs =
else do pgf <- link opts cnc gr
writeOutputs opts pgf
+unionPGFFiles :: Options -> [FilePath] -> IOE ()
+unionPGFFiles opts fs =
+ do pgfs <- ioeIO $ mapM readPGF fs
+ let pgf = foldl1 unionPGF pgfs
+ writeOutputs opts pgf
+
writeOutputs :: Options -> PGF -> IOE ()
writeOutputs opts pgf =
sequence_ [writeOutput opts name str