summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Command/PPrTree.hs
blob: 7562d6fab8fcb9add27c8767ca3b0a6abcabecc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
module GF.Command.PPrTree (tree2exp, exp2tree) where

import PGF.CId
import PGF.Data
import GF.Command.AbsGFShell

tree2exp t = case t of
  TApp f ts -> EApp (i2i f) (map tree2exp ts)
  TAbs xs t -> EAbs (map i2i xs) (tree2exp t)
  TId c     -> EApp (i2i c) []
  TInt i    -> EInt   i
  TStr s    -> EStr   s
  TFloat d  -> EFloat d
 where
   i2i (Ident s) = mkCId s

exp2tree t = case t of
  (EAbs xs e) -> TAbs (map i4i xs) (exp2tree e)
  (EApp f []) -> TId (i4i f)
  (EApp f es) -> TApp (i4i f) (map exp2tree es)
  (EInt   i)  -> TInt i
  (EStr   i)  -> TStr i
  (EFloat i)  -> TFloat i
  (EMeta  i)  -> TId (Ident "?") ----
  where
    i4i s = Ident (prCId s)