diff options
| author | aarne <aarne@cs.chalmers.se> | 2007-11-28 11:58:47 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2007-11-28 11:58:47 +0000 |
| commit | 5257fd963eaf9a38fce3c96479f9ee19ed88104a (patch) | |
| tree | 05d82522ce79a55894bb630aa2b92e5619c2da65 /src/GF/Devel/Modules.hs | |
| parent | 5b0f98f388886932597b656e58a6d215f274fddb (diff) | |
new definitions of term and judgement syntax
Diffstat (limited to 'src/GF/Devel/Modules.hs')
| -rw-r--r-- | src/GF/Devel/Modules.hs | 52 |
1 files changed, 38 insertions, 14 deletions
diff --git a/src/GF/Devel/Modules.hs b/src/GF/Devel/Modules.hs index bf45f86c3..1b7a2bca5 100644 --- a/src/GF/Devel/Modules.hs +++ b/src/GF/Devel/Modules.hs @@ -1,10 +1,12 @@ module GF.Devel.Modules where -import GF.Grammar.Grammar +import GF.Devel.Judgements +import GF.Devel.Terms import GF.Infra.Ident import GF.Data.Operations +import Control.Monad import Data.Map @@ -45,23 +47,45 @@ data MInclude = | MIExcept [Ident] | MIOnly [Ident] -data Judgement = Judgement { - jform :: JudgementForm, -- cat fun oper param - jtype :: Type, -- context type type type - jdef :: Term, -- lindef def - values - jlin :: Term, -- lincat lin def constructors - jprintname :: Term -- printname printname - - - } -data JudgementForm = - JCat - | JFun - | JOper - | JParam +-- look up fields for a constant in a grammar + +lookupJField :: (Judgement -> a) -> GF -> Ident -> Ident -> Err a +lookupJField field gf m c = do + j <- lookupJudgement gf m c + return $ field j + +lookupJForm :: GF -> Ident -> Ident -> Err JudgementForm +lookupJForm = lookupJField jform + +-- the following don't (need to) check that the jment form is adequate + +lookupCatContext :: GF -> Ident -> Ident -> Err Context +lookupCatContext gf m c = do + ty <- lookupJField jtype gf m c + return [] ---- context of ty + +lookupFunType :: GF -> Ident -> Ident -> Err Term +lookupFunType = lookupJField jtype + +lookupLin :: GF -> Ident -> Ident -> Err Term +lookupLin = lookupJField jlin + +lookupLincat :: GF -> Ident -> Ident -> Err Term +lookupLincat = lookupJField jlin + +lookupParamValues :: GF -> Ident -> Ident -> Err [Term] +lookupParamValues gf m c = do + j <- lookupJudgement gf m c + case jdef j of + V _ ts -> return ts + _ -> raise "no parameter values" +-- infrastructure for lookup + lookupIdent :: GF -> Ident -> Ident -> Err (Either Judgement Ident) lookupIdent gf m c = do - mo <- maybe (Bad "module not found") return $ mlookup m (gfmodules gf) + mo <- maybe (raise "module not found") return $ mlookup m (gfmodules gf) maybe (Bad "constant not found") return $ mlookup c (mjments mo) lookupJudgement :: GF -> Ident -> Ident -> Err Judgement |
