forked from GitHub/gf-core
refactor the GF.Grammar.Grammar syntax. The obsolete constructions are removed
This commit is contained in:
@@ -27,6 +27,7 @@ import GF.Infra.Option
|
||||
import GF.Data.Operations
|
||||
|
||||
import Data.List (nub)
|
||||
import Data.Maybe (isNothing)
|
||||
|
||||
-- | rebuilding instance + interface, and "with" modules, prior to renaming.
|
||||
-- AR 24/10/2003
|
||||
@@ -39,13 +40,13 @@ rebuildModule ms mo@(i,mi) = do
|
||||
mi' <- case mi of
|
||||
|
||||
-- add the information given in interface into an instance module
|
||||
ModMod m -> do
|
||||
m | isNothing (mwith m) -> do
|
||||
testErr (null is || mstatus m == MSIncomplete)
|
||||
("module" +++ prt i +++
|
||||
"has open interfaces and must therefore be declared incomplete")
|
||||
case mtype m of
|
||||
MTInstance i0 -> do
|
||||
m1 <- lookupModMod gr i0
|
||||
m1 <- lookupModule gr i0
|
||||
testErr (isModRes m1) ("interface expected instead of" +++ prt i0)
|
||||
m' <- do
|
||||
js' <- extendMod False (i0,const True) i (jments m1) (jments m)
|
||||
@@ -53,7 +54,7 @@ rebuildModule ms mo@(i,mi) = do
|
||||
case extends m of
|
||||
[] -> return $ replaceJudgements m js'
|
||||
j0s -> do
|
||||
m0s <- mapM (lookupModMod gr) j0s
|
||||
m0s <- mapM (lookupModule gr) j0s
|
||||
let notInM0 c _ = all (not . isInBinTree c . jments) m0s
|
||||
let js2 = filterBinTree notInM0 js'
|
||||
return $ (replaceJudgements m js2)
|
||||
@@ -61,37 +62,35 @@ rebuildModule ms mo@(i,mi) = do
|
||||
buildTree (tree2list (positions m1) ++
|
||||
tree2list (positions m))}
|
||||
-- checkCompleteInstance m1 m'
|
||||
return $ ModMod m'
|
||||
return m'
|
||||
_ -> return mi
|
||||
|
||||
-- add the instance opens to an incomplete module "with" instances
|
||||
-- ModWith mt stat ext me ops -> do
|
||||
ModWith (Module mt stat fs_ me ops_ js_ ps_) (ext,incl) ops -> do
|
||||
let insts = [(inf,inst) | OQualif _ inf inst <- ops]
|
||||
ModInfo mt stat fs_ me (Just (ext,incl,ops)) ops_ js_ ps_ -> do
|
||||
let insts = [(inf,inst) | OQualif inf inst <- ops]
|
||||
let infs = map fst insts
|
||||
let stat' = ifNull MSComplete (const MSIncomplete)
|
||||
[i | i <- is, notElem i infs]
|
||||
testErr (stat' == MSComplete || stat == MSIncomplete)
|
||||
("module" +++ prt i +++ "remains incomplete")
|
||||
Module mt0 _ fs me' ops0 js ps0 <- lookupModMod gr ext
|
||||
ModInfo mt0 _ fs me' _ ops0 js ps0 <- lookupModule gr ext
|
||||
let ops1 = nub $
|
||||
ops_ ++ -- N.B. js has been name-resolved already
|
||||
ops ++ [o | o <- ops0, notElem (openedModule o) infs]
|
||||
++ [oQualif i i | i <- map snd insts] ----
|
||||
++ [oSimple i | i <- map snd insts] ----
|
||||
++ [OQualif i i | i <- map snd insts] ----
|
||||
++ [OSimple i | i <- map snd insts] ----
|
||||
|
||||
--- check if me is incomplete
|
||||
let fs1 = fs `addOptions` fs_ -- new flags have priority
|
||||
let js0 = [ci | ci@(c,_) <- tree2list js, isInherited incl c]
|
||||
let js1 = buildTree (tree2list js_ ++ js0)
|
||||
let ps1 = buildTree (tree2list ps_ ++ tree2list ps0)
|
||||
return $ ModMod $ Module mt0 stat' fs1 me ops1 js1 ps1
|
||||
---- (mapTree (qualifInstanceInfo insts) js) -- not needed
|
||||
return $ ModInfo mt0 stat' fs1 me Nothing ops1 js1 ps1
|
||||
|
||||
_ -> return mi
|
||||
return (i,mi')
|
||||
|
||||
checkCompleteInstance :: SourceRes -> SourceRes -> Err ()
|
||||
checkCompleteInstance :: SourceModInfo -> SourceModInfo -> Err ()
|
||||
checkCompleteInstance abs cnc = ifNull (return ()) (Bad . unlines) $
|
||||
checkComplete [f | (f, ResOper (Yes _) _) <- abs'] cnc'
|
||||
where
|
||||
|
||||
Reference in New Issue
Block a user