summaryrefslogtreecommitdiff
path: root/src/compiler/GF/Grammar/CFG.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2016-03-22 13:13:35 +0000
committerkrasimir <krasimir@chalmers.se>2016-03-22 13:13:35 +0000
commita393c1a246bb946e53f26b7b91a173c2ba1a0fa7 (patch)
tree54dbc9eff02cda48568821d53061a01d3f4944dd /src/compiler/GF/Grammar/CFG.hs
parentce7072085947f4981c8d6d49b571e3cf5683fbb6 (diff)
fix the handling of separators in BNFC which are not nonempty
Diffstat (limited to 'src/compiler/GF/Grammar/CFG.hs')
-rw-r--r--src/compiler/GF/Grammar/CFG.hs10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/compiler/GF/Grammar/CFG.hs b/src/compiler/GF/Grammar/CFG.hs
index 0a8d48b4f..aac13bcba 100644
--- a/src/compiler/GF/Grammar/CFG.hs
+++ b/src/compiler/GF/Grammar/CFG.hs
@@ -226,15 +226,9 @@ mkCFG start ext rs = Grammar { cfgStartCat = start, cfgExternalCats = ext, cfgRu
groupProds :: (Ord c,Ord t) => [Rule c t] -> Map c (Set (Rule c t))
groupProds = Map.fromListWith Set.union . map (\r -> (ruleLhs r,Set.singleton r))
-uniqueFuns :: (Ord c,Ord t) => Grammar c t -> Grammar c t
-uniqueFuns cfg = Grammar {cfgStartCat = cfgStartCat cfg
- ,cfgExternalCats = cfgExternalCats cfg
- ,cfgRules = Map.fromList (snd (mapAccumL uniqueFunSet Set.empty (Map.toList (cfgRules cfg))))
- }
+uniqueFuns :: [Rule c t] -> [Rule c t]
+uniqueFuns = snd . mapAccumL uniqueFun Set.empty
where
- uniqueFunSet funs (cat,rules) =
- let (funs',rules') = mapAccumL uniqueFun funs (Set.toList rules)
- in (funs',(cat,Set.fromList rules'))
uniqueFun funs (Rule cat items (CFObj fun args)) = (Set.insert fun' funs,Rule cat items (CFObj fun' args))
where
fun' = head [fun'|suffix<-"":map show ([2..]::[Int]),