forked from vadyushkins/kotgll
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
When processing large grammars, getAlphabet() throws a StackOverflowError due to deep recursion. Even increasing the JVM stack size to 12 MB (-Xss12m) does not resolve the issue.
Steps to Reproduce
- Download the attached files
parenthesesList.txtandbracketsList.txtwith symbol IDs. - Use the following grammar definition:
import java.io.File
fun dyckGrammar(
): Grammar {
val parenthesesIds = File("parenthesesList.txt").readLines()
val bracketsIds = File("bracketsList.txt").readLines()
return object : Grammar() {
val S by Nt().asStart()
init {
var alternatives: Regexp = Epsilon or (Term("normal") * S)
for (id in parenthesesIds) {
val open = "op--$id"
val close = "cp--$id"
alternatives = alternatives or ((Term(open) * S * Term(close)) * S)
}
for (id in bracketsIds) {
val open = "ob--$id"
val close = "cb--$id"
alternatives = alternatives or ((Term(open) * S * Term(close)) * S)
}
S /= alternatives
}
}
}- Call the grammar and trigger the error:
val grammar = dyckGrammar()
grammar.rsmException:
Exception in thread "main" java.lang.StackOverflowError
at org.ucfs.grammar.combinator.regexp.Regexp$DefaultImpls.getAlphabet(Regexp.kt:30)
at org.ucfs.grammar.combinator.regexp.Alternative.getAlphabet(Alternative.kt:6)
...Attached Files
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels