static function init($template, $compiler, $file = '') { $lexer = new Haanga_Compiler_Lexer($template, $compiler); $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) { throw new Haanga_Compiler_Exception($e->getMessage() . ' on line ' . $lexer->getLine()); } $parser->doParse(0, 0); return (array) $parser->body; }
static function init($template, $compiler, $file = '') { $lexer = new Haanga_Compiler_Tokenizer($template, $compiler, $file); $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; }