code: public static String printErrorMessage(String format, String errorMessage, int startIndex, int endIndex,
                                             InputBuffer inputBuffer) {
          checkArgNotNull(inputBuffer, "inputBuffer");
          checkArgument(startIndex <= endIndex);
          Position pos = inputBuffer.getPosition(startIndex);
          StringBuilder sb = new StringBuilder(String.format(format, errorMessage, pos.line, pos.column));
          sb.append('\n');
  
          String line = inputBuffer.extractLine(pos.line);
          sb.append(line);
          sb.append('\n');
  
          int charCount = Math.max(Math.min(endIndex - startIndex, StringUtils.length(line) - pos.column + 2), 1);
          for (int i = 0; i < pos.column - 1; i++) sb.append(' ');
          for (int i = 0; i < charCount; i++) sb.append('^');
          sb.append("\n");
  
          return sb.toString();
      }
docs: Prints an error message showing a location in the given InputBuffer.
  
  @param format       the format string, must include three placeholders for a string
  (the error message) and two integers (the error line / column respectively)
  @param errorMessage the error message
  @param startIndex   the start location of the error as an index into the inputBuffer
  @param endIndex     the end location of the error as an index into the inputBuffer
  @param inputBuffer  the underlying InputBuffer
  @return the error message including the relevant line from the underlying input plus location indicators