public function _stmt()
{
$branch_table = [Tag::T_IF => '_ifStmt', Tag::T_LET => '_letStmt', Tag::T_CONST => '_constStmt', Tag::T_WHILE => '_whileStmt', Tag::T_DO => '_exprStmt', Tag::T_FOR => '_forStmt', Tag::T_FOREACH => '_foreachStmt', Tag::T_SWITCH => '_switchStmt', Tag::T_TRY => '_tryStmt', Tag::T_BREAK => '_breakStmt', Tag::T_CONTINUE => '_continueStmt', Tag::T_RAISE => '_raiseStmt', Tag::T_BEGIN => '_blockStmt', '^' => '_returnStmt', ':-' => '_labelStmt'];
foreach ($branch_table as $token => $action) {
if ($this->parser->is($token)) {
$first_class_stmt = $this->{$action}();
// Optional postfix notation for statements
if ($this->parser->is(Tag::T_WHEN) || $this->parser->is(Tag::T_UNLESS)) {
$tag = $this->parser->consumeAndFetch()->getTag();
$predicate = $this->_expr();
return new PostConditionalStmt($first_class_stmt, $predicate, $tag);
}
return $first_class_stmt;
}
}
throw new SyntaxError(['expected' => 'statement', 'found' => $this->parser->lookahead, 'parser' => $this->parser]);
}