mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
work on cf
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 ---
|
||||
|
||||
Reference in New Issue
Block a user