File tree Expand file tree Collapse file tree 1 file changed +4
-0
lines changed
src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing Expand file tree Collapse file tree 1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ private class FrozenCFG(val cfg: CFG): CFG by cfg {
3434 override fun equals (other : Any? ) =
3535 ((other as ? FrozenCFG )?.cfgId == cfgId) || (other as ? CFG ) == cfg
3636 override fun hashCode (): Int = cfgId
37+ val stats = calcStats()
3738}
3839
3940val CFG .language: CFL by cache { CFL (this ) }
@@ -154,6 +155,9 @@ val CFG.nonparametricForm: CFG by cache { rewriteHistory[this]!![1] }
154155 */
155156val CFG .reachability by cache { mutableMapOf< Σᐩ, Set < Σᐩ>> () }
156157
158+ fun CFG.calcStats () = " CFG(|Σ|=${terminals.size} , |V|=${nonterminals.size} , |P|=${nonterminalProductions.size} )"
159+ fun CFG.stats () = if (this is FrozenCFG ) stats else calcStats()
160+
157161// Equivalence class of an NT B are all NTs, A ->* B ->* C
158162// reachable via unit productions (in forward or reverse)
159163// val CFG.unitReachability: Map<Σᐩ, Set<Σᐩ>> by cache {
You can’t perform that action at this time.
0 commit comments