Try to achieve a better parser error message#3406
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3406 +/- ##
============================================
- Coverage 37.72% 37.72% -0.01%
Complexity 17017 17017
============================================
Files 2076 2076
Lines 126944 126939 -5
Branches 21379 21379
============================================
- Hits 47891 47886 -5
Misses 73155 73155
Partials 5898 5898 ☔ View full report in Codecov by Sentry. |
mattulbrich
left a comment
There was a problem hiding this comment.
In your example the totally unclear SLL error message is still shown. Why? If the other is the "real" error message, can we restrict ourselves to it?
It is not final as I did not understand much of ANTLR internals. Error messages are now caught up in the |
|
The main question is: Is the KeY grammar within SLL?
I would guess so. |
|
SLL is sufficient for the KeY taclet base. Should we just drop LL mode? |
|
KaKeY decision: Fallback to LL(*) will be removed. |
7718e26 to
c7c318a
Compare
c7c318a to
d9de961
Compare
@Override
public Token recoverInline(Parser recognizer) throws RecognitionException {
InputMismatchException e = new InputMismatchException(recognizer);
for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
context.exception = e;
}
var tok = e.getOffendingToken();
var message = "I got offended by the token '%s'. Expected tokens are: %s".formatted(tok,
e.getExpectedTokens().toString(recognizer.getVocabulary()));
syntaxError(recognizer, e.getOffendingToken(),
tok.getLine(), tok.getCharPositionInLine(), message, e);
throw new ParseCancellationException(e);
}
@Override
public void recover(Parser recognizer, RecognitionException e) throws RecognitionException {
for (ParserRuleContext context = recognizer.getContext(); context != null; context = context.getParent()) {
context.exception = e;
}
var tok = e.getOffendingToken();
final var parseCancellationException = new ParseCancellationException(e);
syntaxError(recognizer, e.getOffendingToken(),
tok.getLine(), tok.getCharPositionInLine(), parseCancellationException.getMessage(), e);
throw parseCancellationException;
} |
|
closed in favor of hekeython2 approaches. |

This PR removes the LL(*) fallback from the ParsingFacade to achieve better error message.