public static String getErrorMessage ( final Logger log , final BaseRecognizer recognizer , final RecognitionException e , final String superMessage , final String [ ] tokenNames ) { if ( log . isDebugEnabled ( ) ) { List < ? > stack = BaseRecognizer . getRuleInvocationStack ( e , recognizer . getClass ( ) . getSuperclass ( ) . getName ( ) ) ; String debugMsg = recognizer . getErrorHeader ( e ) + " " + e . getClass ( ) . getSimpleName ( ) + ": " + superMessage + ":" ; if ( e instanceof NoViableAltException ) { NoViableAltException nvae = ( NoViableAltException ) e ; debugMsg += " (decision=" + nvae . decisionNumber + " state=" + nvae . stateNumber + ")" + " decision=<<" + nvae . grammarDecisionDescription + ">>" ; } else if ( e instanceof UnwantedTokenException ) { UnwantedTokenException ute = ( UnwantedTokenException ) e ; debugMsg += " (unexpected token=" + toString ( ute . getUnexpectedToken ( ) , tokenNames ) + ")" ; } else if ( e instanceof EarlyExitException ) { EarlyExitException eea = ( EarlyExitException ) e ; debugMsg += " (decision=" + eea . decisionNumber + ")" ; } debugMsg += " ruleStack=" + stack . toString ( ) ; log . debug ( debugMsg ) ; } return makeUserMsg ( e , superMessage ) ; }
Format an error message as expected by ANTLR . It is basically the same error message that ANTL BaseRecognizer generates with some additional data . Also used to log debugging information .