forked from GitHub/gf-core
CFRules tracing.
This commit is contained in:
@@ -101,7 +101,7 @@ makeSimpleSRG opt s = makeSRG preprocess opt s
|
||||
. removeCycles
|
||||
. traceStats "Inital CFG"
|
||||
|
||||
traceStats s g = trace (s ++ ": " ++ stats g) g
|
||||
traceStats s g = trace ("---- " ++ s ++ ": " ++ stats g {- ++ "\n" ++ prCFRules g ++ "----" -}) g
|
||||
|
||||
stats g = "Categories: " ++ show (countCats g)
|
||||
++ " Rules: " ++ show (countRules g)
|
||||
|
||||
@@ -369,3 +369,9 @@ isLeftLinear :: Ord c =>
|
||||
-> CFRule c n t -- ^ The rule to check for left-linearity
|
||||
-> Bool
|
||||
isLeftLinear cs = noCatsInSet cs . drop 1 . ruleRhs
|
||||
|
||||
prCFRules :: CFRules -> String
|
||||
prCFRules = unlines . map prRule . allRules
|
||||
where
|
||||
prRule r = lhsCat r ++ " --> " ++ unwords (map prSym (ruleRhs r))
|
||||
prSym = symbol id (\t -> "\""++ t ++"\"")
|
||||
|
||||
Reference in New Issue
Block a user