forked from GitHub/gf-core
gfc can now combine PGF files.
This commit is contained in:
15
src/GFC.hs
15
src/GFC.hs
@@ -18,6 +18,15 @@ import System.FilePath
|
|||||||
|
|
||||||
mainGFC :: Options -> [FilePath] -> IOE ()
|
mainGFC :: Options -> [FilePath] -> IOE ()
|
||||||
mainGFC opts fs =
|
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
|
do gr <- batchCompile opts fs
|
||||||
let cnc = justModuleName (last fs)
|
let cnc = justModuleName (last fs)
|
||||||
if flag optStopAfterPhase opts == Compile
|
if flag optStopAfterPhase opts == Compile
|
||||||
@@ -25,6 +34,12 @@ mainGFC opts fs =
|
|||||||
else do pgf <- link opts cnc gr
|
else do pgf <- link opts cnc gr
|
||||||
writeOutputs opts pgf
|
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 :: Options -> PGF -> IOE ()
|
||||||
writeOutputs opts pgf =
|
writeOutputs opts pgf =
|
||||||
sequence_ [writeOutput opts name str
|
sequence_ [writeOutput opts name str
|
||||||
|
|||||||
Reference in New Issue
Block a user