You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generating custom error messages on top of error messages generated by ANTLR4
I am trying to customize the error messages generated by ANTLR4 by categorizing them. I am using syntax error generated by ErrorListner in ANTLR4 class CustomErrorListener<TSymbol = any> implements ErrorListener<TSymbol> { private syntaxErrors: { line: number; column: number; lastCharPosition: number; message: string }[] = []; syntaxError( recognizer: Recognizer<TSymbol>, offendingSymbol: TSymbol, line: number, column: number, message: string, exception?: RecognitionException ): void {}
But I am unable to distinguish the exceptions using the Exception types. Please refer the below code if (exception instanceof RecognitionException) {
message = "Recoginition Error: " + message;
}
if (exception instanceof NoViableAltException) {
message = "No Viable Alternative Error: " + message;
}
Please let me know if there are any ways to customize the error messages
The text was updated successfully, but these errors were encountered:
I was just looking at error reporting. #3700 (comment). You have to override the error strategy as well since that is where the error message is constructed from the parser state.
Generating custom error messages on top of error messages generated by ANTLR4
I am trying to customize the error messages generated by ANTLR4 by categorizing them. I am using syntax error generated by ErrorListner in ANTLR4
class CustomErrorListener<TSymbol = any> implements ErrorListener<TSymbol> { private syntaxErrors: { line: number; column: number; lastCharPosition: number; message: string }[] = []; syntaxError( recognizer: Recognizer<TSymbol>, offendingSymbol: TSymbol, line: number, column: number, message: string, exception?: RecognitionException ): void {}
But I am unable to distinguish the exceptions using the Exception types. Please refer the below code
if (exception instanceof RecognitionException) {
message = "Recoginition Error: " + message;
}
if (exception instanceof NoViableAltException) {
message = "No Viable Alternative Error: " + message;
}
Please let me know if there are any ways to customize the error messages
The text was updated successfully, but these errors were encountered: