/**
  * Parses a query string.
  *
  * @return ParserResult
  */
 public function parse()
 {
     $AST = $this->getAST();
     if (($customWalkers = $this->query->getHint(Query::HINT_CUSTOM_TREE_WALKERS)) !== false) {
         $this->customTreeWalkers = $customWalkers;
     }
     if (($customOutputWalker = $this->query->getHint(Query::HINT_CUSTOM_OUTPUT_WALKER)) !== false) {
         $this->customOutputWalker = $customOutputWalker;
     }
     // Run any custom tree walkers over the AST
     if ($this->customTreeWalkers) {
         $treeWalkerChain = new TreeWalkerChain($this->query, $this->parserResult, $this->queryComponents);
         foreach ($this->customTreeWalkers as $walker) {
             $treeWalkerChain->addTreeWalker($walker);
         }
         switch (true) {
             case $AST instanceof AST\UpdateStatement:
                 $treeWalkerChain->walkUpdateStatement($AST);
                 break;
             case $AST instanceof AST\DeleteStatement:
                 $treeWalkerChain->walkDeleteStatement($AST);
                 break;
             case $AST instanceof AST\SelectStatement:
             default:
                 $treeWalkerChain->walkSelectStatement($AST);
         }
         $this->queryComponents = $treeWalkerChain->getQueryComponents();
     }
     $outputWalkerClass = $this->customOutputWalker ?: __NAMESPACE__ . '\\SqlWalker';
     $outputWalker = new $outputWalkerClass($this->query, $this->parserResult, $this->queryComponents);
     // Assign an SQL executor to the parser result
     $this->parserResult->setSqlExecutor($outputWalker->getExecutor($AST));
     return $this->parserResult;
 }