You are here

private function CssParser::combinator in QueryPath 7.3

Same name and namespace in other branches
  1. 6 QueryPath/CssParser.php \CssParser::combinator()
  2. 7.2 QueryPath/CssParser.php \CssParser::combinator()
1 call to CssParser::combinator()
CssParser::selector in QueryPath/CssParser.php

File

QueryPath/CssParser.php, line 173

Class

CssParser

Code

private function combinator() {
  if ($this->DEBUG) {
    print "COMBINATOR\n";
  }
  $inCombinator = FALSE;
  $white = $this
    ->consumeWhitespace();
  $t = $this->scanner->token;
  if ($t == CssToken::rangle) {
    $this->handler
      ->directDescendant();
    $this->scanner
      ->nextToken();
    $inCombinator = TRUE;
  }
  elseif ($t == CssToken::plus) {
    $this->handler
      ->adjacent();
    $this->scanner
      ->nextToken();
    $inCombinator = TRUE;
  }
  elseif ($t == CssToken::comma) {
    $this->handler
      ->anotherSelector();
    $this->scanner
      ->nextToken();
    $inCombinator = TRUE;
  }
  elseif ($t == CssToken::tilde) {
    $this->handler
      ->sibling();
    $this->scanner
      ->nextToken();
    $inCombinator = TRUE;
  }
  if ($inCombinator) {
    $white = 0;
    if ($this->DEBUG) {
      print "COMBINATOR: " . CssToken::name($t) . "\n";
    }
    $this
      ->consumeWhitespace();
    if ($this
      ->isCombinator($this->scanner->token)) {
      throw new CssParseException("Illegal combinator: Cannot have two combinators in sequence.");
    }
  }
  elseif ($white > 0) {
    if ($this->DEBUG) {
      print "COMBINATOR: any descendant\n";
    }
    $inCombinator = TRUE;
    $this->handler
      ->anyDescendant();
  }
  else {
    if ($this->DEBUG) {
      print "COMBINATOR: no combinator found.\n";
    }
  }
}