/** * @dataProvider dataCompile * @param $template * @param $compiled * @throws \Azera\Fry\Exception\Exception * @throws \Azera\Fry\Exception\LexerException */ public function testCompiles($template, $compiled) { $env = $this->getEnvironment()->addExtension(new Core()); $lexer = new Lexer(new Reader($template), $env); $parser = new Parser($lexer->tokenize()->getStream(), $env); $bodyNode = $parser->parse()->getBody(); $compiler = new Compiler($this->getEnvironment()); $output = $compiler->compile($bodyNode); $this->assertEquals(trim($compiled), trim($output)); }
public function compileSource($source, $fileName) { $lexer = new Lexer(new Reader($source, $fileName), $this); $parser = new Parser($lexer->tokenize()->getStream(), $this); $compiler = new Compiler($this); $compiled = $compiler->compile($parser->parse()); return $compiled; }