summaryrefslogtreecommitdiff
path: root/src/GF
diff options
context:
space:
mode:
authoraarne <unknown>2005-11-15 16:56:13 +0000
committeraarne <unknown>2005-11-15 16:56:13 +0000
commit2cea1a25bb9082953aa4e9c1a8ac41db09b5c761 (patch)
treebf1a237c80f6eae70a454418d03654e23b4e61f4 /src/GF
parent1fd1f44fcc81149b286992dd13b3128d42c4736e (diff)
work on cf
Diffstat (limited to 'src/GF')
-rw-r--r--src/GF/CF/PPrCF.hs10
-rw-r--r--src/GF/Compile/GetGrammar.hs17
2 files changed, 16 insertions, 11 deletions
diff --git a/src/GF/CF/PPrCF.hs b/src/GF/CF/PPrCF.hs
index 6d617c6be..d40a93c57 100644
--- a/src/GF/CF/PPrCF.hs
+++ b/src/GF/CF/PPrCF.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/11/15 11:43:33 $
+-- > CVS $Date: 2005/11/15 17:56:13 $
-- > CVS $Author: aarne $
--- > CVS $Revision: 1.12 $
+-- > CVS $Revision: 1.13 $
--
-- printing and parsing CF grammars, rules, and trees AR 26/1/2000 -- 9/6/2003
--
@@ -89,11 +89,11 @@ getCFRule mo s = getcf (wrds s) where
clean = filter isAlphaNum -- to form valid identifiers
wrds = takeWhile (/= ";") . words -- to permit semicolon in the end
-pCF :: String -> String -> Err CF
+pCF :: String -> String -> Err [CFRule]
pCF mo s = do
rules <- mapM (getCFRule mo) $ filter isRule $ lines s
- return $ rules2CF $ concat rules
+ return $ concat rules
where
- isRule line = case line of
+ isRule line = case dropWhile isSpace line of
'-':'-':_ -> False
_ -> not $ all isSpace line
diff --git a/src/GF/Compile/GetGrammar.hs b/src/GF/Compile/GetGrammar.hs
index 4e5328bf3..a848c9bcf 100644
--- a/src/GF/Compile/GetGrammar.hs
+++ b/src/GF/Compile/GetGrammar.hs
@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
--- > CVS $Date: 2005/04/21 16:21:37 $
--- > CVS $Author: bringert $
--- > CVS $Revision: 1.15 $
+-- > CVS $Date: 2005/11/15 17:56:13 $
+-- > CVS $Author: aarne $
+-- > CVS $Revision: 1.16 $
--
-- this module builds the internal GF grammar that is sent to the type checker
-----------------------------------------------------------------------------
@@ -32,6 +32,7 @@ import GF.Infra.Option
import GF.Source.ParGF
import qualified GF.Source.LexGF as L
+import GF.CF.CF (rules2CF)
import GF.CF.PPrCF
import GF.CF.CFtoGrammar
import GF.CF.EBNF
@@ -103,9 +104,13 @@ oldLexer = map change . L.tokens where
getCFGrammar :: Options -> FilePath -> IOE SourceGrammar
getCFGrammar opts file = do
let mo = takeWhile (/='.') file
- s <- ioeIO $ readFileIf file
- cf <- ioeErr $ pCF mo s
- defs <- return $ cf2grammar cf
+ s <- ioeIO $ readFileIf file
+ let files = case words (concat (take 1 (lines s))) of
+ "--":"include":fs -> fs
+ _ -> []
+ ss <- ioeIO $ mapM readFileIf files
+ cfs <- ioeErr $ mapM (pCF mo) $ s:ss
+ defs <- return $ cf2grammar $ rules2CF $ concat cfs
let g = A.OldGr A.NoIncl defs
--- let ma = justModuleName file
--- let mc = 'C':ma ---