Esempio n. 1
0
 protected function resolveIncludeCall(Expressions\MethodCall $expression)
 {
     assert($expression->getArguments()[0] instanceof Expressions\Scalar);
     $filename = $this->basePath . DIRECTORY_SEPARATOR . $expression->getArguments()[0]->getValue();
     $filehandle = fopen($filename, "r");
     assert(is_resource($filehandle));
     // make sure we don't write a new function header + footer
     $oldDisableFunctionBoilerPlate = $this->disableFunctionBoilerplate;
     $this->disableFunctionBoilerplate = true;
     $lexer = new Lexer($filehandle, $filename);
     $parser = new Parser($lexer->lex(), $this);
     $this->comment('@@START OF TEMPLATE ' . $filename . ' @@');
     $parser->parse();
     $this->comment('@@END OF TEMPLATE ' . $filename . ' @@');
     $this->disableFunctionBoilerplate = $oldDisableFunctionBoilerPlate;
 }
Esempio n. 2
0
 private function parseAndCompile($inputStream, $filename)
 {
     $outputStream = fopen($this->compiledTemplatePath, "w");
     try {
         $lexer = new Lexer($inputStream, $filename);
         $compiler = new PhpCompiler($outputStream, $this->templateRoot, $this);
         $parser = new Parser($lexer->lex(), $compiler);
         $parser->parse();
     } catch (LexException $ex) {
         $msg = sprintf("blitz::blitz(): SYNTAX ERROR: %s (%s: line %d, pos %d)", $ex->getMessage(), $ex->getTemplateName(), $ex->getTemplateLine(), $ex->getTemplateColumn());
         throw new \Exception($msg, 0, $ex);
     } catch (ParseException $ex) {
         $msg = sprintf("blitz::blitz(): SYNTAX ERROR: %s (%s: line %d, pos %d)", $ex->getMessage(), $ex->getTemplateName(), $ex->getTemplateLine(), $ex->getTemplateColumn());
         throw new \Exception($msg, 0, $ex);
     } finally {
         fclose($outputStream);
     }
 }