private function processFollowingBlock($finals)
{
if ($this->tokens[$this->id + 1][0] === T_OPEN_CURLY) {
++$this->id;
$blockId = $this->processBlock(false);
} elseif ($this->tokens[$this->id + 1][0] === T_COLON) {
$this->startSequence();
$blockId = $this->sequence;
++$this->id;
// skip :
while (!in_array($this->tokens[$this->id + 1][0], $finals)) {
$this->processNext();
}
$this->pushExpression($this->sequence);
$this->endSequence();
} elseif (in_array($this->tokens[$this->id + 1][0], array(T_SEMICOLON))) {
// void; One epxression block, with ;
$this->startSequence();
$blockId = $this->sequence;
$voidId = $this->addAtomVoid();
$this->addToSequence($voidId);
$this->endSequence();
$this->pushExpression($blockId);
++$this->id;
} elseif (in_array($this->tokens[$this->id + 1][0], array(T_CLOSE_TAG, T_CLOSE_CURLY, T_CLOSE_PARENTHESIS))) {
// Completely void (not even ;)
$this->startSequence();
$blockId = $this->sequence;
$voidId = $this->addAtomVoid();
$this->addToSequence($voidId);
$this->endSequence();
$this->pushExpression($blockId);
} else {
// One expression only
$this->startSequence();
$blockId = $this->sequence;
$current = $this->id;
// This may include WHILE in the list of finals for do....while
$finals = array_merge(array(T_SEMICOLON, T_CLOSE_TAG, T_ELSE, T_END, T_CLOSE_CURLY), $finals);
$specials = array(T_IF, T_FOREACH, T_SWITCH, T_FOR, T_TRY, T_WHILE);
if (in_array($this->tokens[$this->id + 1][0], $specials)) {
$this->processNext();
} else {
while (!in_array($this->tokens[$this->id + 1][0], $finals)) {
$this->processNext();
}
$expressionId = $this->popExpression();
$this->addToSequence($expressionId);
}
$this->endSequence();
if (!in_array($this->tokens[$current + 1][0], $specials)) {
++$this->id;
}
$this->pushExpression($blockId);
}
return $blockId;
}