code: public static String makeUserMsg(final RecognitionException e, final String msg) {
          if (e instanceof NoViableAltException) {
              return msg.replace("no viable alternative at", "unrecognized");
          } else if (e instanceof UnwantedTokenException) {
              return msg.replace("extraneous input", "unexpected token");
          } else if (e instanceof MismatchedTokenException) {
              if (msg.contains("mismatched input '<EOF>'")) {
                  return msg.replace("mismatched input '<EOF>' expecting", "reached end of file looking for");
              } else {
                  return msg.replace("mismatched input", "unexpected token");
              }
          } else if (e instanceof EarlyExitException) {
              return msg.replace("required (...)+ loop did not match anything", "required tokens not found");
          } else if (e instanceof FailedPredicateException) {
              if (msg.contains("picture_string failed predicate: {Unbalanced parentheses}")) {
                  return "Unbalanced parentheses in picture string";
              }
              if (msg.contains("PICTURE_PART failed predicate: {Contains invalid picture symbols}")) {
                  return "Picture string contains invalid symbols";
              }
              if (msg.contains("PICTURE_PART failed predicate: {Syntax error in last picture clause}")) {
                  return "Syntax error in last picture clause";
              }
              if (msg.contains("DATA_NAME failed predicate: {Syntax error in last clause}")) {
                  return "Syntax error in last COBOL clause";
              }
          }
          return msg;
      }
docs: Simplify error message text for end users.
  @param e exception that occurred
  @param msg as formatted by ANTLR
  @return a more readable error message