Example #1
0
 /**
  * Parses a graph pattern.
  *
  * @param  int     $optional Optional graph pattern
  * @param  int     $union    Union graph pattern
  * @param  string  $graph    Graphname
  * @param  boolean $constr   TRUE if the pattern is a construct pattern
  * @param  boolean $external If the parsed pattern shall be returned
  * @param  int     $subpattern If the new pattern is subpattern of the
  *                               pattern with the given id
  * @return void
  */
 protected function parseGraphPattern($optional = false, $union = false, $graph = false, $constr = false, $external = false, $subpattern = false)
 {
     $pattern = $this->query->getNewPattern($constr);
     if (is_int($optional)) {
         $pattern->setOptional($optional);
     } else {
         $this->tmp = $pattern->getId();
     }
     if (is_int($union)) {
         $pattern->setUnion($union);
     }
     if (is_int($subpattern)) {
         $pattern->setSubpatternOf($subpattern);
     }
     if ($graph != false) {
         $pattern->setGraphname($graph);
     }
     $this->_fastForward();
     do {
         switch (strtolower(current($this->tokens))) {
             case "graph":
                 $this->parseGraph();
                 break;
             case "union":
                 $this->_fastForward();
                 $this->parseGraphPattern(false, $this->tmp, false, false, false, $subpattern);
                 break;
             case "optional":
                 $this->_fastForward();
                 $this->parseGraphPattern($this->tmp, false, false, false, false, $subpattern);
                 break;
             case "filter":
                 $this->parseConstraint($pattern, true, false, false, false, $subpattern);
                 $this->_fastForward();
                 break;
             case ".":
                 $this->_fastForward();
                 break;
             case "{":
                 if (!is_int($subpattern)) {
                     $subpattern = $pattern->getId();
                 }
                 $this->parseGraphPattern(false, false, false, false, false, $subpattern);
                 break;
             case "}":
                 $pattern->open = false;
                 break;
             default:
                 $this->parseTriplePattern($pattern);
                 break;
         }
     } while ($pattern->open);
     if ($external) {
         return $pattern;
     }
     $this->_fastForward();
 }