Lexy::compile PHP Method

compile() protected method

[compile description]
protected compile ( [type] $text, boolean $sandbox = false ) : [type]
$text [type]
$sandbox boolean [description]
return [type]
    protected function compile($text, $sandbox = false)
    {
        // disable php in sandbox mode
        if ($sandbox) {
            $text = str_replace(array("<?", "?>"), array("&lt;?", "?&gt;"), $text);
        }
        foreach ($this->compilers as $compiler) {
            $method = "compile_{$compiler}";
            $text = $this->{$method}($text);
        }
        if ($sandbox) {
            $lines = explode("\n", $text);
            foreach ($lines as $ln => &$line) {
                if ($errors = $this->check_security($line)) {
                    return 'illegal call(s): ' . implode(", ", $errors) . " - on line " . $ln . ($this->srcinfo ? ' (' . $this->srcinfo . ') ' : '');
                }
            }
        }
        if ($errors = $this->check_syntax($text)) {
            if ($this->srcinfo) {
                $errors[] = '(' . $this->srcinfo . ')';
            }
            return implode("\n", $errors);
        }
        return $text;
    }