int nextBlockMarker() throws LessException {
        if( cachePos < cache.length() ) {
            String str = cache.substring( cachePos );
            if( cache2 != null ) { // occur with detached rulset inside another detached ruleset
                try (Scanner scanner = new Scanner( cache2 ).useDelimiter( "\\A" )) {
                    if( scanner.hasNext() ) {
                        str = scanner.next() + str;
                    }
                }
            }
            cache2 = new StringReader( str );
        }
        cache.setLength( cachePos = 0 );
        int parenthesis = 0;
        boolean isSlash = false;
        try {
            for( ;; ) {
                int ch = readCharBlockMarker();
                if( ch < 0 ) {
                    for( int i = 0; i < cache.length(); i++ ) {
                        if( !Character.isWhitespace( cache.charAt( i ) ) ) {
                            return ';'; // a not terminated line is like a lime with semicolon
                        }
                    }
                    return -1;
                }
                cache.append( (char)ch );
                switch( ch ) {
                    case '/':
                        if( isSlash ) {
                            if( parenthesis > 0 && cache.indexOf( "url" ) > 0 ) {
                                break; // url function with unquoted url like url(http://xyz)
                            }
                            cache.setLength( cache.length() - 2 );
                            skipLine();
                            ch = 0;
                        }
                        break;
                    case '*':
                        if( isSlash ) {
                            boolean isAsterix = false;
                            for( ;; ) {
                                ch = readCharBlockMarker();
                                if( ch < 0 ) {
                                    throw createException( "Unrecognized input: '" + cache.toString().trim() + "'" );
                                }
                                cache.append( (char)ch );
                                if( ch == '/' && isAsterix ) {
                                    ch = 0;
                                    break;
                                }
                                isAsterix = ch == '*';
                            }
                        }
                        break;
                    case '{':
                        boolean isBlock = true;
                        if( cache.length() > 1 && cache.charAt( cache.length() - 2 ) == '@' ) { // @{  --> a inline variable and not a block start
                            isBlock = false;
                        } else {
                            for( int i = cache.length()-2; i > 0; i-- ) {
                                char c = cache.charAt( i );
                                if( !Character.isWhitespace( c ) ) {
                                    isBlock = c != ':';  // detached ruleset that will assign to a variable
                                    break;
                                }
                            }
                        }
                        if( !isBlock ) {
                            int braces = 1;
                            do {
                                ch = readCharBlockMarker();
                                switch( ch ) {
                                    case -1:
                                        throw createException( "Unrecognized input: '" + cache.toString().trim() + "'" );
                                    case '}':
                                        braces--;
                                        break;
                                    case '{':
                                        braces++;
                                        break;
                                }
                                cache.append( (char)ch );
                            } while( braces > 0 );
                            break;
                        }
                        //$FALL-THROUGH$
                    case '}':
                    case ';':
                        if( parenthesis == 0 ) {
                            return ch;
                        }
                        break;
                    case '(':
                        parenthesis++;
                        break;
                    case ')':
                        if( --parenthesis < 0 ) {
                            throw createException( "Unrecognized input: '" + cache.toString().trim() + "'" );
                        }
                        break;
                    case '"':
                    case '\'':
                    case '`':
                        int ch2;
                        isSlash = false;
                        for( ;; ) {
                            ch2 = readCharBlockMarker();
                            if( ch2 < 0 ) {
                                return ';'; // a not terminated line is like a lime with semicolon
                            }
                            cache.append( (char)ch2 );
                            if( ch == ch2 && !isSlash ) {
                                break;
                            }
                            isSlash = ch2 == '\\';
                        }
                        break;
                    case '\\':
                        cache.append( (char)readCharBlockMarker() );
                        break;
                    default:
                }
                isSlash = ch == '/';
            }
        } catch( IOException ex ) {
            throw new LessException( ex );
        }
    }
int nextBlockMarker ( ) throws LessException { if ( cachePos < cache . length ( ) ) { String str = cache . substring ( cachePos ) ; if ( cache2 != null ) { try ( Scanner scanner = new Scanner ( cache2 ) . useDelimiter ( "\\A" ) ) { if ( scanner . hasNext ( ) ) { str = scanner . next ( ) + str ; } } } cache2 = new StringReader ( str ) ; } cache . setLength ( cachePos = 0 ) ; int parenthesis = 0 ; boolean isSlash = false ; try { for ( ; ; ) { int ch = readCharBlockMarker ( ) ; if ( ch < 0 ) { for ( int i = 0 ; i < cache . length ( ) ; i ++ ) { if ( ! Character . isWhitespace ( cache . charAt ( i ) ) ) { return ';' ; } } return - 1 ; } cache . append ( ( char ) ch ) ; switch ( ch ) { case '/' : if ( isSlash ) { if ( parenthesis > 0 && cache . indexOf ( "url" ) > 0 ) { break ; } cache . setLength ( cache . length ( ) - 2 ) ; skipLine ( ) ; ch = 0 ; } break ; case '*' : if ( isSlash ) { boolean isAsterix = false ; for ( ; ; ) { ch = readCharBlockMarker ( ) ; if ( ch < 0 ) { throw createException ( "Unrecognized input: '" + cache . toString ( ) . trim ( ) + "'" ) ; } cache . append ( ( char ) ch ) ; if ( ch == '/' && isAsterix ) { ch = 0 ; break ; } isAsterix = ch == '*' ; } } break ; case '{' : boolean isBlock = true ; if ( cache . length ( ) > 1 && cache . charAt ( cache . length ( ) - 2 ) == '@' ) { isBlock = false ; } else { for ( int i = cache . length ( ) - 2 ; i > 0 ; i -- ) { char c = cache . charAt ( i ) ; if ( ! Character . isWhitespace ( c ) ) { isBlock = c != ':' ; break ; } } } if ( ! isBlock ) { int braces = 1 ; do { ch = readCharBlockMarker ( ) ; switch ( ch ) { case - 1 : throw createException ( "Unrecognized input: '" + cache . toString ( ) . trim ( ) + "'" ) ; case '}' : braces -- ; break ; case '{' : braces ++ ; break ; } cache . append ( ( char ) ch ) ; } while ( braces > 0 ) ; break ; } case '}' : case ';' : if ( parenthesis == 0 ) { return ch ; } break ; case '(' : parenthesis ++ ; break ; case ')' : if ( -- parenthesis < 0 ) { throw createException ( "Unrecognized input: '" + cache . toString ( ) . trim ( ) + "'" ) ; } break ; case '"' : case '\'' : case '`' : int ch2 ; isSlash = false ; for ( ; ; ) { ch2 = readCharBlockMarker ( ) ; if ( ch2 < 0 ) { return ';' ; } cache . append ( ( char ) ch2 ) ; if ( ch == ch2 && ! isSlash ) { break ; } isSlash = ch2 == '\\' ; } break ; case '\\' : cache . append ( ( char ) readCharBlockMarker ( ) ) ; break ; default : } isSlash = ch == '/' ; } } catch ( IOException ex ) { throw new LessException ( ex ) ; } }
Get the next parse type. This can be -1, ';', '{' or '}'. It copy the input until this marker in the look ahead
cache.

@return the block type of the next data.
@throws LessException if any parsing error occur.