private function processSwitch()
{
$switchId = $this->addAtom('Switch');
$current = $this->id;
++$this->id;
// Skip (
while (!in_array($this->tokens[$this->id + 1][0], array(T_CLOSE_PARENTHESIS))) {
$this->processNext();
}
$nameId = $this->popExpression();
$this->addLink($switchId, $nameId, 'NAME');
$casesId = $this->addAtom('Sequence');
$this->setAtom($casesId, array('code' => self::FULLCODE_SEQUENCE, 'fullcode' => self::FULLCODE_SEQUENCE, 'line' => $this->tokens[$current][2], 'token' => $this->getToken($this->tokens[$current][0]), 'bracket' => true));
$this->addLink($switchId, $casesId, 'CASES');
++$this->id;
$isColon = $this->tokens[$this->id + 1][0] === T_COLON;
$rank = 0;
if ($this->tokens[$this->id + 1][0] === T_CLOSE_PARENTHESIS) {
$voidId = $this->addAtomVoid();
$this->addLink($casesId, $voidId, 'ELEMENT');
$this->setAtom($voidId, array('rank' => $rank));
++$this->id;
} else {
if ($this->tokens[$this->id + 1][0] === T_OPEN_CURLY) {
++$this->id;
$finals = array(T_CLOSE_CURLY);
} else {
++$this->id;
// skip :
$finals = array(T_ENDSWITCH);
}
while (!in_array($this->tokens[$this->id + 1][0], $finals)) {
$this->processNext();
$caseId = $this->popExpression();
$this->addLink($casesId, $caseId, 'ELEMENT');
$this->setAtom($caseId, array('rank' => ++$rank));
}
}
++$this->id;
$this->setAtom($casesId, array('count' => $rank));
if ($isColon) {
$fullcode = $this->tokens[$current][1] . ' (' . $this->atoms[$nameId]['fullcode'] . ') :' . self::FULLCODE_SEQUENCE . ' ' . $this->tokens[$this->id][1];
} else {
$fullcode = $this->tokens[$current][1] . ' (' . $this->atoms[$nameId]['fullcode'] . ')' . self::FULLCODE_BLOCK;
}
$this->setAtom($switchId, array('code' => $this->tokens[$current][1], 'fullcode' => $fullcode, 'line' => $this->tokens[$current][2], 'token' => $this->getToken($this->tokens[$current][0]), 'alternative' => $isColon));
$this->pushExpression($switchId);
$this->processSemicolon();
return $switchId;
}