1
0
forked from GitHub/gf-core

the parser can read .gfm files (but they are not yet compiled all the way)

This commit is contained in:
aarne
2006-01-24 15:18:46 +00:00
parent 10f2fd2457
commit 72b22a54cd
3 changed files with 17 additions and 8 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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)