summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-09-23 06:32:24 +0000
committerkrasimir <krasimir@chalmers.se>2009-09-23 06:32:24 +0000
commit0b1590536ae6fa1e03aee6fe0f9d46b42f71f00d (patch)
tree67278afdeb4f480c5e1a0926ed27fd17476d5756 /src
parentea10ce93c4cda765c474732cbdf7ed23e55b2755 (diff)
bugfix in the filterProds function
Diffstat (limited to 'src')
-rw-r--r--src/PGF/PMCFG.hs21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/PGF/PMCFG.hs b/src/PGF/PMCFG.hs
index f7c2eea29..c657e3d17 100644
--- a/src/PGF/PMCFG.hs
+++ b/src/PGF/PMCFG.hs
@@ -100,9 +100,20 @@ ppFunId funid = char 'F' <> int funid
ppSeqId seqid = char 'S' <> int seqid
-filterProductions prods =
- fmap (Set.filter filterRule) prods
+filterProductions = closure
where
- filterRule (FApply funid args) = all (\fcat -> isLiteralFCat fcat || IntMap.member fcat prods) args
- filterRule (FCoerce _) = True
- filterRule _ = True
+ closure prods0
+ | IntMap.size prods == IntMap.size prods0 = prods
+ | otherwise = closure prods
+ where
+ prods = IntMap.mapMaybe (filterProdSet prods0) prods0
+
+ filterProdSet prods set0
+ | Set.null set = Nothing
+ | otherwise = Just set
+ where
+ set = Set.filter (filterRule prods) set0
+
+ filterRule prods (FApply funid args) = all (\fcat -> isLiteralFCat fcat || IntMap.member fcat prods) args
+ filterRule prods (FCoerce fcat) = isLiteralFCat fcat || IntMap.member fcat prods
+ filterRule prods _ = True