private void _fillToken()

in trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/skin/SkinCSSParser.java [311:478]


    private void _fillToken()
    {
      while (true)
      {
        _nextChar();
        switch (_currentChar)
        {
          case -1:
            _type = CSSLexicalUnits.EOF;
            break;


          case ' ':
          case '\t':
          case '\n':
          case '\f':
          case '\r':
            if (_type != CSSLexicalUnits.LEFT_CURLY_BRACE)
            {
              _type = CSSLexicalUnits.SPACE;
              return;
            }
            // fall through to LEFT_CURLY_BRACE


          case '/':
            if (_type != CSSLexicalUnits.LEFT_CURLY_BRACE)
            {
              // check for comment. If it is a comment, set the type and return
              // if it isn't a comment, keep looping to get more characters.
              _nextChar();
              if (_currentChar == '*')
              {
                // WE ARE IN A COMMENT
                // loop and get characters into buffer until we get '*/'

                _nextChar();
                int prevChar;
                while (_currentChar != -1)
                {

                  prevChar = _currentChar;
                  _nextChar();
                  if ((prevChar == '*') && (_currentChar == '/'))
                    break;
                }

                _type = CSSLexicalUnits.COMMENT;
                return;

              }
              // wasn't a comment, so keep going on, filling the buffer with
              // each _nextChar call.
              break;
            }



          case '@':
            if (_type != CSSLexicalUnits.LEFT_CURLY_BRACE)
            {
              // found @.
              // @namespace is treated differently than other @rules.
              // These are the formats:
              // @namespace foo url(http://www.foo.com);
              // @agent {
              //    af|inputText::content{color:red; background-color:blue;}
              // }
              // @platform {...}
              // If @namespace, go 'til the semi-colon
              // Else, go until the start/end brace match.

              // found @. keep getting characters until we get a ; or end of file.
              /*
              _nextChar();

              while ((_currentChar != -1) && (_currentChar != ';'))
              {
                _nextChar();
              }
              */
              _nextChar();
              // go until ; or until {} match
              int openBraceCount = 0;
              boolean openBraceCountStarted = false;
              while ((_currentChar != -1))
              {

                if (_currentChar == '{')
                  openBraceCount++;
                if (openBraceCount == 1)
                  openBraceCountStarted = true;
                if (_currentChar == '}' && openBraceCountStarted)
                {
                  openBraceCount--;
                  // make sure openBraceCount never goes negative
                  // if it does, then there was an extra right curly brace
                  if (openBraceCount < 0)
                  {
                    _handleBraceMismatch();
                  }
                  if (openBraceCountStarted && openBraceCount == 0)
                  {
                    break;
                  }
                }
                if (_currentChar == ';' && openBraceCount==0)
                {
                  break;
                }
                _nextChar();

              }

              // There should not be any closing braces pending at this point
              if (openBraceCountStarted && openBraceCount != 0)
              {
                _handleBraceMismatch();
              }

              _type = CSSLexicalUnits.AT_KEYWORD;
              return;
            }

          default:
            if (_type == CSSLexicalUnits.LEFT_CURLY_BRACE)
            {
              // these are the properties,
              // keep going until we have all the properties
              while ((_currentChar != -1) && (_currentChar != '}'))
              {
                if (_currentChar == '{')
                {
                  // this is not expected. There is a right curly braces missing
                  _handleBraceMismatch();
                }

                _nextChar();
              }
              _type = CSSLexicalUnits.RIGHT_CURLY_BRACE;
            }
            else
            {
              while ((_currentChar != -1) && (_currentChar != '{'))
              {
                // here we navigate to the opening curly braces
                // there cannot be a closing curly brace here
                if (_currentChar == '}')
                  _handleBraceMismatch();

                _nextChar();
              }
              _type = CSSLexicalUnits.LEFT_CURLY_BRACE;
            }
            return;

        } // end switch



        if (_currentChar == -1)
        {
          _type = CSSLexicalUnits.EOF;
          return;
        }
      }

    }