summaryrefslogtreecommitdiff
path: root/src/GF/GFCC
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-01-31 16:37:32 +0000
committeraarne <aarne@cs.chalmers.se>2008-01-31 16:37:32 +0000
commit8f8aac4d24b8ea7d0867df8b3f890422a1f833d8 (patch)
tree05fcda4d1d2bd628b6ebae138f0a473c7857929f /src/GF/GFCC
parentc6137229ebb66b0a299b3ff09bd6fabf01444884 (diff)
gfcc generation with HOAS: var fields appended to records
Diffstat (limited to 'src/GF/GFCC')
-rw-r--r--src/GF/GFCC/CheckGFCC.hs7
-rw-r--r--src/GF/GFCC/Linearize.hs9
-rw-r--r--src/GF/GFCC/Macros.hs8
3 files changed, 20 insertions, 4 deletions
diff --git a/src/GF/GFCC/CheckGFCC.hs b/src/GF/GFCC/CheckGFCC.hs
index dfd9b2a0e..33302ab1b 100644
--- a/src/GF/GFCC/CheckGFCC.hs
+++ b/src/GF/GFCC/CheckGFCC.hs
@@ -138,10 +138,13 @@ str :: CType
str = S []
lintype :: GFCC -> CId -> CId -> LinType
-lintype gfcc lang fun = case catSkeleton (lookType gfcc fun) of
- (cs,c) -> (map linc cs, linc c) ---- HOAS
+lintype gfcc lang fun = case typeSkeleton (lookType gfcc fun) of
+ (cs,c) -> (map vlinc cs, linc c) ---- HOAS
where
linc = lookLincat gfcc lang
+ vlinc (0,c) = linc c
+ vlinc (i,c) = case linc c of
+ R ts -> R (ts ++ replicate i str)
inline :: GFCC -> CId -> Term -> Term
inline gfcc lang t = case t of
diff --git a/src/GF/GFCC/Linearize.hs b/src/GF/GFCC/Linearize.hs
index 7d5e6b010..b585385ea 100644
--- a/src/GF/GFCC/Linearize.hs
+++ b/src/GF/GFCC/Linearize.hs
@@ -27,19 +27,24 @@ realize trm = case trm of
_ -> "ERROR " ++ show trm ---- debug
linExp :: GFCC -> CId -> Exp -> Term
-linExp mcfg lang tree@(DTr _ at trees) = ---- bindings TODO
+linExp mcfg lang tree@(DTr xs at trees) = ---- bindings TODO
case at of
- AC fun -> comp (lmap lin trees) $ look fun
+ AC fun -> addB $ comp (lmap lin trees) $ look fun
AS s -> R [kks (show s)] -- quoted
AI i -> R [kks (show i)]
--- [C lst, kks (show i), C size] where
--- lst = mod (fromInteger i) 10 ; size = if i < 10 then 0 else 1
AF d -> R [kks (show d)]
+ AV x -> addB $ R [kks (prCId x)] ---- lindef of cat
AM _ -> TM
where
lin = linExp mcfg lang
comp = compute mcfg lang
look = lookLin mcfg lang
+ addB t
+ | Data.List.null xs = t
+ | otherwise = case t of
+ R ts -> R $ ts ++ (Data.List.map (kks . prCId) xs)
compute :: GFCC -> CId -> [Term] -> Term -> Term
compute mcfg lang args = comp where
diff --git a/src/GF/GFCC/Macros.hs b/src/GF/GFCC/Macros.hs
index 383b77d34..d38ccb2e5 100644
--- a/src/GF/GFCC/Macros.hs
+++ b/src/GF/GFCC/Macros.hs
@@ -69,10 +69,18 @@ catSkeleton :: Type -> ([CId],CId)
catSkeleton ty = case ty of
DTyp hyps val _ -> ([valCat ty | Hyp _ ty <- hyps],val)
+typeSkeleton :: Type -> ([(Int,CId)],CId)
+typeSkeleton ty = case ty of
+ DTyp hyps val _ -> ([(contextLength ty, valCat ty) | Hyp _ ty <- hyps],val)
+
valCat :: Type -> CId
valCat ty = case ty of
DTyp _ val _ -> val
+contextLength :: Type -> Int
+contextLength ty = case ty of
+ DTyp hyps _ _ -> length hyps
+
cid :: String -> CId
cid = CId