Пример #1
0
 /**
  * get next token
  * @see Fl_Token::getNextToken()
  */
 public function getNextToken()
 {
     $token = parent::getNextToken();
     if ($token || $token === false) {
         return $token;
     }
     $char = $this->getCurrentChar();
     if ($char === false) {
         return $this->getLastToken();
     }
     if (!$this->_checkNamespace) {
         $this->_checkNamespace = true;
         if (Fl_Css_Static::checkNamespace($this->text)) {
             $result = $this->readWhile('getNamespaceToken');
             return $this->getTokenInfo(FL_TOKEN_CSS_SELECTOR_NAMESPACE, $result);
         }
     }
     $type = '';
     $value = '';
     switch ($char) {
         case '*':
             $type = FL_TOKEN_CSS_SELECTOR_UNIVERSAL;
             $this->getNextChar();
             $value = $char;
             break;
         case ',':
             $type = FL_TOKEN_CSS_SELECTOR_COMMA;
             $this->getNextChar();
             $value = $char;
             break;
         case '>':
         case '+':
         case '~':
             $this->getNextChar();
             $value = $char;
             $type = FL_TOKEN_CSS_SELECTOR_COMBINATOR;
             break;
         case '#':
             $type = FL_TOKEN_CSS_SELECTOR_ID;
             $value = $this->readWhile('getIdToken');
             break;
         case '.':
             $type = FL_TOKEN_CSS_SELECTOR_CLASS;
             $value = $this->readWhile('getClassToken');
             break;
         case '[':
             $type = FL_TOKEN_CSS_SELECTOR_ATTRIBUTES;
             $value = $this->getAttributeToken($char);
             break;
         case ':':
             if ($this->getPosChar($this->pos + 1) === ':') {
                 $this->getNextChar();
                 $value = ':' . $this->readWhile('getPseudoElementToken');
                 $type = FL_TOKEN_CSS_SELECTOR_PSEUDO_ELEMENT;
             } else {
                 $value = $this->getPseudoClassToken($char);
                 $type = FL_TOKEN_CSS_SELECTOR_PSEUDO_CLASS;
             }
             break;
         default:
             $value = $this->readWhile('getTypeToken');
             $type = FL_TOKEN_CSS_SELECTOR_TYPE;
     }
     if ($this->check && !Fl_Css_Static::checkSelectorToken($type, $value)) {
         $this->throwException($value . ' is not valid');
     }
     return $this->getTokenInfo($type, $value);
 }