Skip to content

Commit 5024e77

Browse files
committed
make deletion markers cosmetic
1 parent 6c0c50d commit 5024e77

File tree

1 file changed

+4
-0
lines changed
  • src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing

1 file changed

+4
-0
lines changed

src/commonMain/kotlin/ai/hypergraph/kaliningraph/parsing/CFG.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff 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

3940
val CFG.language: CFL by cache { CFL(this) }
@@ -154,6 +155,9 @@ val CFG.nonparametricForm: CFG by cache { rewriteHistory[this]!![1] }
154155
*/
155156
val 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 {

0 commit comments

Comments
 (0)