diff options
| author | bringert <bringert@cs.chalmers.se> | 2006-12-17 19:18:28 +0000 |
|---|---|---|
| committer | bringert <bringert@cs.chalmers.se> | 2006-12-17 19:18:28 +0000 |
| commit | c7df9f4167f7b554a93a216245a013e16cca420d (patch) | |
| tree | 77be7e4fadb2c86f2583c58cf5e8d255a68829b8 /src/GF/Speech/CFGToFiniteState.hs | |
| parent | 4e592d495e402bb8e73f860197315654c3958ae4 (diff) | |
Added still unused implementation of Moore's LCLR algorithm for left recursion elimination. Fixed top category generation for SRG (included LR-elimination-added categories before).
Diffstat (limited to 'src/GF/Speech/CFGToFiniteState.hs')
| -rw-r--r-- | src/GF/Speech/CFGToFiniteState.hs | 13 |
1 files changed, 2 insertions, 11 deletions
diff --git a/src/GF/Speech/CFGToFiniteState.hs b/src/GF/Speech/CFGToFiniteState.hs index 7876f637d..cb32ff73e 100644 --- a/src/GF/Speech/CFGToFiniteState.hs +++ b/src/GF/Speech/CFGToFiniteState.hs @@ -75,7 +75,7 @@ makeRegular g = groupProds $ concatMap trSet (mutRecCats True g) where trSet cs | allXLinear cs rs = rs | otherwise = concatMap handleCat csl where csl = Set.toList cs - rs = catSetRules g csl + rs = catSetRules g cs handleCat c = [CFRule c' [] (mkName (c++"-empty"))] -- introduce A' -> e ++ concatMap (makeRightLinearRules c) (catRules g c) where c' = newCat c @@ -90,15 +90,6 @@ makeRegular g = groupProds $ concatMap trSet (mutRecCats True g) | otherwise = [CFRule c rhs n] newCat c = c ++ "$" --- | Get the sets of mutually recursive non-terminals for a grammar. -mutRecCats :: Bool -- ^ If true, all categories will be in some set. - -- If false, only recursive categories will be included. - -> CFRules -> [Set Cat_] -mutRecCats incAll g = equivalenceClasses $ refl $ symmetricSubrelation $ transitiveClosure r - where r = mkRel [(c,c') | (_,rs) <- g, CFRule c ss _ <- rs, Cat c' <- ss] - allCats = map fst g - refl = if incAll then reflexiveClosure_ allCats else reflexiveSubrelation - -- -- * Compile strongly regular grammars to NFAs -- @@ -271,7 +262,7 @@ mutRecSets g = Map.fromList . concatMap mkMutRecSet where mkMutRecSet cs = [ (c,ms) | c <- csl ] where csl = Set.toList cs - rs = catSetRules g csl + rs = catSetRules g cs (nrs,rrs) = partition (ruleIsNonRecursive cs) rs ms = MutRecSet { mrCats = cs, |
