From 1c0ecb44c436522df62fff3df09b49a44ca56c71 Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 15 Nov 2005 16:56:13 +0000 Subject: [PATCH] work on cf --- src/GF/CF/PPrCF.hs | 10 +++++----- src/GF/Compile/GetGrammar.hs | 17 +++++++++++------ 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 ---