private void processNestedComment ( ) { int nestedCommentsAmount = 1 ; // Starting with just the initial comment. while ( templateReader . hasNextCharacter ( ) ) { final char commentCharacter = templateReader . nextCharacter ( ) ; if ( isCommentClosingMarker ( commentCharacter ) && templateReader . hasNextCharacter ( ) && templateReader . peekCharacter ( ) == syntax . getTagClosing ( ) ) { // Character was a comment closing sign and the next tag closed the comment. templateReader . nextCharacter ( ) ; // Polling tag closing. if ( -- nestedCommentsAmount == 0 ) { // All comments ended. Returning. break ; } } if ( commentCharacter == syntax . getTagOpening ( ) && templateReader . hasNextCharacter ( ) && isCommentOpeningMarker ( templateReader . peekCharacter ( ) ) ) { // Another comment was opened inside the currently parsed one. templateReader . nextCharacter ( ) ; // Polling comment opening marker. nestedCommentsAmount ++ ; } } }
Found an open tag starting with comment sign and nested comments are on . Burning through characters up to the comment s end honoring nested commented - out comments .