private static function _print($value) { if (Util::isNode($value)) { Util::checkArity($value, 1); return print Interpreter::parseNode($value->children()[0]); } else { return print dom_import_simplexml($value)->textContent; } }
public static function parse(array &$argv) { if (!isset($argv[2])) { echo "No input file", PHP_EOL; return; } if (!file_exists($argv[2])) { echo "File doesn't exists", PHP_EOL; return; } try { $parser = new Parser(file_get_contents($argv[2])); $ast = $parser->getAst(); Interpreter::evaluate($ast); } catch (Exception $e) { echo $e->getMessage(), PHP_EOL; return; } }
function upper() { return new F("upper", 1, function ($node) { return strtoupper(U::isNode($node) ? I::parseNode($node)->children()[0] : dom_import_simplexml($node)->textContent); }); }