Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
breandan committed Oct 15, 2023
1 parent 453b249 commit 6a8d320
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ fun CFG.reachSym(from: Σᐩ = START_SYMBOL): Set<Σᐩ> {
fun CFG.reachableSymbols(from: Σᐩ = START_SYMBOL): Set<Σᐩ> =
reachability.getOrPut(from) { depGraph.transitiveClosure(setOf(from)) }

fun CFG.genSym(from: Set<Σᐩ> = terminals): Set<Σᐩ> {
fun CFG.genSym(from: Set<Σᐩ> = terminalUnitProductions.map { it.LHS }.toSet()): Set<Σᐩ> {
val allGenerating: MutableSet<Σᐩ> = mutableSetOf()
val nextGenerating = from.toMutableSet()

Expand All @@ -221,7 +221,7 @@ fun CFG.genSym(from: Set<Σᐩ> = terminals): Set<Σᐩ> {

// All symbols that are either terminals or generate terminals
fun CFG.generatingSymbols(
from: Set<Σᐩ> = terminals,
from: Set<Σᐩ> = terminalUnitProductions.map { it.LHS }.toSet(),
revGraph: LabeledGraph = revDepGraph
): Set<Σᐩ> = revGraph.transitiveClosure(from)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,12 @@ class BarHillelTest {
@Test
fun testPythonBarHillel() {
val gram = SetValiantTest.seq2parsePythonCFG.noEpsilonOrNonterminalStubs
gram.intersectLevFSA(makeLevFSA("NUMBER + NEWLINE", 2, gram.terminals))
val intGram = gram.intersectLevFSA(makeLevFSA("NUMBER + NEWLINE", 2, gram.terminals))
.also { println("LEV ∩ CFG grammar:\n${it.pretty}") }
.enumSeq(List(5) { "_" }.joinToString(" "))
val clock = TimeSource.Monotonic.markNow()

intGram.enumSeq(List(5) { "_" }.joinToString(" "))
.onEach { println(it) }.toList()
println("Enumerative solver took ${clock.elapsedNow().inWholeMilliseconds}ms")
}
}

0 comments on commit 6a8d320

Please sign in to comment.