mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 19:42:50 -06:00
Print SRG stats when preprocessing grammar.
This commit is contained in:
@@ -50,6 +50,8 @@ import qualified Data.Map as Map
|
|||||||
import Data.Set (Set)
|
import Data.Set (Set)
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
|
import Debug.Trace
|
||||||
|
|
||||||
data SRG = SRG { grammarName :: String -- ^ grammar name
|
data SRG = SRG { grammarName :: String -- ^ grammar name
|
||||||
, startCat :: SRGCat -- ^ start category name
|
, startCat :: SRGCat -- ^ start category name
|
||||||
, origStartCat :: String -- ^ original start category name
|
, origStartCat :: String -- ^ original start category name
|
||||||
@@ -87,10 +89,22 @@ makeSimpleSRG :: Options -- ^ Grammar options
|
|||||||
-> SRG
|
-> SRG
|
||||||
makeSimpleSRG opt s = makeSRG preprocess opt s
|
makeSimpleSRG opt s = makeSRG preprocess opt s
|
||||||
where
|
where
|
||||||
preprocess origStart = mergeIdentical
|
preprocess origStart = traceStats "After mergeIdentical"
|
||||||
|
. mergeIdentical
|
||||||
|
. traceStats "After removeLeftRecursion"
|
||||||
. removeLeftRecursion origStart
|
. removeLeftRecursion origStart
|
||||||
. fix (topDownFilter origStart . bottomUpFilter)
|
. fix (traceStats "After topDownFilter"
|
||||||
. removeCycles
|
. topDownFilter origStart
|
||||||
|
. traceStats "After bottomUpFilter"
|
||||||
|
. bottomUpFilter)
|
||||||
|
. traceStats "After removeCycles"
|
||||||
|
. removeCycles
|
||||||
|
. traceStats "Inital CFG"
|
||||||
|
|
||||||
|
traceStats s g = trace (s ++ ": " ++ stats g) g
|
||||||
|
|
||||||
|
stats g = "Categories: " ++ show (length (filter (not . null . snd) g))
|
||||||
|
++ " Rules: " ++ show (length (concatMap snd g))
|
||||||
|
|
||||||
makeNonRecursiveSRG :: Options
|
makeNonRecursiveSRG :: Options
|
||||||
-> StateGrammar
|
-> StateGrammar
|
||||||
|
|||||||
Reference in New Issue
Block a user