private void handleDeclarationBlock ( CssToken start , CssTokenIterator iter , final CssContentHandler doc , CssErrorHandler err ) throws CssException { while ( true ) { if ( MATCH_CLOSEBRACE . apply ( start ) ) { return ; } CssDeclaration decl = handleDeclaration ( start , iter , doc , err , false ) ; try { if ( decl != null ) { doc . declaration ( decl ) ; if ( debug ) { checkState ( MATCH_SEMI_CLOSEBRACE . apply ( iter . last ) ) ; } // continue or return: we may be at "; next decl" or "}" or ";}" if ( MATCH_CLOSEBRACE . apply ( iter . last ) ) { return ; } else if ( MATCH_SEMI . apply ( iter . last ) && MATCH_CLOSEBRACE . apply ( iter . peek ( ) ) ) { iter . next ( ) ; return ; } else { if ( debug ) { checkState ( MATCH_SEMI . apply ( iter . last ) ) ; } // we have ';', expect another decl start = iter . next ( ) ; // first token after ';' } } else { // #handleDeclaration returned null to signal error // #handleDeclaration has issued errors, we forward start = iter . next ( MATCH_SEMI_CLOSEBRACE ) ; if ( MATCH_SEMI . apply ( start ) ) { start = iter . next ( ) ; } } } catch ( NoSuchElementException nse ) { err . error ( new CssGrammarException ( GRAMMAR_PREMATURE_EOF , iter . last . location , messages . getLocale ( ) , "';' " + messages . get ( "or" ) + " '}'" ) ) ; throw new PrematureEOFException ( ) ; } } }
With start token being the first non - ignorable token inside the declaration block iterate issuing CssDeclaration objects until the block ends .