summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Command
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-09-24 12:39:49 +0000
committeraarne <aarne@chalmers.se>2010-09-24 12:39:49 +0000
commit709b0518fa284b41777cbec015a4647303e7a0b3 (patch)
tree045b344fdc5c2d0d985da62e5dac7a2176255c3e /src/compiler/GF/Command
parent617ce3cce67acca54a1ef3127da91bcd3e6a12ab (diff)
restored the .ebnf grammar format
Diffstat (limited to 'src/compiler/GF/Command')
-rw-r--r--src/compiler/GF/Command/Importing.hs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/compiler/GF/Command/Importing.hs b/src/compiler/GF/Command/Importing.hs
index 194c993ba..80f3833ee 100644
--- a/src/compiler/GF/Command/Importing.hs
+++ b/src/compiler/GF/Command/Importing.hs
@@ -6,6 +6,7 @@ import PGF.Data
import GF.Compile
import GF.Grammar (identC, SourceGrammar) -- for cc command
import GF.Grammar.CF
+import GF.Grammar.EBNF
import GF.Infra.UseIO
import GF.Infra.Option
import GF.Data.ErrM
@@ -19,17 +20,8 @@ importGrammar :: PGF -> Options -> [FilePath] -> IO PGF
importGrammar pgf0 _ [] = return pgf0
importGrammar pgf0 opts files =
case takeExtensions (last files) of
- ".cf" -> do
- s <- fmap unlines $ mapM readFile files
- let cnc = justModuleName (last files)
- gf <- case getCF cnc s of
- Ok g -> return g
- Bad s -> error s ----
- Ok gr <- appIOE $ compileSourceGrammar opts gf
- epgf <- appIOE $ link opts (identC (BS.pack (cnc ++ "Abs"))) gr
- case epgf of
- Ok pgf -> return pgf
- Bad s -> error s ----
+ ".cf" -> importCF opts files getCF
+ ".ebnf" -> importCF opts files getEBNF
s | elem s [".gf",".gfo"] -> do
res <- appIOE $ compileToPGF opts files
case res of
@@ -49,3 +41,16 @@ importSource src0 opts files = do
Bad msg -> do
putStrLn msg
return src0
+
+-- for different cf formats
+importCF opts files get = do
+ s <- fmap unlines $ mapM readFile files
+ let cnc = justModuleName (last files)
+ gf <- case get cnc s of
+ Ok g -> return g
+ Bad s -> error s ----
+ Ok gr <- appIOE $ compileSourceGrammar opts gf
+ epgf <- appIOE $ link opts (identC (BS.pack (cnc ++ "Abs"))) gr
+ case epgf of
+ Ok pgf -> return pgf
+ Bad s -> error s ----