Drop obsolete and deprecated code
This commit is contained in:
parent
06a2e2c6e1
commit
38843c344e
|
|
@ -110,58 +110,6 @@ class RuleIndex(): Iterable<Rule>, RuleLookup
|
|||
}
|
||||
}
|
||||
|
||||
@Deprecated(message = "update functionality to be dropped")
|
||||
fun updateIndexFromRules(rules: Iterable<Rule>) {
|
||||
val removedTags = allRules.map { it.rule.uniqueTag() }.toHashSet()
|
||||
rules.map { it.uniqueTag() }.forEach{ removedTags.remove(it) }
|
||||
|
||||
val allRulesIt = allRules.listIterator()
|
||||
var nextIdx = 0
|
||||
rules.forEach { rule ->
|
||||
var skip = false
|
||||
while (allRulesIt.hasNext()) {
|
||||
val irule = allRulesIt.next()
|
||||
if (removedTags.contains(irule.rule.uniqueTag())) {
|
||||
removeRuleFromIndex(irule)
|
||||
allRulesIt.remove()
|
||||
|
||||
} else if (!irule.rule.uniqueTag().equals(rule.uniqueTag())) {
|
||||
allRulesIt.previous()
|
||||
break
|
||||
|
||||
} else {
|
||||
irule.idx = nextIdx
|
||||
skip = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!skip) {
|
||||
IndexedRule(nextIdx, rule).also {
|
||||
addRuleToIndex(it)
|
||||
allRulesIt.add(it)
|
||||
}
|
||||
}
|
||||
nextIdx++
|
||||
}
|
||||
while (allRulesIt.hasNext()) {
|
||||
val irule = allRulesIt.next()
|
||||
removeRuleFromIndex(irule)
|
||||
allRulesIt.remove()
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeRuleFromIndex(irule: IndexedRule) {
|
||||
val uniqueTag = irule.rule.uniqueTag()
|
||||
tag2rule.remove(uniqueTag)
|
||||
val ruleBit = tag2bit.remove(uniqueTag)
|
||||
bit2ruleAndMask.remove(ruleBit)
|
||||
val head = irule.rule.headKept() + irule.rule.headReplaced()
|
||||
for ((headPos, cst) in head.withIndex()) {
|
||||
symbol2index[cst.symbol()]?.clear(cst, ruleBit, headPos)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun addRuleToIndex(irule: IndexedRule) {
|
||||
val uniqueTag = irule.rule.uniqueTag()
|
||||
if (tag2rule.containsKey(uniqueTag)) throw IllegalStateException("duplicate rule tag $uniqueTag")
|
||||
|
|
|
|||
|
|
@ -136,7 +136,6 @@ interface MatchJournal : EvidenceSource {
|
|||
* [RuleMatch] which defines this [Chunk]
|
||||
*/
|
||||
val match: RuleMatch
|
||||
val ruleUniqueTag: Any get() = match.rule().uniqueTag()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -59,14 +59,6 @@ class TestRuleIndex {
|
|||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
iterator().hasNext() shouldBe false
|
||||
}
|
||||
|
||||
ruleIndex.updateIndexFromRules(second.rules)
|
||||
with (ruleIndex.forOccurrence(occurrence("foo"))) {
|
||||
iterator().hasNext() shouldBe false
|
||||
}
|
||||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -91,14 +83,6 @@ class TestRuleIndex {
|
|||
with (ruleIndex.forOccurrence(occurrence("foo"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule0")
|
||||
}
|
||||
|
||||
ruleIndex.updateIndexFromRules(second.rules)
|
||||
with (ruleIndex.forOccurrence(occurrence("foo"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule0")
|
||||
}
|
||||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -127,11 +111,6 @@ class TestRuleIndex {
|
|||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule2")
|
||||
}
|
||||
|
||||
ruleIndex.updateIndexFromRules(second.rules)
|
||||
with (ruleIndex.forOccurrence(occurrence("foo"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -158,14 +137,6 @@ class TestRuleIndex {
|
|||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule1","rule2")
|
||||
}
|
||||
|
||||
ruleIndex.updateIndexFromRules(second.rules)
|
||||
with (ruleIndex.forOccurrence(occurrence("foo"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule0")
|
||||
}
|
||||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
iterator().hasNext() shouldBe false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -208,20 +179,6 @@ class TestRuleIndex {
|
|||
with (ruleIndex.forOccurrence(occurrence("qux"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule4")
|
||||
}
|
||||
|
||||
ruleIndex.updateIndexFromRules(second.rules)
|
||||
with (ruleIndex.forOccurrence(occurrence("foo"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule5", "rule0")
|
||||
}
|
||||
with (ruleIndex.forOccurrence(occurrence("bar"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule2")
|
||||
}
|
||||
with (ruleIndex.forOccurrence(occurrence("baz"))) {
|
||||
iterator().hasNext() shouldBe false
|
||||
}
|
||||
with (ruleIndex.forOccurrence(occurrence("qux"))) {
|
||||
map { it.uniqueTag().toString() }.toList() shouldBe listOf("rule4", "rule6")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue