protected function next()
{
if (!empty($this->queue)) {
return array_shift($this->queue);
}
if ($this->cursor >= $this->end) {
return new Token(Token::EOF, null, $this->line, $this->char);
}
switch ($this->position) {
case self::POSITION_TEXT:
$this->queue = $this->lexText();
break;
case self::POSITION_BLOCK:
$this->queue = $this->lexBlock();
break;
case self::POSITION_OUTPUT:
$this->queue = $this->lexOutput();
break;
}
return $this->next();
}