diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-11-06 14:44:17 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-11-06 14:44:17 +0000 |
| commit | 2b1d5a4d513970308f47c735212cbc253ec40961 (patch) | |
| tree | 2395299df4ba44d7cfb060b9294ea38f1dce63f4 /src/GF/Command/Importing.hs | |
| parent | 693621ffbe9146f24ba75e073b6ce2e716c56a5e (diff) | |
Devel/GF3: experimentally putting together all functionalities for the first time
Diffstat (limited to 'src/GF/Command/Importing.hs')
| -rw-r--r-- | src/GF/Command/Importing.hs | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/GF/Command/Importing.hs b/src/GF/Command/Importing.hs new file mode 100644 index 000000000..dc8255ad2 --- /dev/null +++ b/src/GF/Command/Importing.hs @@ -0,0 +1,34 @@ +module GF.Command.Importing (importGrammar) where + +import GF.Devel.Compile +import GF.Devel.GrammarToGFCC +import GF.GFCC.OptimizeGFCC +import GF.GFCC.CheckGFCC +import GF.GFCC.DataGFCC +import GF.GFCC.ParGFCC +import GF.GFCC.API +import qualified GF.Command.AbsGFShell as C + +import GF.Devel.UseIO +import GF.Infra.Option + +import Data.List (nubBy) + +-- import a grammar in an environment where it extends an existing grammar +importGrammar :: MultiGrammar -> Options -> [FilePath] -> IO MultiGrammar +importGrammar mgr0 opts files = do + gfcc2 <- case fileSuffix (last files) of + s | elem s ["gf","gfo"] -> do + gr <- batchCompile opts files + let name = justModuleName (last files) + let (abs,gfcc0) = mkCanon2gfcc opts name gr + (gfcc1,b) <- checkGFCC gfcc0 + if b then return () else do + putStrLn "Corrupted GFCC" + return $ if oElem (iOpt "noopt") opts then gfcc1 else optGFCC gfcc1 + "gfcc" -> + mapM file2gfcc files >>= return . foldl1 unionGFCC + let gfcc3 = unionGFCC (gfcc mgr0) gfcc2 + return $ MultiGrammar gfcc3 + (nubBy (\ (x,_) (y,_) -> x == y) (gfcc2parsers gfcc3 ++ parsers mgr0)) + -- later coming parsers override |
