diff options
| author | aarne <aarne@chalmers.se> | 2013-03-29 11:45:42 +0000 |
|---|---|---|
| committer | aarne <aarne@chalmers.se> | 2013-03-29 11:45:42 +0000 |
| commit | e56bfe88111e8406e7f5ab3c764b9de02c49987d (patch) | |
| tree | 47bae081da2afea6c2cf1470b0012435ccb498d8 /src/compiler/GF/Command | |
| parent | 63c0b7ae5de4798a5b1c0a11e501fccd1f7a025e (diff) | |
option pt -funs to show all fun's in a tree
Diffstat (limited to 'src/compiler/GF/Command')
| -rw-r--r-- | src/compiler/GF/Command/TreeOperations.hs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/GF/Command/TreeOperations.hs b/src/compiler/GF/Command/TreeOperations.hs index ea6180317..bf8882802 100644 --- a/src/compiler/GF/Command/TreeOperations.hs +++ b/src/compiler/GF/Command/TreeOperations.hs @@ -27,7 +27,9 @@ allTreeOps pgf = [ ("smallest",("sort trees from smallest to largest, in number of nodes", Left $ smallest)), ("subtrees",("return all fully applied subtrees (stopping at abstractions), by default sorted from the largest", - Left $ concatMap subtrees)) + Left $ concatMap subtrees)), + ("funs",("return all fun functions appearing in the tree, with duplications", + Left $ concatMap funNodes)) ] largest :: [Expr] -> [Expr] @@ -45,6 +47,13 @@ subtrees t = t : case unApp t of Just (f,ts) -> concatMap subtrees ts _ -> [] -- don't go under abstractions +funNodes :: Expr -> [Expr] +funNodes t = case t of + EAbs _ _ e -> funNodes e + EApp e1 e2 -> funNodes e1 ++ funNodes e2 + EFun _ -> [t] + _ -> [] -- not literals, metas, etc + --- simple-minded transfer; should use PGF.Expr.match transfer :: PGF -> CId -> Expr -> Expr |
