summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Infra
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-04-06 08:53:44 +0000
committeraarne <aarne@chalmers.se>2010-04-06 08:53:44 +0000
commitba13052d3117c3931a5477a0bbf2d3c38ed749c6 (patch)
treec6049008c3f7e9440a24129db318b517546868c8 /src/compiler/GF/Infra
parent2ced613d81b1fb93e3e60c974eee73a8872d7093 (diff)
dependency graph can be restricted to some modules; added help dg
Diffstat (limited to 'src/compiler/GF/Infra')
-rw-r--r--src/compiler/GF/Infra/Dependencies.hs41
1 files changed, 27 insertions, 14 deletions
diff --git a/src/compiler/GF/Infra/Dependencies.hs b/src/compiler/GF/Infra/Dependencies.hs
index 9a870b139..82606a865 100644
--- a/src/compiler/GF/Infra/Dependencies.hs
+++ b/src/compiler/GF/Infra/Dependencies.hs
@@ -6,8 +6,11 @@ import GF.Grammar.Grammar
import GF.Infra.Modules
import GF.Infra.Ident
-depGraph :: SourceGrammar -> String
-depGraph = prDepGraph . grammar2moddeps
+import Data.List (nub,isPrefixOf)
+
+-- the list gives the only modules to show, e.g. to hide the library details
+depGraph :: Maybe [String] -> SourceGrammar -> String
+depGraph only = prDepGraph . grammar2moddeps only
prDepGraph :: [(Ident,ModDeps)] -> String
prDepGraph deps = unlines $ [
@@ -47,15 +50,25 @@ data ModDeps = ModDeps {
noModDeps = ModDeps MTAbstract [] [] [] [] [] [] []
-grammar2moddeps :: SourceGrammar -> [(Ident,ModDeps)]
-grammar2moddeps gr = [(i,depMod m) | (i,m) <- modules gr] where
- depMod m = noModDeps{
- modtype = mtype m,
- ofs = case mtype m of
- MTConcrete i -> [i]
- MTInstance i -> [i]
- _ -> [],
- extendeds = map fst (extend m),
- openeds = map openedModule (opens m),
- extrads = mexdeps m
- }
+grammar2moddeps :: Maybe [String] -> SourceGrammar -> [(Ident,ModDeps)]
+grammar2moddeps monly gr = [(i,depMod i m) | (i,m) <- modules gr, yes i]
+ where
+ depMod i m =
+ noModDeps{
+ modtype = mtype m,
+ ofs = case mtype m of
+ MTConcrete i -> [i | yes i]
+ MTInstance i -> [i | yes i]
+ _ -> [],
+ extendeds = nub $ filter yes $ map fst (extend m),
+ openeds = nub $ filter yes $ map openedModule (opens m),
+ extrads = nub $ filter yes $ mexdeps m
+ }
+ yes i = case monly of
+ Just only -> match (showIdent i) only
+ _ -> True
+ match s os = any (\x -> doMatch x s) os
+ doMatch x s = case last x of
+ '*' -> isPrefixOf (init x) s
+ _ -> x == s
+