public function parse($input)
{
$this->level = 0;
$this->tokens = $this->lexer->lex($input);
$this->document = $this->createNode('document', ['line' => 0, 'offset' => 0]);
$this->currentParent = $this->document;
$this->current = null;
$this->last = null;
$this->inMixin = false;
$this->mixinLevel = null;
$this->expansion = null;
//Fix HHVM generators needing ->next() before ->current()
//This will actually work as expected, no node will be skipped
//HHVM always needs a first ->next() (I don't know if this is a bug or
//expected behaviour)
if (defined('HHVM_VERSION')) {
$this->tokens->next();
}
//While we have tokens, handle current token, then go to next token
//rinse and repeat
while ($this->hasTokens()) {
$this->handleToken();
$this->nextToken();
}
//Return the final document node with all its awesome child nodes
return $this->document;
}