/** * This method parses a try-statement + associated catch-statements. * * @return \PDepend\Source\AST\ASTTryStatement * @since 0.9.12 */ private function parseTryStatement() { $this->tokenStack->push(); $token = $this->consumeToken(Tokens::T_TRY); $stmt = $this->builder->buildAstTryStatement($token->image); $stmt->addChild($this->parseRegularScope()); $this->consumeComments(); if (false === in_array($this->tokenizer->peek(), array(Tokens::T_CATCH, Tokens::T_FINALLY))) { throw new UnexpectedTokenException($this->tokenizer->next(), $this->tokenizer->getSourceFile()); } while ($this->tokenizer->peek() === Tokens::T_CATCH) { $stmt->addChild($this->parseCatchStatement()); $this->consumeComments(); } while ($this->tokenizer->peek() === Tokens::T_FINALLY) { $stmt->addChild($this->parseFinallyStatement()); $this->consumeComments(); } return $this->setNodePositionsAndReturn($stmt); }