Skip to content

Commit

Permalink
Only replace text if found
Browse files Browse the repository at this point in the history
  • Loading branch information
luepges committed Jan 1, 2025
1 parent 82d7615 commit 984d0dc
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ public void syntaxError(Recognizer<?, ?> recognizer, Object offendingSymbol, int
// Due to our substitute-no-keyword handling, we remove no-keywords from the expected list (as they are included within Name)
if (parser.getNoKeywordRuleNames() != null) {
int index = msg.indexOf("' expecting "); // We strip everything after the expecting
msg = msg.substring(0, index) + "', expecting ";
if (index >= 0) {
msg = msg.substring(0, index) + "', expecting ";
}

// Check for the rules which the ATN would change into using epsilon transitions (to find nokeywor rules)
Set<Map.Entry<Integer, String>> epsilonRules = new HashSet<>();
Expand Down

0 comments on commit 984d0dc

Please sign in to comment.