summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-06-18 17:31:49 +0000
committerkrasimir <krasimir@chalmers.se>2009-06-18 17:31:49 +0000
commit5f0a68c1a4206bbd3cf07ae2b93844dedcc79c74 (patch)
treec8490908e56cc4f1855cb7dd6419eed95b5e7354
parentea9aed6ff8303a576c95683d8e647b13be836e88 (diff)
bugfix: the optimizer should not filter out rules that refer to lexical categories
-rw-r--r--src/GF/Speech/PGFToCFG.hs4
-rw-r--r--src/PGF/PMCFG.hs4
2 files changed, 3 insertions, 5 deletions
diff --git a/src/GF/Speech/PGFToCFG.hs b/src/GF/Speech/PGFToCFG.hs
index 772ae90c1..4165e0aa1 100644
--- a/src/GF/Speech/PGFToCFG.hs
+++ b/src/GF/Speech/PGFToCFG.hs
@@ -114,7 +114,3 @@ pgfToCFG pgf lang = mkCFG (prCId (lookStartCat pgf)) extCats (startRules ++ conc
fruleToCFRule (c,FCoerce c') =
[CFRule (fcatToCat c l) [NonTerminal (fcatToCat c' l)] (CFRes 0)
| l <- [0..catLinArity c-1]]
-
-
-isLiteralFCat :: FCat -> Bool
-isLiteralFCat = (`elem` [fcatString, fcatInt, fcatFloat, fcatVar])
diff --git a/src/PGF/PMCFG.hs b/src/PGF/PMCFG.hs
index 6a83baad3..c077367ad 100644
--- a/src/PGF/PMCFG.hs
+++ b/src/PGF/PMCFG.hs
@@ -50,6 +50,8 @@ fcatInt = (-2)
fcatFloat = (-3)
fcatVar = (-4)
+isLiteralFCat :: FCat -> Bool
+isLiteralFCat = (`elem` [fcatString, fcatInt, fcatFloat, fcatVar])
ppPMCFG :: ParserInfo -> Doc
ppPMCFG pinfo =
@@ -101,6 +103,6 @@ ppSeqId seqid = char 'S' <> int seqid
filterProductions prods =
fmap (Set.filter filterRule) prods
where
- filterRule (FApply funid args) = all (\fcat -> IntMap.member fcat prods) args
+ filterRule (FApply funid args) = all (\fcat -> isLiteralFCat fcat || IntMap.member fcat prods) args
filterRule (FCoerce _) = True
filterRule _ = True