/**
  * Parse the query
  * @throws \Exception any number of exceptions may be thrown on errors
  * @return Query
  */
 public function parse()
 {
     if ($this->query->isEmpty()) {
         return $this->query;
     }
     $text = $this->query->getText();
     $this->query->setSelect($this->readSelect($text));
     $this->readWhere($text);
     $this->readGroupBy($text);
     $this->query->setPivot($this->readPivot($text));
     $this->readOrderBy($text);
     $this->readSkipping($text);
     $this->readLimit($text);
     $this->readOffset($text);
     $this->readLabel($text);
     $this->readFormat($text);
     $this->readOptions($text);
     if ($text !== '') {
         throw new InvalidQueryException("Syntax error near: " . $text);
     }
     return $this->query;
 }