summaryrefslogtreecommitdiff
path: root/src-3.0/GF
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-05-24 09:16:59 +0000
committeraarne <aarne@cs.chalmers.se>2008-05-24 09:16:59 +0000
commit0db611a9abfb31c76933a455da946cf2194ded7b (patch)
treef7548438d460ec72bfe1d74fd8673dfa3183c7d6 /src-3.0/GF
parent5a386209ddf005f5a090f3668cfe246c3df22057 (diff)
support for source gr and i -retain in GFI env
Diffstat (limited to 'src-3.0/GF')
-rw-r--r--src-3.0/GF/Command/Importing.hs15
-rw-r--r--src-3.0/GF/Grammar/Grammar.hs3
2 files changed, 16 insertions, 2 deletions
diff --git a/src-3.0/GF/Command/Importing.hs b/src-3.0/GF/Command/Importing.hs
index 868ca02b6..f200ba7c4 100644
--- a/src-3.0/GF/Command/Importing.hs
+++ b/src-3.0/GF/Command/Importing.hs
@@ -1,9 +1,11 @@
-module GF.Command.Importing (importGrammar) where
+module GF.Command.Importing (importGrammar, importSource) where
import GF.Compile
import GF.GFCC.DataGFCC
import GF.GFCC.API
+import GF.Grammar.Grammar (SourceGrammar) -- for cc command
+
import GF.Infra.UseIO
import GF.Infra.Option
import GF.Data.ErrM
@@ -25,4 +27,13 @@ importGrammar mgr0 opts files =
".gfcc" -> do
gfcc2 <- mapM file2gfcc files >>= return . foldl1 unionGFCC
let gfcc3 = unionGFCC (gfcc mgr0) gfcc2
- return $ MultiGrammar gfcc3 \ No newline at end of file
+ return $ MultiGrammar gfcc3
+
+importSource :: SourceGrammar -> Options -> [FilePath] -> IO SourceGrammar
+importSource src0 opts files = do
+ src <- appIOE $ batchCompile opts files
+ case src of
+ Ok gr -> return gr
+ Bad msg -> do
+ putStrLn msg
+ return src0
diff --git a/src-3.0/GF/Grammar/Grammar.hs b/src-3.0/GF/Grammar/Grammar.hs
index f451d0b27..9771a56dd 100644
--- a/src-3.0/GF/Grammar/Grammar.hs
+++ b/src-3.0/GF/Grammar/Grammar.hs
@@ -15,6 +15,7 @@
-----------------------------------------------------------------------------
module GF.Grammar.Grammar (SourceGrammar,
+ emptySourceGrammar,
SourceModInfo,
SourceModule,
SourceAbs,
@@ -64,6 +65,8 @@ import qualified Data.ByteString.Char8 as BS
-- | grammar as presented to the compiler
type SourceGrammar = MGrammar Ident Info
+emptySourceGrammar = MGrammar []
+
type SourceModInfo = ModInfo Ident Info
type SourceModule = (Ident, SourceModInfo)