summaryrefslogtreecommitdiff
path: root/src-3.0/PGF/VisualizeTree.hs
diff options
context:
space:
mode:
authoraarne <aarne@cs.chalmers.se>2008-06-22 14:15:06 +0000
committeraarne <aarne@cs.chalmers.se>2008-06-22 14:15:06 +0000
commit0a43025bbec5c6141d866dec1e9387ef30e12788 (patch)
tree55a2bcd8f21714cd5ae95df20e83bb16532cb0d5 /src-3.0/PGF/VisualizeTree.hs
parent0f0e65f706eb67e8035e9737cc4647fffe15f5f8 (diff)
added -nofun and -nocat options to vt
Diffstat (limited to 'src-3.0/PGF/VisualizeTree.hs')
-rw-r--r--src-3.0/PGF/VisualizeTree.hs18
1 files changed, 12 insertions, 6 deletions
diff --git a/src-3.0/PGF/VisualizeTree.hs b/src-3.0/PGF/VisualizeTree.hs
index 1bf4dc075..0219dcbde 100644
--- a/src-3.0/PGF/VisualizeTree.hs
+++ b/src-3.0/PGF/VisualizeTree.hs
@@ -20,12 +20,13 @@ module PGF.VisualizeTree ( visualizeTrees
import PGF.CId (prCId)
import PGF.Data
+import PGF.Macros (lookValCat)
-visualizeTrees :: Bool -> [Tree] -> String
-visualizeTrees digr = unlines . map (prGraph digr . tree2graph digr)
+visualizeTrees :: PGF -> (Bool,Bool) -> [Tree] -> String
+visualizeTrees pgf funscats = unlines . map (prGraph False . tree2graph pgf funscats)
-tree2graph :: Bool -> Tree -> [String]
-tree2graph digr = prf [] where
+tree2graph :: PGF -> (Bool,Bool) -> Tree -> [String]
+tree2graph pgf (funs,cats) = prf [] where
prf ps t = case t of
Fun cid trees ->
let (nod,lab) = prn ps cid in
@@ -33,10 +34,15 @@ tree2graph digr = prf [] where
[ pra (j:ps) nod t | (j,t) <- zip [0..] trees] ++
concat [prf (j:ps) t | (j,t) <- zip [0..] trees]
prn ps cid =
- let lab = "\"" ++ prCId cid ++ "\""
+ let
+ fun = if funs then prCId cid else ""
+ cat = if cats then prCat cid else ""
+ colon = if funs && cats then " : " else ""
+ lab = "\"" ++ fun ++ colon ++ cat ++ "\""
in (show(show (ps :: [Int])),lab)
pra i nod t@(Fun cid _) = nod ++ arr ++ fst (prn i cid) ++ " [style = \"solid\"];"
- arr = if digr then " -> " else " -- "
+ arr = " -- " -- if digr then " -> " else " -- "
+ prCat = prCId . lookValCat pgf
prGraph digr ns = concat $ map (++"\n") $ [graph ++ "{\n"] ++ ns ++ ["}"] where
graph = if digr then "digraph" else "graph"