protected int lexWhiteSpacesAndComments(int currentOffset,List<CustomToken> targetList){
  CharSequence buffer=getBuffer();
  int bufferEnd=getBufferEnd();
  while (currentOffset < bufferEnd) {
    char currentChar=buffer.charAt(currentOffset);
    if (currentChar == '\n') {
      targetList.add(getCustomToken(currentOffset++,currentOffset,TokenType.NEW_LINE_INDENT));
    }
 else     if (Character.isWhitespace(currentChar)) {
      int whiteSpaceStart=currentOffset;
      while (currentOffset < bufferEnd && Character.isWhitespace(currentChar=buffer.charAt(currentOffset)) && currentChar != '\n') {
        currentOffset++;
      }
      targetList.add(getCustomToken(whiteSpaceStart,currentOffset,TokenType.WHITE_SPACE));
    }
 else     if (currentChar == '#') {
      int commentStart=currentOffset;
      while (currentOffset < bufferEnd && buffer.charAt(currentOffset) != '\n') {
        currentOffset++;
      }
      targetList.add(getCustomToken(commentStart,currentOffset,COMMENT_LINE));
    }
 else {
      break;
    }
  }
  return currentOffset;
}

protected int lexWhiteSpacesAndComments ( int currentOffset , List < CustomToken > targetList ) { CharSequence buffer = getBuffer ( ) ; int bufferEnd = getBufferEnd ( ) ; while ( currentOffset < bufferEnd ) { char currentChar = buffer . charAt ( currentOffset ) ; if ( currentChar == '\n' ) { targetList . add ( getCustomToken ( currentOffset ++ , currentOffset , TokenType . NEW_LINE_INDENT ) ) ; } else if ( Character . isWhitespace ( currentChar ) ) { int whiteSpaceStart = currentOffset ; while ( currentOffset < bufferEnd && Character . isWhitespace ( currentChar = buffer . charAt ( currentOffset ) ) && currentChar != '\n' ) { currentOffset ++ ; } targetList . add ( getCustomToken ( whiteSpaceStart , currentOffset , TokenType . WHITE_SPACE ) ) ; } else if ( currentChar == '#' ) { int commentStart = currentOffset ; while ( currentOffset < bufferEnd && buffer . charAt ( currentOffset ) != '\n' ) { currentOffset ++ ; } targetList . add ( getCustomToken ( commentStart , currentOffset , COMMENT_LINE ) ) ; } else { break ; } } return currentOffset ; }
lexing empty spaces and comments between regex / tr blocks and adding tokens to the target list
