1
0
forked from GitHub/gf-core

Modified the LC_LR implementation to only produce rules using A-X categories when those categories have any productions.

This commit is contained in:
bringert
2007-03-24 17:30:04 +00:00
parent 0058f6281f
commit 99af757b06

View File

@@ -125,6 +125,7 @@ removeLeftRecursion start gr
x <- properLeftCornersOf a,
not (isLeftRecursive x),
let a_x = mkCat (Cat a) x,
a_x `Set.member` newCats,
let n' = symbol (\_ -> CFApp (CFRes 1) (CFRes 0))
(\_ -> CFRes 0) x]
scheme2 = [CFRule a_x (beta++[Cat a_b]) n' |
@@ -147,6 +148,8 @@ removeLeftRecursion start gr
(\_ -> n) x]
scheme4 = catSetRules gr $ Set.fromList $ filter (not . isLeftRecursive . Cat) cats
newCats = Set.fromList (map lhsCat (scheme2 ++ scheme3))
shiftTerm :: CFTerm -> CFTerm
shiftTerm (CFObj f ts) = CFObj f (map shiftTerm ts)
shiftTerm (CFRes 0) = CFVar 1