mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-11 05:49:31 -06:00
bugfix: the optimizer should not filter out rules that refer to lexical categories
This commit is contained in:
@@ -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])
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user