summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-08-15 21:10:54 +0000
committerbjorn <bjorn@bringert.net>2008-08-15 21:10:54 +0000
commitf28dc5ac16b1123def254f55bbed36f0d3fdbc6e (patch)
tree6bb73a39f5c047173e57ae24f548f454e5dfdbac /src
parent137133b742f38c76d2354047ecc9d4af88826d42 (diff)
gfc can now combine PGF files.
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