summaryrefslogtreecommitdiff
path: root/src/PGF/VisualizeTree.hs
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2009-11-15 20:03:28 +0000
committeraarne <aarne@chalmers.se>2009-11-15 20:03:28 +0000
commitdcc2888fafb1ab1066f5faed3b5dd52bbb4a4124 (patch)
tree435c6e88d983acfe9493fb04d69681fad58098f0 /src/PGF/VisualizeTree.hs
parent4c17b7ba95dcbfe7dd485857222b3828621719cc (diff)
command vt -mk for displaying overload-style function names
Diffstat (limited to 'src/PGF/VisualizeTree.hs')
-rw-r--r--src/PGF/VisualizeTree.hs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/PGF/VisualizeTree.hs b/src/PGF/VisualizeTree.hs
index 857c1b08d..25bc2b3f1 100644
--- a/src/PGF/VisualizeTree.hs
+++ b/src/PGF/VisualizeTree.hs
@@ -19,7 +19,7 @@ module PGF.VisualizeTree ( graphvizAbstractTree
, graphvizParseTree
, graphvizDependencyTree
, graphvizAlignment
-
+ , tree2mk
, getDepLabels
, PosText(..), readPosText
) where
@@ -27,6 +27,7 @@ module PGF.VisualizeTree ( graphvizAbstractTree
import PGF.CId (CId,showCId,pCId,mkCId)
import PGF.Data
import PGF.Tree
+import PGF.Expr (showExpr)
import PGF.Linearize
import PGF.Macros (lookValCat)
@@ -63,6 +64,14 @@ prGraph digr ns = concat $ map (++"\n") $ [graph ++ "{\n"] ++ ns ++ ["}"] where
graph = if digr then "digraph" else "graph"
+-- replace each non-atomic constructor with mkC, where C is the val cat
+tree2mk :: PGF -> Expr -> String
+tree2mk pgf = showExpr [] . tree2expr . t2m . expr2tree where
+ t2m t = case t of
+ Fun cid [] -> t
+ Fun cid ts -> Fun (mk cid) (map t2m ts)
+ mk = mkCId . ("mk" ++) . showCId . lookValCat pgf
+
-- dependency trees from Linearize.linearizeMark
graphvizDependencyTree :: String -> Bool -> Maybe Labels -> Maybe String -> PGF -> CId -> Expr -> String