Ejemplo n.º 1
0
 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;
 }