top-level toy compiler - far from complete

This commit is contained in:
aarne
2007-03-27 16:32:44 +00:00
parent 273dc7120f
commit 1c1acf1b97
12 changed files with 388 additions and 54 deletions

16
devel/compiler/TMacros.hs Normal file
View File

@@ -0,0 +1,16 @@
module TMacros where
import AbsTgt
appVal :: Val -> [Val] -> Val
appVal v vs = compVal vs v
compVal :: [Val] -> Val -> Val
compVal args = comp where
comp val = case val of
VRec vs -> VRec $ map comp vs
VPro r p -> case (comp r, comp p) of
(VRec vs, VPar i) -> vs !! fromInteger i
VArg i -> args !! fromInteger i
VCat x y -> VCat (comp x) (comp y)
_ -> val