summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Speech/CFG.hs
diff options
context:
space:
mode:
authorbjorn <bjorn@bringert.net>2008-06-16 16:44:33 +0000
committerbjorn <bjorn@bringert.net>2008-06-16 16:44:33 +0000
commita47fcbcbf23ead0cf3d7144ee23906bd5f6cb440 (patch)
treeb8763526410773fe1eb2220c21c18d0c1957442c /src-3.0/GF/Speech/CFG.hs
parent5c7c010f80533fd0909893c878b500ffb00f46bb (diff)
Handled renaming external SRG categories centrally.
Diffstat (limited to 'src-3.0/GF/Speech/CFG.hs')
-rw-r--r--src-3.0/GF/Speech/CFG.hs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src-3.0/GF/Speech/CFG.hs b/src-3.0/GF/Speech/CFG.hs
index a99a9d011..dfcecf913 100644
--- a/src-3.0/GF/Speech/CFG.hs
+++ b/src-3.0/GF/Speech/CFG.hs
@@ -242,6 +242,11 @@ catRules gr c = Set.toList $ Map.findWithDefault Set.empty c (cfgRules gr)
catSetRules :: CFG -> Set Cat -> [CFRule]
catSetRules gr cs = allRules $ filterCFGCats (`Set.member` cs) gr
+mapCFGCats :: (Cat -> Cat) -> CFG -> CFG
+mapCFGCats f cfg = mkCFG (f (cfgStartCat cfg))
+ (Set.map f (cfgExternalCats cfg))
+ [CFRule (f lhs) (map (mapSymbol f id) rhs) t | CFRule lhs rhs t <- allRules cfg]
+
onCFG :: (Map Cat (Set CFRule) -> Map Cat (Set CFRule)) -> CFG -> CFG
onCFG f cfg = cfg { cfgRules = f (cfgRules cfg) }