public function parse(\Twig_Token $token)
{
$lineno = $token->getLine();
$expr = $this->parser->getExpressionParser()->parseExpression();
$this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
$body = $this->parser->subparse(array($this, 'decideIfEnd'));
$tests = array($expr, $body);
$else = null;
$end = false;
$next_val = $this->parser->getStream()->next()->getValue();
while (!$end) {
switch ($next_val) {
case 'endwhile':
$end = true;
break;
default:
throw new \Twig_Error_Syntax(sprintf('Unexpected end of template. Twig was looking for "endwhile" to close the "while" block started at line %d)', $lineno), -1);
}
}
$this->parser->getStream()->expect(\Twig_Token::BLOCK_END_TYPE);
return new Twig_Node_While(new \Twig_Node($tests), $else, $lineno, $this->getTag());
}