Skip to content

Commit

Permalink
Fix case when ANTLR getText() causes assertion in LexerInput.
Browse files Browse the repository at this point in the history
  • Loading branch information
lkishalmi committed Mar 8, 2023
1 parent ce4ed99 commit 34f880e
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ public String getText(Interval intrvl) {
}
int start = intrvl.a - tokenMark;
int end = intrvl.b - tokenMark + 1;
int toread = end - start - input.readLength();
for (int i = 0; i < toread; i++) {
input.read();
}
String ret = String.valueOf(input.readText(start, end));
if (toread > 0) {
input.backup(toread);
int readCount = 0;
int next = 0;
while ((end > input.readLength()) && (next != EOF)) {
next = input.read();
readCount++;
}
String ret = String.valueOf(input.readText(start, Math.min(end, input.readLength())));
input.backup(readCount);
return ret;
}

Expand Down

0 comments on commit 34f880e

Please sign in to comment.