Ejemplo n.º 1
0
 /**
  * Parses a value constraint.
  *
  * @param GraphPattern $pattern
  * @param boolean $outer     If the constraint is an outer one.
  * @return void
  */
 protected function parseConstraint(&$pattern, $outer)
 {
     $constraint = new Constraint();
     $constraint->setOuterFilter($outer);
     $this->_fastForward();
     $this->_rewind();
     $nBeginKey = key($this->tokens);
     $constraint->setTree($t = $this->parseConstraintTree());
     $nEndKey = key($this->tokens);
     if (current($this->tokens) == '}') {
         prev($this->tokens);
     }
     //for backwards compatibility with the normal sparql engine
     // which does not use the tree array currently
     $expression = trim(implode('', array_slice($this->tokens, $nBeginKey + 1, $nEndKey - $nBeginKey - 1)));
     if ($expression[0] == '(' && substr($expression, -1) == ')') {
         $expression = trim(substr($expression, 1, -1));
     }
     $constraint->addExpression($expression);
     $pattern->addConstraint($constraint);
 }