function Parser::parseCatch
Parses the catch block of a try-catch statement
Return value
Node\CatchClause|null
1 call to Parser::parseCatch()
- Parser::parseTryStatement in vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php - Parses a try-catch statement
File
-
vendor/
mck89/ peast/ lib/ Peast/ Syntax/ Parser.php, line 610
Class
- Parser
- Parser class
Namespace
Peast\SyntaxCode
protected function parseCatch() {
if ($token = $this->scanner
->consume("catch")) {
$node = $this->createNode("CatchClause", $token);
if ($this->scanner
->consume("(")) {
if (!($param = $this->parseCatchParameter()) || !$this->scanner
->consume(")")) {
$this->error();
}
$node->setParam($param);
}
elseif (!$this->features->optionalCatchBinding) {
$this->error();
}
if (!($body = $this->parseBlock())) {
$this->error();
}
$node->setBody($body);
return $this->completeNode($node);
}
return null;
}