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).
This commit is contained in:
Thomas Hallgren
2019-01-22 17:16:32 +01:00
parent a40130ddc4
commit e4abff7725
6 changed files with 101 additions and 27 deletions

View File

@@ -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