forked from GitHub/gf-core
bottom-up and top-down filtering do not need fix point iteration.
This commit is contained in:
@@ -64,7 +64,7 @@ cfgToFA opts s = minimize $ compileAutomaton start $ makeSimpleRegular opts s
|
|||||||
makeSimpleRegular :: Options -> StateGrammar -> CFRules
|
makeSimpleRegular :: Options -> StateGrammar -> CFRules
|
||||||
makeSimpleRegular opts s = makeRegular $ preprocess $ cfgToCFRules s
|
makeSimpleRegular opts s = makeRegular $ preprocess $ cfgToCFRules s
|
||||||
where start = getStartCatCF opts s
|
where start = getStartCatCF opts s
|
||||||
preprocess = fix (topDownFilter start . bottomUpFilter)
|
preprocess = topDownFilter start . bottomUpFilter
|
||||||
. removeCycles
|
. removeCycles
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -93,10 +93,10 @@ makeSimpleSRG opt s = makeSRG preprocess opt s
|
|||||||
. mergeIdentical
|
. mergeIdentical
|
||||||
. traceStats "After removeLeftRecursion"
|
. traceStats "After removeLeftRecursion"
|
||||||
. removeLeftRecursion origStart
|
. removeLeftRecursion origStart
|
||||||
. fix (traceStats "After topDownFilter"
|
. traceStats "After topDownFilter"
|
||||||
. topDownFilter origStart
|
. topDownFilter origStart
|
||||||
. traceStats "After bottomUpFilter"
|
. traceStats "After bottomUpFilter"
|
||||||
. bottomUpFilter)
|
. bottomUpFilter
|
||||||
. traceStats "After removeCycles"
|
. traceStats "After removeCycles"
|
||||||
. removeCycles
|
. removeCycles
|
||||||
. traceStats "Inital CFG"
|
. traceStats "Inital CFG"
|
||||||
|
|||||||
@@ -109,7 +109,6 @@ bottomUpFilter gr = fix grow Map.empty
|
|||||||
okSym g = symbol (`elem` allCats g) (const True)
|
okSym g = symbol (`elem` allCats g) (const True)
|
||||||
|
|
||||||
-- | Removes categories which are not reachable from the start category.
|
-- | Removes categories which are not reachable from the start category.
|
||||||
-- Only does one pass through the grammar.
|
|
||||||
topDownFilter :: Cat_ -> CFRules -> CFRules
|
topDownFilter :: Cat_ -> CFRules -> CFRules
|
||||||
topDownFilter start rules = filterCFRulesCats (isRelatedTo uses start) rules
|
topDownFilter start rules = filterCFRulesCats (isRelatedTo uses start) rules
|
||||||
where
|
where
|
||||||
|
|||||||
Reference in New Issue
Block a user