public function compile($code, $path = null)
{
$locale = setlocale(LC_NUMERIC, 0);
setlocale(LC_NUMERIC, 'C');
$this->indentLevel = -1;
$this->commentsSeen = [];
$this->extends = [];
$this->extendsMap = [];
$this->sourceIndex = null;
$this->sourceLine = null;
$this->sourceColumn = null;
$this->env = null;
$this->scope = null;
$this->storeEnv = null;
$this->charsetSeen = null;
$this->shouldEvaluate = null;
$this->stderr = fopen('php://stderr', 'w');
$this->parser = $this->parserFactory($path);
$tree = $this->parser->parse($code);
$this->parser = null;
$this->formatter = new $this->formatter();
$this->rootBlock = null;
$this->rootEnv = $this->pushEnv($tree);
$this->injectVariables($this->registeredVars);
$this->compileRoot($tree);
$this->popEnv();
$out = $this->formatter->format($this->scope);
setlocale(LC_NUMERIC, $locale);
return $out;
}