You are here

private function Parser::parserSelectorNode in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/css-selector/Parser/Parser.php \Symfony\Component\CssSelector\Parser\Parser::parserSelectorNode()

Parses next selector or combined node.

Parameters

TokenStream $stream:

Return value

Node\SelectorNode

Throws

SyntaxErrorException

1 call to Parser::parserSelectorNode()
Parser::parseSelectorList in vendor/symfony/css-selector/Parser/Parser.php
Parses selector nodes.

File

vendor/symfony/css-selector/Parser/Parser.php, line 138

Class

Parser
CSS selector parser.

Namespace

Symfony\Component\CssSelector\Parser

Code

private function parserSelectorNode(TokenStream $stream) {
  list($result, $pseudoElement) = $this
    ->parseSimpleSelector($stream);
  while (true) {
    $stream
      ->skipWhitespace();
    $peek = $stream
      ->getPeek();
    if ($peek
      ->isFileEnd() || $peek
      ->isDelimiter(array(
      ',',
    ))) {
      break;
    }
    if (null !== $pseudoElement) {
      throw SyntaxErrorException::pseudoElementFound($pseudoElement, 'not at the end of a selector');
    }
    if ($peek
      ->isDelimiter(array(
      '+',
      '>',
      '~',
    ))) {
      $combinator = $stream
        ->getNext()
        ->getValue();
      $stream
        ->skipWhitespace();
    }
    else {
      $combinator = ' ';
    }
    list($nextSelector, $pseudoElement) = $this
      ->parseSimpleSelector($stream);
    $result = new Node\CombinedSelectorNode($result, $combinator, $nextSelector);
  }
  return new Node\SelectorNode($result, $pseudoElement);
}