Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve regex lattice #5

Draft
wants to merge 19 commits into
base: add-regex-compressor
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 0 additions & 90 deletions ParSy/src/main/kotlin/zhe/ParSy/Grammar/AntlrPrinter.kt

This file was deleted.

6 changes: 5 additions & 1 deletion ParSy/src/main/kotlin/zhe/ParSy/Grammar/HeapCNFGrammar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ public class HeapCNFGrammar : IGrammar {
}

override fun toString(): String {
return AntlrPrinter(this).string()
return "TODO"
}

override fun equals(other: Any?): Boolean {
return this.toString() == other.toString()
}

companion object {
Expand Down
7 changes: 4 additions & 3 deletions ParSy/src/main/kotlin/zhe/ParSy/Parser/ZheParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class ZheParser(
val sensitiveTokenIndexes = sensitiveTokenIndexesList?.toSet()
?: setOf<Int>()
val tokens = cleanLine.split(tokenDelimeter)
val newGrammar = solver.solve(tokens, sensitiveTokenIndexes)
grammar = merger.merge(grammar, newGrammar)
val grammarWasUpdated = true
val lineGrammar = solver.solve(tokens, sensitiveTokenIndexes)
val newGrammar = merger.merge(grammar, lineGrammar)
val grammarWasUpdated = newGrammar != grammar
if (grammarWasUpdated) {
grammar = newGrammar
File(grammarFilePath).writeText(grammar.toString())
}
return grammarWasUpdated
Expand Down
Loading