diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-06-27 09:18:50 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-06-27 09:18:50 +0000 |
| commit | 5c713d8f027a9b6be687ee3f7e917e8bd2115773 (patch) | |
| tree | 65da19829810b753345a5b2164bef2d8876268dd /old-examples/gfcc/compiler/Trees.hs | |
| parent | f7b2a83059697f1b36a6369e489ac276e7ff875d (diff) | |
took away old-examples
Diffstat (limited to 'old-examples/gfcc/compiler/Trees.hs')
| -rw-r--r-- | old-examples/gfcc/compiler/Trees.hs | 78 |
1 files changed, 0 insertions, 78 deletions
diff --git a/old-examples/gfcc/compiler/Trees.hs b/old-examples/gfcc/compiler/Trees.hs deleted file mode 100644 index 57fbfd966..000000000 --- a/old-examples/gfcc/compiler/Trees.hs +++ /dev/null @@ -1,78 +0,0 @@ -module Trees where - -data Exp = - EApp Exp Exp - | EAbs Ident Exp - | EAtom Atom - deriving (Eq,Ord,Show) - -newtype CFTree = CFTree (CFFun,[CFTree]) deriving (Eq, Show) - -type CFCat = Ident - -newtype Ident = Ident String deriving (Eq, Ord, Show) - --- to build trees: the Atom contains a GF function, Cn | Meta | Vr | Literal -newtype CFFun = CFFun (Atom, Profile) deriving (Eq,Ord,Show) - -type Profile = [([[Int]],[Int])] - -data Atom = - AC Ident - | AV Ident - | AM - | AS String - | AI Integer - deriving (Eq,Ord,Show) - --- printing - -class Prt a where - prt :: a -> String - -instance Prt Exp where - prt e = case e of - EApp f a -> unwords [prt f, prt1 a] - EAbs x a -> "\\" ++ prt x ++ " -> " ++ prt a - EAtom a -> prt a - where - prt1 e = case e of - EAtom _ -> prt e - _ -> "(" ++ prt e ++ ")" - -instance Prt Atom where - prt a = case a of - AC x -> prt x - AV x -> prt x - AM -> "?" - AS s -> show s ---- - AI i -> show i - -instance Prt Ident where - prt (Ident x) = x - --- printing trees - -prCFTree :: CFTree -> String -prCFTree (CFTree (fun, trees)) = prCFFun fun ++ prs trees where - prs [] = "" - prs ts = " " ++ unwords (map ps ts) - ps t@(CFTree (_,[])) = prCFTree t - ps t = "(" ++ prCFTree t ++ ")" - -prCFFun :: CFFun -> String -prCFFun = prCFFun' True ---- False -- print profiles for debug - -prCFFun' :: Bool -> CFFun -> String -prCFFun' profs (CFFun (t, p)) = prt t ++ pp p where - pp p = if (not profs || normal p) then "" else "_" ++ concat (map show p) - normal p = and [x==y && null b | ((b,x),y) <- zip p (map (:[]) [0..])] - -prCFCat :: CFCat -> String -prCFCat c = prt c - -mkFunTree :: String -> Profile -> [CFTree] -> CFTree -mkFunTree f p ts = CFTree (CFFun (AC (Ident f),p), ts) - -mkAtTree :: Atom -> CFTree -mkAtTree a = CFTree (CFFun (a,[]), []) |
