avoid crash when parser doesn't report an offending token for a parse error

This commit is contained in:
Irmen de Jong 2021-10-19 00:44:33 +02:00
parent 4011dce31b
commit 40bf117497

View File

@ -97,11 +97,15 @@ object Prog8Parser {
if (e == null) {
TODO("no RecognitionException - create your own ParseError")
//throw ParseError()
} else {
if(e.offendingToken==null) {
throw ParseError(msg, Position(src.origin, line, charPositionInLine, charPositionInLine), e)
} else {
throw ParseError(msg, e.getPosition(src.origin), e)
}
}
}
}
private fun RecognitionException.getPosition(file: String): Position {
val offending = this.offendingToken