From 9cf71d3bba75f157e72bc08f984a2262885ed506 Mon Sep 17 00:00:00 2001 From: aarne Date: Mon, 20 Jun 2005 15:14:19 +0000 Subject: parse tree visualization --- src/GF/Shell.hs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/GF/Shell.hs') diff --git a/src/GF/Shell.hs b/src/GF/Shell.hs index 29e00e72f..ac5a5d660 100644 --- a/src/GF/Shell.hs +++ b/src/GF/Shell.hs @@ -5,9 +5,9 @@ -- Stability : (stable) -- Portability : (portable) -- --- > CVS $Date: 2005/06/14 20:09:57 $ +-- > CVS $Date: 2005/06/20 16:14:19 $ -- > CVS $Author: aarne $ --- > CVS $Revision: 1.40 $ +-- > CVS $Revision: 1.41 $ -- -- GF shell command interpreter. ----------------------------------------------------------------------------- @@ -31,6 +31,7 @@ import GF.UseGrammar.GetTree import GF.Shell.ShellCommands import GF.Visualization.VisualizeGrammar (visualizeCanonGrammar, visualizeSourceGrammar) +import GF.Visualization.VisualizeTree (visualizeTrees) import GF.API import GF.API.IOGrammar import GF.Compile.Compile @@ -57,7 +58,6 @@ import GF.Data.Operations import GF.Infra.UseIO import GF.Text.UTF8 (encodeUTF8) -import GF.Visualization.VisualizeGrammar (visualizeSourceGrammar) ---- import qualified GrammarToGramlet as Gr ---- import qualified GrammarToCanonXML2 as Canon @@ -208,6 +208,12 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of _ -> Nothing returnArg (ATrms $ generateTrees opts gro mt) sa + CShowTreeGraph -> do + let g0 = writeFile "grphtmp.dot" $ visualizeTrees opts $ strees $ s2t a + g1 = system "dot -Tps grphtmp.dot >grphtmp.ps" + g2 = system "gv grphtmp.ps &" + g3 = return () ---- system "rm -f grphtmp.*" + justOutput opts (g0 >> g1 >> g2 >> g3 >> return ()) sa CPutTerm -> changeArg (opTT2CommandArg (optTermCommand opts gro) . s2t) sa @@ -306,6 +312,10 @@ execC co@(comm, opts0) sa@((st,(h,_)),a) = checkOptions st co >> case comm of AString s -> err AError (ATrms . return) $ string2treeErr gro s _ -> a + strees a = case a of + ATrms ts -> ts + _ -> [] + warnDiscont os = err putStrLn id $ do let c0 = firstAbsCat os gro c <- GrammarToCanon.redQIdent c0 -- cgit v1.2.3