Example #1
0
 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;
     }
 }
Example #2
0
 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;
     }
 }
Example #3
0
function upper()
{
    return new F("upper", 1, function ($node) {
        return strtoupper(U::isNode($node) ? I::parseNode($node)->children()[0] : dom_import_simplexml($node)->textContent);
    });
}