static function init($template, $compiler, $file = '')
{
$lexer = new Haanga_Compiler_Tokenizer($template, $compiler, $file);
file_put_contents('/tmp/foo.php', $file . "\n", FILE_APPEND);
$parser = new Haanga_Compiler_Parser($lexer, $file);
$parser->compiler = $compiler;
try {
for ($i = 0;; $i++) {
if (!$lexer->yylex()) {
break;
}
$parser->doParse($lexer->token, $lexer->value);
}
} catch (Exception $e) {
/* destroy the parser */
try {
$parser->doParse(0, 0);
} catch (Exception $y) {
}
throw $e;
/* re-throw exception */
}
$parser->doParse(0, 0);
return (array) $parser->body;
}