Example #1
0
 /**
  * Main function of SparqlParser. Parses a query string.
  *
  * @param  String $queryString The SPARQL query
  * @return Query  The query object
  * @throws SparqlParserException
  */
 public function parse($queryString = false)
 {
     $this->prepare();
     if ($queryString) {
         $this->query->setQueryString($queryString);
         $uncommentedQuery = $this->uncomment($queryString);
         $this->queryString = $uncommentedQuery;
         $this->tokens = self::tokenize($uncommentedQuery);
         $this->parseQuery();
         if (!$this->query->isComplete()) {
             throw new SparqlParserException("Query is incomplete.", null, $queryString);
         }
     } else {
         throw new SparqlParserException("Querystring is empty.", null, key($this->tokens));
         $this->query->isEmpty = true;
     }
     return $this->query;
 }