From 72b22a54cd21801cfd0847fe0a3444479db1a1b5 Mon Sep 17 00:00:00 2001 From: aarne Date: Tue, 24 Jan 2006 15:18:46 +0000 Subject: [PATCH] the parser can read .gfm files (but they are not yet compiled all the way) --- src/GF/Compile/Compile.hs | 12 ++++++------ src/GF/Compile/GetGrammar.hs | 11 ++++++++++- src/GF/Compile/ModDeps.hs | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/GF/Compile/Compile.hs b/src/GF/Compile/Compile.hs index 0b14cedc1..c364e1adf 100644 --- a/src/GF/Compile/Compile.hs +++ b/src/GF/Compile/Compile.hs @@ -77,15 +77,15 @@ compileModule :: Options -> ShellState -> FilePath -> IOE TimedCompileEnv compileModule opts st0 file | oElem showOld opts || - elem suff ["cf","ebnf"] = do + elem suff ["cf","ebnf","gfm"] = do let putp = putPointE opts let putpp = putPointEsil opts let path = [] ---- - grammar1 <- if suff == "cf" - then putp ("- parsing" +++ suff +++ file) $ getCFGrammar opts file - else if suff == "ebnf" - then putp ("- parsing" +++ suff +++ file) $ getEBNFGrammar opts file - else putp ("- parsing old gf" +++ file) $ getOldGrammar opts file + grammar1 <- case suff of + "cf" -> putp ("- parsing" +++ suff +++ file) $ getCFGrammar opts file + "ebnf" -> putp ("- parsing" +++ suff +++ file) $ getEBNFGrammar opts file + "gfm" -> putp ("- parsing" +++ suff +++ file) $ getSourceGrammar file + _ -> putp ("- parsing old gf" +++ file) $ getOldGrammar opts file let mods = modules grammar1 let env = compileEnvShSt st0 [] foldM (comp putpp path) env mods diff --git a/src/GF/Compile/GetGrammar.hs b/src/GF/Compile/GetGrammar.hs index a848c9bcf..4eebc2845 100644 --- a/src/GF/Compile/GetGrammar.hs +++ b/src/GF/Compile/GetGrammar.hs @@ -12,7 +12,9 @@ -- this module builds the internal GF grammar that is sent to the type checker ----------------------------------------------------------------------------- -module GF.Compile.GetGrammar (getSourceModule, getOldGrammar, getCFGrammar, getEBNFGrammar, +module GF.Compile.GetGrammar ( + getSourceModule, getSourceGrammar, + getOldGrammar, getCFGrammar, getEBNFGrammar, err2err ) where @@ -50,6 +52,13 @@ getSourceModule file = do mo1 <- ioeErr $ {- err2err $ -} pModDef tokens ioeErr $ transModDef mo1 +getSourceGrammar :: FilePath -> IOE SourceGrammar +getSourceGrammar file = do + string <- readFileIOE file + let tokens = myLexer string + gr1 <- ioeErr $ {- err2err $ -} pGrammar tokens + ioeErr $ transGrammar gr1 + -- for old GF format with includes diff --git a/src/GF/Compile/ModDeps.hs b/src/GF/Compile/ModDeps.hs index d2d3cbe83..737c7e4c1 100644 --- a/src/GF/Compile/ModDeps.hs +++ b/src/GF/Compile/ModDeps.hs @@ -57,7 +57,7 @@ checkUniqueErr ms = do checkUniqueImportNames :: [Ident] -> SourceModInfo -> Err () checkUniqueImportNames ns mo = case mo of ModMod m -> test [n | OQualif _ n v <- opens m, n /= v] - + _ -> return () --- Bad $ "bug: ModDeps does not treat" +++ show mo where test ms = testErr (all (`notElem` ns) ms)