protected String getErrorMessage(RecognitionException re) {
    String message = "";

    Parser recognizer = (Parser) re.getRecognizer();
    TokenStream tokens = recognizer.getInputStream();

    if (re instanceof NoViableAltException) {
      NoViableAltException e = (NoViableAltException) re;
      Token startToken = e.getStartToken();
      String input =
          (startToken.getType() == Token.EOF)
              ? "end of text"
              : quote(tokens.getText(startToken, e.getOffendingToken()));

      message = "no viable date format found at " + input;
    } else if (re instanceof InputMismatchException) {
      InputMismatchException e = (InputMismatchException) re;
      message =
          "did not expect "
              + getTokenDisplayString(e.getOffendingToken())
              + " while looking for "
              + e.getExpectedTokens().toString(recognizer.getTokenNames());
    } else if (re instanceof FailedPredicateException) {
      FailedPredicateException e = (FailedPredicateException) re;
      String ruleName = recognizer.getRuleNames()[recognizer.getContext().getRuleIndex()];

      message = "failed predicate " + ruleName + ": " + e.getMessage();
    }

    return message;
  }
 @Override
 public void syntaxError(
     Recognizer<?, ?> recognizer,
     Object offendingSymbol,
     int line,
     int charPositionInLine,
     String msg,
     RecognitionException e) {
   if (e != null) {
     if (!msg.contains("<EOF>")) {
       String exc = e.getClass().getName();
       if (exc.contains("InputMismatchException")) {
         System.out.println(
             "Error Sintactico: Entrada no coincide con tokens. Linea "
                 + line
                 + ", caracter "
                 + charPositionInLine
                 + ". Por favor verifique su codigo UNALang.");
         System.out.println("\t Detalle del error: " + msg);
       } else if (exc.contains("FailedPredicateException")) {
         System.out.println(
             "Error Semantico: Validacion Fallida. Linea "
                 + line
                 + ", caracter "
                 + charPositionInLine
                 + ". Por favor verifique su codigo UNALang.");
         System.out.println("\t Detalle del error: " + msg);
       } else if (exc.contains("LexerNoViableAltException")) {
         System.out.println(
             "Error Sintactico: Ambiguedad en entrada para analisis. Linea "
                 + line
                 + ", caracter "
                 + charPositionInLine
                 + ". Por favor verifique su codigo UNALang.");
         System.out.println("\t Detalle del error: " + msg);
       } else if (exc.contains("NoViableAltException")) {
         System.out.println(
             "Error Semantico: Ambiguedad en entrada para analisis. Linea "
                 + line
                 + ", caracter "
                 + charPositionInLine
                 + ". Por favor verifique su codigo UNALang.");
         System.out.println("\t Detalle del error: " + msg);
       } else {
         System.out.println("OTRO ERROR :V");
       }
     }
   } else {
     System.out.println(
         "Error " + msg + " en Linea " + line + " " + ", caracter " + charPositionInLine);
   }
 }
    /**
     * Logs parser errors in Checkstyle manner. Parser can generate error messages. There is special
     * error that parser can generate. It is missed close HTML tag. This case is special because
     * parser prints error like {@code "no viable alternative at input 'b \n *\n'"} and it is not
     * clear that error is about missed close HTML tag. Other error messages are not special and
     * logged simply as "Parse Error...".
     *
     * <p>{@inheritDoc}
     */
    @Override
    public void syntaxError(
        Recognizer<?, ?> recognizer,
        Object offendingSymbol,
        int line,
        int charPositionInLine,
        String msg,
        RecognitionException ex) {
      final int lineNumber = offset + line;
      final Token token = (Token) offendingSymbol;

      if (MSG_JAVADOC_MISSED_HTML_CLOSE.equals(msg)) {
        errorMessage =
            new ParseErrorMessage(
                lineNumber, MSG_JAVADOC_MISSED_HTML_CLOSE, charPositionInLine, token.getText());

        throw new ParseCancellationException(msg);
      } else if (MSG_JAVADOC_WRONG_SINGLETON_TAG.equals(msg)) {
        errorMessage =
            new ParseErrorMessage(
                lineNumber, MSG_JAVADOC_WRONG_SINGLETON_TAG, charPositionInLine, token.getText());

        throw new ParseCancellationException(msg);
      } else {
        final int ruleIndex = ex.getCtx().getRuleIndex();
        final String ruleName = recognizer.getRuleNames()[ruleIndex];
        final String upperCaseRuleName =
            CaseFormat.UPPER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, ruleName);

        errorMessage =
            new ParseErrorMessage(
                lineNumber,
                MSG_JAVADOC_PARSE_RULE_ERROR,
                charPositionInLine,
                msg,
                upperCaseRuleName);
      }
    }