private CssDeclaration handleDeclaration ( CssToken name , CssTokenIterator iter , CssContentHandler doc , CssErrorHandler err , boolean isStyleAttribute ) throws CssException { if ( name . type != CssToken . Type . IDENT ) { err . error ( new CssGrammarException ( GRAMMAR_EXPECTING_TOKEN , name . location , messages . getLocale ( ) , name . getChars ( ) , messages . get ( "a_property_name" ) ) ) ; return null ; } CssDeclaration declaration = new CssDeclaration ( name . getChars ( ) , name . location ) ; try { if ( ! MATCH_COLON . apply ( iter . next ( ) ) ) { err . error ( new CssGrammarException ( GRAMMAR_EXPECTING_TOKEN , name . location , messages . getLocale ( ) , iter . last . getChars ( ) , ":" ) ) ; return null ; } } catch ( NoSuchElementException nse ) { err . error ( new CssGrammarException ( GRAMMAR_PREMATURE_EOF , iter . last . location , messages . getLocale ( ) , ":" ) ) ; throw new PrematureEOFException ( ) ; } try { while ( true ) { CssToken value = iter . next ( ) ; if ( MATCH_SEMI_CLOSEBRACE . apply ( value ) ) { if ( declaration . components . size ( ) < 1 ) { err . error ( new CssGrammarException ( GRAMMAR_EXPECTING_TOKEN , iter . last . location , messages . getLocale ( ) , value . getChar ( ) , messages . get ( "a_property_value" ) ) ) ; return null ; } else { return declaration ; } } else { if ( ! handlePropertyValue ( declaration , value , iter , isStyleAttribute ) ) { err . error ( new CssGrammarException ( GRAMMAR_UNEXPECTED_TOKEN , iter . last . location , messages . getLocale ( ) , iter . last . getChars ( ) ) ) ; return null ; } else { if ( isStyleAttribute && ! iter . hasNext ( ) ) { return declaration ; } } } } } catch ( NoSuchElementException nse ) { err . error ( new CssGrammarException ( GRAMMAR_PREMATURE_EOF , iter . last . location , messages . getLocale ( ) , "';' " + messages . get ( "or" ) + " '}'" ) ) ; throw new PrematureEOFException ( ) ; } }
With start expected to be an IDENT token representing the property name build the declaration and return after hitting ; or } . On error issue to errhandler return null caller forwards .