mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
debugging new compilation
This commit is contained in:
@@ -13,7 +13,7 @@ comment "{-" "-}" ;
|
|||||||
|
|
||||||
-- identifiers
|
-- identifiers
|
||||||
|
|
||||||
position token PIdent (letter | '_') (letter | digit | '_' | '\'')* ;
|
position token PIdent ('_')? letter (letter | digit | '_' | '\'')* ;
|
||||||
|
|
||||||
-- the top-level grammar
|
-- the top-level grammar
|
||||||
|
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ import GF.Devel.Grammar.Compute
|
|||||||
|
|
||||||
--import GF.Infra.Ident
|
--import GF.Infra.Ident
|
||||||
|
|
||||||
--import GF.Grammar.Lookup
|
import GF.Devel.Grammar.Lookup
|
||||||
--import GF.Grammar.Refresh
|
--import GF.Grammar.Refresh
|
||||||
|
|
||||||
--import GF.Compile.BackOpt
|
--import GF.Compile.BackOpt
|
||||||
--import GF.Devel.CheckGrammar
|
import GF.Devel.Compile.CheckGrammar
|
||||||
--import GF.Compile.Update
|
--import GF.Compile.Update
|
||||||
|
|
||||||
|
|
||||||
@@ -45,8 +45,8 @@ import Debug.Trace
|
|||||||
optimizeModule :: Options -> GF -> SourceModule -> Err SourceModule
|
optimizeModule :: Options -> GF -> SourceModule -> Err SourceModule
|
||||||
optimizeModule opts gf0 sm@(m,mo) = case mtype mo of
|
optimizeModule opts gf0 sm@(m,mo) = case mtype mo of
|
||||||
MTConcrete _ -> opt sm
|
MTConcrete _ -> opt sm
|
||||||
MTInstance _ -> opt sm
|
MTInstance _ -> optr sm
|
||||||
MTGrammar -> opt sm
|
MTGrammar -> optr sm
|
||||||
_ -> return sm
|
_ -> return sm
|
||||||
where
|
where
|
||||||
gf = gf0 {gfmodules = Map.insert m mo (gfmodules gf0)}
|
gf = gf0 {gfmodules = Map.insert m mo (gfmodules gf0)}
|
||||||
@@ -54,6 +54,19 @@ optimizeModule opts gf0 sm@(m,mo) = case mtype mo of
|
|||||||
mo' <- termOpModule (computeTerm gf) mo
|
mo' <- termOpModule (computeTerm gf) mo
|
||||||
return (m,mo')
|
return (m,mo')
|
||||||
|
|
||||||
|
optr (m,mo)= do
|
||||||
|
let deps = allOperDependencies m $ mjments mo
|
||||||
|
ids <- topoSortOpers deps
|
||||||
|
gf' <- foldM evalOp gf ids
|
||||||
|
mo' <- lookupModule gf' m
|
||||||
|
return $ (m,mo')
|
||||||
|
where
|
||||||
|
evalOp gf i = do
|
||||||
|
ju <- lookupJudgement gf m i
|
||||||
|
def' <- computeTerm gf (jdef ju)
|
||||||
|
updateJudgement m i (ju {jdef = def'}) gf
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{-
|
{-
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ computeTermOpt rec gr = comp where
|
|||||||
---- Computed t' -> return $ unComputed t'
|
---- Computed t' -> return $ unComputed t'
|
||||||
|
|
||||||
Vr x -> do
|
Vr x -> do
|
||||||
t' <- maybe (prtBad ("no value given to variable") x) return $ lookup x g
|
t' <- maybe (prtBad ("no value for variable") x) return $ lookup x g
|
||||||
case t' of
|
case t' of
|
||||||
_ | t == t' -> return t
|
_ | t == t' -> return t
|
||||||
_ -> comp g t'
|
_ -> comp g t'
|
||||||
|
|||||||
@@ -149,7 +149,11 @@ unifyJudgement old new = do
|
|||||||
---- (unwords ["illegal update of",prt oterm,"to",prt nterm])
|
---- (unwords ["illegal update of",prt oterm,"to",prt nterm])
|
||||||
return nterm
|
return nterm
|
||||||
|
|
||||||
|
updateJudgement :: Ident -> Ident -> Judgement -> GF -> Err GF
|
||||||
|
updateJudgement m c ju gf = do
|
||||||
|
mo <- maybe (Bad (show m)) return $ Data.Map.lookup m $ gfmodules gf
|
||||||
|
let mo' = mo {mjments = insert c ju (mjments mo)}
|
||||||
|
return $ gf {gfmodules = insert m mo' (gfmodules gf)}
|
||||||
|
|
||||||
-- abstractions on Term
|
-- abstractions on Term
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user