diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-01-05 12:59:36 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-01-05 12:59:36 +0000 |
| commit | 5c0d9d52b3d502faf87377303bf06c6028e8612e (patch) | |
| tree | c531abee2e52b5804bc1d706e1415b94e6331733 /src/GF/Speech/PrSLF.hs | |
| parent | a4ba93cc556dadc33ed95abd9baac0d29236bcfe (diff) | |
Print slf_graphviz with subgraphs.
Diffstat (limited to 'src/GF/Speech/PrSLF.hs')
| -rw-r--r-- | src/GF/Speech/PrSLF.hs | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/GF/Speech/PrSLF.hs b/src/GF/Speech/PrSLF.hs index ce0795420..a47057c80 100644 --- a/src/GF/Speech/PrSLF.hs +++ b/src/GF/Speech/PrSLF.hs @@ -62,13 +62,25 @@ slfGraphvizPrinter :: Ident -- ^ Grammar name -> Options -> CGrammar -> String slfGraphvizPrinter name opts cfg = Dot.prGraphviz g where MFA main subs = cfgToMFA opts cfg - g = Dot.addSubGraphs (map (uncurry gvSLFFA) subs) $ gvSLFFA "" main - -gvSLFFA :: String -> DFA (MFALabel String) -> Dot.Graph -gvSLFFA n = faToGraphviz n . mapStates (maybe "" mfaLabelToGv) - . mapTransitions (const "") . slfStyleFA + g = STM.evalState (liftM2 Dot.addSubGraphs ss m) [0..] + ss = mapM (\ (c,f) -> gvSLFFA (Just c) f) subs + m = gvSLFFA Nothing main + +gvSLFFA :: Maybe String -> DFA (MFALabel String) -> STM.State [State] Dot.Graph +gvSLFFA n fa = + liftM (mkCluster n . faToGraphviz . mapStates (maybe "" mfaLabelToGv) + . mapTransitions (const "")) (rename $ slfStyleFA fa) where mfaLabelToGv (MFASym s) = s - mfaLabelToGv (MFASub s) = "<" ++ s ++ ">" + mfaLabelToGv (MFASub s) = "#" ++ s + mkCluster Nothing = id + mkCluster (Just x) + = Dot.setName ("cluster_"++x) . Dot.setAttr "label" x + rename fa = do + names <- STM.get + let fa' = renameStates names fa + names' = unusedNames fa' + STM.put names' + return fa' mapMFA :: (DFA (MFALabel a) -> b) -> MFA a -> (b,[(String,b)]) mapMFA f (MFA main subs) = (f main, [(c, f fa) | (c,fa) <- subs]) |
