From e4abff772556ebee68a7e3b2cbe4fd413a5e845e Mon Sep 17 00:00:00 2001 From: Thomas Hallgren Date: Tue, 22 Jan 2019 17:16:32 +0100 Subject: More work on the canonica_gf export + Abstract syntax now is converted directly from the Grammar and not via PGF, so you can use `gf -batch -no-pmcfg -f canonical_gf ...`, to export to canonical_gf while skipping PMCFG and PGF file generation completely. + Flags that are normally copied to PGF files are now included in the caninical_gf output as well (in particular the startcat flag). --- src/compiler/GF/Compiler.hs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/compiler/GF/Compiler.hs') diff --git a/src/compiler/GF/Compiler.hs b/src/compiler/GF/Compiler.hs index 334bbd592..2bd0fc0cb 100644 --- a/src/compiler/GF/Compiler.hs +++ b/src/compiler/GF/Compiler.hs @@ -7,7 +7,7 @@ import GF.Compile as S(batchCompile,link,srcAbsName) import GF.CompileInParallel as P(parallelBatchCompile) import GF.Compile.Export import GF.Compile.ConcreteToHaskell(concretes2haskell) -import GF.Compile.ConcreteToCanonical(concretes2canonical) +import GF.Compile.ConcreteToCanonical--(concretes2canonical) import GF.Compile.CFGtoPGF import GF.Compile.GetGrammar import GF.Grammar.BNFC @@ -60,17 +60,24 @@ compileSourceFiles opts fs = do when (FmtHaskell `elem` ofmts && haskellOption opts HaskellConcrete) $ mapM_ cnc2haskell (snd output) when (FmtCanonicalGF `elem` ofmts) $ - mapM_ cnc2canonical (snd output) + do createDirectoryIfMissing False "canonical" + mapM_ abs2canonical (snd output) + mapM_ cnc2canonical (snd output) where ofmts = flag optOutputFormats opts cnc2haskell (cnc,gr) = do mapM_ writeExport $ concretes2haskell opts (srcAbsName gr cnc) gr + abs2canonical (cnc,gr) = + writeExport ("canonical/"++render absname++".gf",render80 canAbs) + where + absname = srcAbsName gr cnc + canAbs = abstract2canonical absname gr + cnc2canonical (cnc,gr) = - do createDirectoryIfMissing False "canonical" - mapM_ (writeExport.fmap render80) $ - concretes2canonical opts (srcAbsName gr cnc) gr + mapM_ (writeExport.fmap render80) $ + concretes2canonical opts (srcAbsName gr cnc) gr writeExport (path,s) = writing opts path $ writeUTF8File path s -- cgit v1.2.3