mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-23 09:52:55 -06:00
the parser can read .gfm files (but they are not yet compiled all the way)
This commit is contained in:
@@ -77,15 +77,15 @@ compileModule :: Options -> ShellState -> FilePath -> IOE TimedCompileEnv
|
|||||||
|
|
||||||
compileModule opts st0 file |
|
compileModule opts st0 file |
|
||||||
oElem showOld opts ||
|
oElem showOld opts ||
|
||||||
elem suff ["cf","ebnf"] = do
|
elem suff ["cf","ebnf","gfm"] = do
|
||||||
let putp = putPointE opts
|
let putp = putPointE opts
|
||||||
let putpp = putPointEsil opts
|
let putpp = putPointEsil opts
|
||||||
let path = [] ----
|
let path = [] ----
|
||||||
grammar1 <- if suff == "cf"
|
grammar1 <- case suff of
|
||||||
then putp ("- parsing" +++ suff +++ file) $ getCFGrammar opts file
|
"cf" -> putp ("- parsing" +++ suff +++ file) $ getCFGrammar opts file
|
||||||
else if suff == "ebnf"
|
"ebnf" -> putp ("- parsing" +++ suff +++ file) $ getEBNFGrammar opts file
|
||||||
then putp ("- parsing" +++ suff +++ file) $ getEBNFGrammar opts file
|
"gfm" -> putp ("- parsing" +++ suff +++ file) $ getSourceGrammar file
|
||||||
else putp ("- parsing old gf" +++ file) $ getOldGrammar opts file
|
_ -> putp ("- parsing old gf" +++ file) $ getOldGrammar opts file
|
||||||
let mods = modules grammar1
|
let mods = modules grammar1
|
||||||
let env = compileEnvShSt st0 []
|
let env = compileEnvShSt st0 []
|
||||||
foldM (comp putpp path) env mods
|
foldM (comp putpp path) env mods
|
||||||
|
|||||||
@@ -12,7 +12,9 @@
|
|||||||
-- this module builds the internal GF grammar that is sent to the type checker
|
-- 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
|
err2err
|
||||||
) where
|
) where
|
||||||
|
|
||||||
@@ -50,6 +52,13 @@ getSourceModule file = do
|
|||||||
mo1 <- ioeErr $ {- err2err $ -} pModDef tokens
|
mo1 <- ioeErr $ {- err2err $ -} pModDef tokens
|
||||||
ioeErr $ transModDef mo1
|
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
|
-- for old GF format with includes
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ checkUniqueErr ms = do
|
|||||||
checkUniqueImportNames :: [Ident] -> SourceModInfo -> Err ()
|
checkUniqueImportNames :: [Ident] -> SourceModInfo -> Err ()
|
||||||
checkUniqueImportNames ns mo = case mo of
|
checkUniqueImportNames ns mo = case mo of
|
||||||
ModMod m -> test [n | OQualif _ n v <- opens m, n /= v]
|
ModMod m -> test [n | OQualif _ n v <- opens m, n /= v]
|
||||||
|
_ -> return () --- Bad $ "bug: ModDeps does not treat" +++ show mo
|
||||||
where
|
where
|
||||||
|
|
||||||
test ms = testErr (all (`notElem` ns) ms)
|
test ms = testErr (all (`notElem` ns) ms)
|
||||||
|
|||||||
Reference in New Issue
Block a user