diff --git a/.gitignore b/.gitignore index 3f4f687..54687b7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,5 @@ lib/phake/builtins.php lib/pharen/*.php examples/*.php test/*.php -test/tmp ex .DS_Store diff --git a/lang.php b/lang.php index db0c1d2..08b46cb 100644 --- a/lang.php +++ b/lang.php @@ -3,7 +3,7 @@ use Pharen\Lexical as Lexical; use \Seq as Seq; use \FastSeq as FastSeq; -Lexical::$scopes['_home_scriptor_pharenlang'] = array(); +Lexical::$scopes['_Users_aarti_pharenlang'] = array(); define("SYSTEM", dirname(__FILE__)); define("LIB_PATH", (SYSTEM . "/lib/")); define("LIB_PHAREN_PATH", (SYSTEM . "/lib/pharen/")); @@ -117,11 +117,11 @@ function dec($x){ return ($x - 1); } -function _home_scriptor_pharenlang__lambdafunc2($args, $__closure_id){ +function _Users_aarti_pharenlang__lambdafunc2($args, $__closure_id){ $__splatargs = func_get_args(); $args = seq(array_slice($__splatargs, 0, count($__splatargs) - 1)); $__closure_id = last($__splatargs); - $rfs = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 104, '$rfs', isset($__closure_id)?$__closure_id:0);; + $rfs = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 104, '$rfs', isset($__closure_id)?$__closure_id:0);; $init = call_user_func_array(first($rfs), arr($args)); return reduce('\apply', $init, rest($rfs)); } @@ -129,10 +129,10 @@ function _home_scriptor_pharenlang__lambdafunc2($args, $__closure_id){ function comp(){ $fs = seq(array_slice(func_get_args(), 0)); - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 104); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 104); $rfs = reverse($fs); - Lexical::bind_lexing("_home_scriptor_pharenlang", 104, '$rfs', $rfs); - return new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc2", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id)); + Lexical::bind_lexing("_Users_aarti_pharenlang", 104, '$rfs', $rfs); + return new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc2", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id)); } function zero_or_empty__question($n, $xs){ @@ -224,14 +224,14 @@ function hashify($x){ } } -function _home_scriptor_pharenlang__lambdafunc3($pair, $hm, $__closure_id){ +function _Users_aarti_pharenlang__lambdafunc3($pair, $hm, $__closure_id){ return assoc($pair[0], $pair[1], $hm); } function hash_from_pairs($pairs){ - return reduce(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc3", Lexical::get_closure_id("_home_scriptor_pharenlang", Null)), hashify(array()), $pairs); + return reduce(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc3", Lexical::get_closure_id("_Users_aarti_pharenlang", Null)), hashify(array()), $pairs); } function force($x){ @@ -360,8 +360,8 @@ function interleave($xs, $ys){ } function zip_with($f, $xs, $ys){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 144); - Lexical::bind_lexing("_home_scriptor_pharenlang", 144, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 144); + Lexical::bind_lexing("_Users_aarti_pharenlang", 144, '$f', $f); $__condtmpvar1 = Null; if(empty__question($xs)){ @@ -392,97 +392,97 @@ function seq_rand($xs){ return $xs[rand(0, dec(count($xs)))]; } -function _home_scriptor_pharenlang__lambdafunc5($__closure_id){ - $n = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 149, '$n', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc5($__closure_id){ + $n = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 149, '$n', isset($__closure_id)?$__closure_id:0);; return cons($n, infinity(($n + 1))); } function infinity($n=0){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 149); - Lexical::bind_lexing("_home_scriptor_pharenlang", 149, '$n', $n); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 149); + Lexical::bind_lexing("_Users_aarti_pharenlang", 149, '$n', $n); - return new \PharenLazyList(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc5", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id))); + return new \PharenLazyList(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc5", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id))); } -function _home_scriptor_pharenlang__lambdafunc6($__closure_id){ - $x = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 151, '$x', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc6($__closure_id){ + $x = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 151, '$x', isset($__closure_id)?$__closure_id:0);; return cons($x, repeat($x)); } function repeat($x){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 151); - Lexical::bind_lexing("_home_scriptor_pharenlang", 151, '$x', $x); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 151); + Lexical::bind_lexing("_Users_aarti_pharenlang", 151, '$x', $x); - return new \PharenLazyList(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc6", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id))); + return new \PharenLazyList(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc6", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id))); } -function _home_scriptor_pharenlang__lambdafunc7($__closure_id){ - $f = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 153, '$f', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc7($__closure_id){ + $f = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 153, '$f', isset($__closure_id)?$__closure_id:0);; return cons($f(), repeatedly($f)); } function repeatedly($f){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 153); - Lexical::bind_lexing("_home_scriptor_pharenlang", 153, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 153); + Lexical::bind_lexing("_Users_aarti_pharenlang", 153, '$f', $f); - return new \PharenLazyList(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc7", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id))); + return new \PharenLazyList(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc7", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id))); } -function _home_scriptor_pharenlang__lambdafunc8($__closure_id){ - $init = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 155, '$init', isset($__closure_id)?$__closure_id:0);; - $f = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 155, '$f', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc8($__closure_id){ + $init = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 155, '$init', isset($__closure_id)?$__closure_id:0);; + $f = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 155, '$f', isset($__closure_id)?$__closure_id:0);; return cons($init, iterate($f, $f($init))); } function iterate($f, $init){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 155); - Lexical::bind_lexing("_home_scriptor_pharenlang", 155, '$f', $f); - Lexical::bind_lexing("_home_scriptor_pharenlang", 155, '$init', $init); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 155); + Lexical::bind_lexing("_Users_aarti_pharenlang", 155, '$f', $f); + Lexical::bind_lexing("_Users_aarti_pharenlang", 155, '$init', $init); - return new \PharenLazyList(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc8", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id))); + return new \PharenLazyList(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc8", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id))); } -function _home_scriptor_pharenlang__lambdafunc9($__closure_id){ - $xs = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 157, '$xs', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc9($__closure_id){ + $xs = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 157, '$xs', isset($__closure_id)?$__closure_id:0);; return concat($xs, cycle($xs)); } function cycle($xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 157); - Lexical::bind_lexing("_home_scriptor_pharenlang", 157, '$xs', $xs); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 157); + Lexical::bind_lexing("_Users_aarti_pharenlang", 157, '$xs', $xs); - return new \PharenLazyList(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc9", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id))); + return new \PharenLazyList(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc9", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id))); } -function _home_scriptor_pharenlang__lambdafunc10($__closure_id){ - $f = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 159, '$f', isset($__closure_id)?$__closure_id:0);; - $xs = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 159, '$xs', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc10($__closure_id){ + $f = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 159, '$f', isset($__closure_id)?$__closure_id:0);; + $xs = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 159, '$xs', isset($__closure_id)?$__closure_id:0);; $new_xs = map($f, $xs); return concat($xs, cycle_with($f, $new_xs)); } function cycle_with($f, $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 159); - Lexical::bind_lexing("_home_scriptor_pharenlang", 159, '$f', $f); - Lexical::bind_lexing("_home_scriptor_pharenlang", 159, '$xs', $xs); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 159); + Lexical::bind_lexing("_Users_aarti_pharenlang", 159, '$f', $f); + Lexical::bind_lexing("_Users_aarti_pharenlang", 159, '$xs', $xs); - return new \PharenLazyList(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc10", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id))); + return new \PharenLazyList(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc10", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id))); } @@ -526,42 +526,42 @@ function apply($f){ return call_user_func_array($name, $args_array); } -function _home_scriptor_pharenlang__lambdafunc11($x, $y, $__closure_id){ - $f = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 166, '$f', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc11($x, $y, $__closure_id){ + $f = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 166, '$f', isset($__closure_id)?$__closure_id:0);; return $f($y, $x); } function flip($f){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 166); - Lexical::bind_lexing("_home_scriptor_pharenlang", 166, '$f', $f); - return new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc11", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id)); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 166); + Lexical::bind_lexing("_Users_aarti_pharenlang", 166, '$f', $f); + return new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc11", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id)); } -function _home_scriptor_pharenlang__lambdafunc13($f, $__closure_id){ - $args = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 169, '$args', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc13($f, $__closure_id){ + $args = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 169, '$args', isset($__closure_id)?$__closure_id:0);; return apply($f, $args); } -function _home_scriptor_pharenlang__lambdafunc12($args, $__closure_id){ +function _Users_aarti_pharenlang__lambdafunc12($args, $__closure_id){ $__splatargs = func_get_args(); $args = seq(array_slice($__splatargs, 0, count($__splatargs) - 1)); $__closure_id = last($__splatargs); - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 169); - Lexical::bind_lexing("_home_scriptor_pharenlang", 169, '$args', $args); - $fs = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 168, '$fs', isset($__closure_id)?$__closure_id:0);; + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 169); + Lexical::bind_lexing("_Users_aarti_pharenlang", 169, '$args', $args); + $fs = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 168, '$fs', isset($__closure_id)?$__closure_id:0);; - return map(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc13", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id)), $fs); + return map(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc13", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id)), $fs); } function juxt(){ $fs = seq(array_slice(func_get_args(), 0)); - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 168); - Lexical::bind_lexing("_home_scriptor_pharenlang", 168, '$fs', $fs); - return new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc12", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id)); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 168); + Lexical::bind_lexing("_Users_aarti_pharenlang", 168, '$fs', $fs); + return new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc12", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id)); } function concat($xs1, $xs2){ @@ -580,8 +580,8 @@ function into($to, $from){ } function reduce($f, $acc, $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 173); - Lexical::bind_lexing("_home_scriptor_pharenlang", 173, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 173); + Lexical::bind_lexing("_Users_aarti_pharenlang", 173, '$f', $f); while(1){ if(empty__question($xs)){ return $acc; @@ -594,8 +594,8 @@ function reduce($f, $acc, $xs){ } function reduce1($f, $acc,Seq $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 174); - Lexical::bind_lexing("_home_scriptor_pharenlang", 174, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 174); + Lexical::bind_lexing("_Users_aarti_pharenlang", 174, '$f', $f); while(1){ $__inline_result0 = Null; if(($xs instanceof \PharenEmptyList)){ @@ -616,8 +616,8 @@ function reduce1($f, $acc,Seq $xs){ } function reduce2($f, $acc,FastSeq $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 175); - Lexical::bind_lexing("_home_scriptor_pharenlang", 175, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 175); + Lexical::bind_lexing("_Users_aarti_pharenlang", 175, '$f', $f); while(1){ if($xs->length === 0){ return $acc; @@ -644,22 +644,22 @@ function reduce_fns($fns, $acc, $xs){ } } -function _home_scriptor_pharenlang__lambdafunc14($val, $acc, $__closure_id){ - $new_val_func = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 177, '$new_val_func', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc14($val, $acc, $__closure_id){ + $new_val_func = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 177, '$new_val_func', isset($__closure_id)?$__closure_id:0);; return ($acc . $new_val_func($val)); } function reduce_to_str($new_val_func, $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 177); - Lexical::bind_lexing("_home_scriptor_pharenlang", 177, '$new_val_func', $new_val_func); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 177); + Lexical::bind_lexing("_Users_aarti_pharenlang", 177, '$new_val_func', $new_val_func); - return reduce(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc14", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id)), "", $xs); + return reduce(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc14", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id)), "", $xs); } function reduce_pairs($f, $acc, $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 179); - Lexical::bind_lexing("_home_scriptor_pharenlang", 179, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 179); + Lexical::bind_lexing("_Users_aarti_pharenlang", 179, '$f', $f); while(1){ if(empty__question($xs)){ return $acc; @@ -672,8 +672,8 @@ function reduce_pairs($f, $acc, $xs){ } function map($f, $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 180); - Lexical::bind_lexing("_home_scriptor_pharenlang", 180, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 180); + Lexical::bind_lexing("_Users_aarti_pharenlang", 180, '$f', $f); if(empty__question($xs)){ return $xs; } @@ -699,8 +699,8 @@ function filter($f, $coll){ } function until($f, $xs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 183); - Lexical::bind_lexing("_home_scriptor_pharenlang", 183, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 183); + Lexical::bind_lexing("_Users_aarti_pharenlang", 183, '$f', $f); while(1){ Null; @@ -716,8 +716,8 @@ function until($f, $xs){ } function map_indexed($f, $xs, $idx=0){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 184); - Lexical::bind_lexing("_home_scriptor_pharenlang", 184, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 184); + Lexical::bind_lexing("_Users_aarti_pharenlang", 184, '$f', $f); if(empty__question($xs)){ return \PharenVector::create_from_array(array()); } @@ -726,17 +726,17 @@ function map_indexed($f, $xs, $idx=0){ } } -function _home_scriptor_pharenlang__lambdafunc15($pair, $acc, $__closure_id){ - $f = Lexical::get_lexical_binding('_home_scriptor_pharenlang', 185, '$f', isset($__closure_id)?$__closure_id:0);; +function _Users_aarti_pharenlang__lambdafunc15($pair, $acc, $__closure_id){ + $f = Lexical::get_lexical_binding('_Users_aarti_pharenlang', 185, '$f', isset($__closure_id)?$__closure_id:0);; return append($f($pair[0], $pair[1]), $acc); } function map_pairs($f, $pairs){ - $__scope_id = Lexical::init_closure("_home_scriptor_pharenlang", 185); - Lexical::bind_lexing("_home_scriptor_pharenlang", 185, '$f', $f); + $__scope_id = Lexical::init_closure("_Users_aarti_pharenlang", 185); + Lexical::bind_lexing("_Users_aarti_pharenlang", 185, '$f', $f); - return reduce_pairs(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc15", Lexical::get_closure_id("_home_scriptor_pharenlang", $__scope_id)), \PharenVector::create_from_array(array()), $pairs); + return reduce_pairs(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc15", Lexical::get_closure_id("_Users_aarti_pharenlang", $__scope_id)), \PharenVector::create_from_array(array()), $pairs); } function repling(){ @@ -770,7 +770,7 @@ static function set_multi($multi_name, $pattern, $f){ } MultiManager::$multis = hashify(array()); -function _home_scriptor_pharenlang__lambdafunc16($val, $__closure_id){ +function _Users_aarti_pharenlang__lambdafunc16($val, $__closure_id){ Null; if(is_string($val)){ @@ -801,7 +801,7 @@ function _home_scriptor_pharenlang__lambdafunc16($val, $__closure_id){ function multi_serialize_args($vals){ - return reduce_to_str(new \PharenLambda("\\_home_scriptor_pharenlang__lambdafunc16", Lexical::get_closure_id("_home_scriptor_pharenlang", Null)), $vals); + return reduce_to_str(new \PharenLambda("\\_Users_aarti_pharenlang__lambdafunc16", Lexical::get_closure_id("_Users_aarti_pharenlang", Null)), $vals); } function multi_serialize_pattern($pattern){ diff --git a/test/tests/function_definition.phn b/test/tests/function_definition.phn index bcf3e23..9390046 100644 --- a/test/tests/function_definition.phn +++ b/test/tests/function_definition.phn @@ -2,14 +2,23 @@ 1) (check (one-expr) 1) +(local foo #one-expr) +(check ($foo) 1) + (fn one-arg (a) (. "Argument is " a)) (check (one-arg "this") "Argument is this") +(local foo2 #one-arg) +(check ($foo2 "this") "Argument is this") + (fn add-two-args (a b) (+ a b)) (check (add-two-args 133 123) 256) +(local foo3 #add-two-args) +(check ($foo3 133 123) 256) + (fn two-exprs (a b) (one-arg a) (one-arg b)) diff --git a/test/tmp/bindings.php b/test/tmp/bindings.php new file mode 100644 index 0000000..500fb2e --- /dev/null +++ b/test/tmp/bindings.php @@ -0,0 +1,16 @@ += 100)){ + return $__dotimes_result; + } + $y = ($x + 100); + $__dotmpvar3 = check($y, ($x + 100)); + $__dotimes_result = $__dotmpvar3; + $__tailrecursetmp0 = inc($x); + $x = $__tailrecursetmp0; + } +} + + +$__tmpfuncname15 = new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc31", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", $__scope_id)); +$__tmpfuncname15(0, NULL); +check(zero__question(0), TRUE); +check(zero__question(1), FALSE); +check(pos__question(1), TRUE); +check(pos__question(-1), FALSE); +check(neg__question(-1), TRUE); +check(neg__question(1), FALSE); +check(odd__question((100 / 2)), FALSE); +check(even__question((100 / 2)), TRUE); +check(str("a", "b"), "ab"); +check(identity(1), 1); +check(inc(1), 2); +check(dec(2), 1); + $__scope_id = Lexical::init_closure("_Users_aarti_pharen_test_tmplang_functions", 322); +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc32($x, $__closure_id){ + return (1 + $x); +} + + +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc33($y, $__closure_id){ + return (2 + $y); +} + + +$fnx = comp(new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc32", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc33", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null))); + Lexical::bind_lexing("_Users_aarti_pharen_test_tmplang_functions", 322, '$fnx', $fnx); +check($fnx(1), 4); +check(zero_or_empty__question(1, \PharenVector::create_from_array(array())), TRUE); +check(zero_or_empty__question(0, \PharenVector::create_from_array(array(1, 2))), TRUE); +check(empty__question(\PharenVector::create_from_array(array())), TRUE); +check(empty__question(\PharenVector::create_from_array(array(1))), FALSE); +check(seq__question(\PharenVector::create_from_array(array(1, 2, 3))), TRUE); +check(sequential__question(\PharenVector::create_from_array(array(1, 2, 3))), TRUE); +check(seq__question(seq(\PharenVector::create_from_array(array(1, 2, 3)))), TRUE); +$__listAcessTmpVar2 = hashify(hashify(array('\a' => 1))); +check($__listAcessTmpVar2['\a'], 1); +check(arr(\PharenVector::create_from_array(array(1, 2, 3))), array(1, 2, 3)); +check(first(rest(\PharenVector::create_from_array(array(1, 2)))), 2); +check(cons(0, \PharenVector::create_from_array(array(1, 2, 3))), \PharenVector::create_from_array(array(0, 1, 2, 3))); +$__listAcessTmpVar3 = assoc('\a', 1, hashify(array())); +check($__listAcessTmpVar3['\a'], 1); +check(get('\a', hashify(array('\a' => 1))), 1); +check(take(2, \PharenVector::create_from_array(array(0, 1, 2))), \PharenVector::create_from_array(array(0, 1))); +check(drop(2, \PharenVector::create_from_array(array(0, 1, 2))), \PharenVector::create_from_array(array(2))); +check(reverse(\PharenVector::create_from_array(array(1, 2, 3))), \PharenVector::create_from_array(array(3, 2, 1))); +check(interpose("-", \PharenVector::create_from_array(array(1, 2, 3))), \PharenVector::create_from_array(array(1, "-", 2, "-", 3))); +check(partition(3, \PharenVector::create_from_array(array(1, 2, 3, 4, 5, 6, 7, 8, 9))), \PharenVector::create_from_array(array(\PharenVector::create_from_array(array(1, 2, 3)), \PharenVector::create_from_array(array(4, 5, 6)), \PharenVector::create_from_array(array(7, 8, 9))))); +check(interleave(\PharenVector::create_from_array(array(1, 2, 3)), \PharenVector::create_from_array(array(4, 3, 6))), \PharenVector::create_from_array(array(1, 4, 2, 3, 3, 6))); +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc34($a, $b, $__closure_id){ + return ($a + $b); +} + + +check(zip_with(new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc34", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), \PharenVector::create_from_array(array(1, 2, 3)), \PharenVector::create_from_array(array(4, 5, 6))), \PharenVector::create_from_array(array(5, 7, 9))); +check(seq_join(\PharenVector::create_from_array(array(1, 2, 3, 4, 5)), ","), "1,2,3,4,5"); +check((infinity() instanceof PharenLazyList), TRUE); +check((repeat(\PharenVector::create_from_array(array(1, 2, 3))) instanceof PharenLazyList), TRUE); +function _Users_aarti_pharen_test_tmplang_functions__partial2($arg0, $__closure_id){ + $a = Lexical::get_lexical_binding('_Users_aarti_pharen_test_tmplang_functions', 326, '$a', isset($__closure_id)?$__closure_id:0);; +return ($a + $arg0); +} + +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc35($a, $__closure_id){ + $__scope_id = Lexical::init_closure("_Users_aarti_pharen_test_tmplang_functions", 326); + Lexical::bind_lexing("_Users_aarti_pharen_test_tmplang_functions", 326, '$a', $a); + + + return new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial2', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", $__scope_id)); +} + + +check((repeatedly(new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc35", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null))) instanceof PharenLazyList), TRUE); +function _Users_aarti_pharen_test_tmplang_functions__partial3($arg0, $__closure_id){ + $a = Lexical::get_lexical_binding('_Users_aarti_pharen_test_tmplang_functions', 328, '$a', isset($__closure_id)?$__closure_id:0);; +return ($a + $arg0); +} + +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc36($a, $__closure_id){ + $__scope_id = Lexical::init_closure("_Users_aarti_pharen_test_tmplang_functions", 328); + Lexical::bind_lexing("_Users_aarti_pharen_test_tmplang_functions", 328, '$a', $a); + + + return new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial3', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", $__scope_id)); +} + + +check((iterate(new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc36", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), 100) instanceof PharenLazyList), TRUE); +check((cycle(\PharenVector::create_from_array(array(1, 2, 3))) instanceof PharenLazyList), TRUE); +function _Users_aarti_pharen_test_tmplang_functions__partial4($arg0, $__closure_id){ + return (1 + $arg0); +} + + +check((cycle_with(new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial4', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), \PharenVector::create_from_array(array(1, 2, 3))) instanceof PharenLazyList), TRUE); +check(vals(\PharenVector::create_from_array(array(1, 2, 3))), \PharenVector::create_from_array(array(1, 2, 3))); +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc37($a, $b, $__closure_id){ + return ($a + $b); +} + + +check(apply(new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc37", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), 1, 2), 3); +function _Users_aarti_pharen_test_tmplang_functions__lambdafunc38($a, $b, $__closure_id){ + return \PharenVector::create_from_array(array($a, $b)); +} + + +check(apply(flip(new \PharenLambda("\\_Users_aarti_pharen_test_tmplang_functions__lambdafunc38", Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null))), 1, 2), \PharenVector::create_from_array(array(2, 1))); +function _Users_aarti_pharen_test_tmplang_functions__partial5($arg0, $__closure_id){ + return (1 + $arg0); +} + + +function _Users_aarti_pharen_test_tmplang_functions__partial6($arg0, $__closure_id){ + return (2 + $arg0); +} + + +check(apply(juxt(new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial5', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial6', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null))), 1), \PharenVector::create_from_array(array(2, 3))); +check(concat(\PharenVector::create_from_array(array(1)), \PharenVector::create_from_array(array(2))), \PharenVector::create_from_array(array(1, 2))); +check(into(\PharenVector::create_from_array(array(3)), \PharenVector::create_from_array(array(1, 2, 3, 4, 5))), \PharenVector::create_from_array(array(5, 4, 3, 2, 1, 3))); +function _Users_aarti_pharen_test_tmplang_functions__partial7($arg0, $__closure_id){ + return (1 + $arg0); +} + + +check(reduce(new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial7', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), 0, \PharenVector::create_from_array(array(1, 2, 3, 4, 5))), 6); +function _Users_aarti_pharen_test_tmplang_functions__partial8($arg0, $__closure_id){ + return (1 + $arg0); +} + + +check(reduce_to_str(new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial8', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), \PharenVector::create_from_array(array(1, 2, 3))), "234"); +function _Users_aarti_pharen_test_tmplang_functions__partial9($arg0, $__closure_id){ + return (1 + $arg0); +} + + +check(map(new \PharenLambda('\\_Users_aarti_pharen_test_tmplang_functions__partial9', Lexical::get_closure_id("_Users_aarti_pharen_test_tmplang_functions", Null)), \PharenVector::create_from_array(array(1, 2, 3))), \PharenVector::create_from_array(array(2, 3, 4))); diff --git a/test/tmp/lazy.php b/test/tmp/lazy.php new file mode 100644 index 0000000..655d001 --- /dev/null +++ b/test/tmp/lazy.php @@ -0,0 +1,20 @@ + "Haskell", "imperative" => "C", "wtf" => "Pharen"))), 3); +$__listAcessTmpVar1 = hashify(array("functional" => "Haskell", "imperative" => "C", "wtf" => "Pharen")); +check($__listAcessTmpVar1["wtf"], "Pharen"); +$dct = hashify(array("functional" => "Haskell", "imperative" => "C", "wtf" => "Pharen")); +Lexical::bind_lexing("_Users_aarti_pharen_test_tmplists_and_dicts", 263, '$dct', $dct); +check($dct["functional"], "Haskell"); +$new_dct = assoc("logic", "Prolog", $dct); +Lexical::bind_lexing("_Users_aarti_pharen_test_tmplists_and_dicts", 263, '$new_dct', $new_dct); +check($new_dct["logic"], "Prolog"); +$__tmpfuncname6 = hashify(array("foo" => "bar")); +check($__tmpfuncname6("foo"), "bar"); +check($dct("imperative"), "C"); diff --git a/test/tmp/literals.php b/test/tmp/literals.php new file mode 100644 index 0000000..81a973c --- /dev/null +++ b/test/tmp/literals.php @@ -0,0 +1,14 @@ + 2, "foo" => "bar")), hashify(array("foo" => "bar", 1 => 2))); +check('\strstr', "\\strstr"); +check('\foo_bar_baz', "\\foo_bar_baz"); diff --git a/test/tmp/macros.php b/test/tmp/macros.php new file mode 100644 index 0000000..33639f2 --- /dev/null +++ b/test/tmp/macros.php @@ -0,0 +1,35 @@ + $arg0); +} + + +check(array_filter(arr(\PharenVector::create_from_array(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))), new \PharenLambda('\\_Users_aarti_pharen_test_tmpphp_interop__partial11', Lexical::get_closure_id("_Users_aarti_pharen_test_tmpphp_interop", Null))), array(1, 2, 3)); +function _Users_aarti_pharen_test_tmpphp_interop__lambdafunc40($x, $__closure_id){ + return (4 > $x); +} + + +check(array_filter(arr(\PharenVector::create_from_array(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))), new \PharenLambda("\\_Users_aarti_pharen_test_tmpphp_interop__lambdafunc40", Lexical::get_closure_id("_Users_aarti_pharen_test_tmpphp_interop", Null))), array(1, 2, 3)); +check((array(1, 2, 3) == array(1, 2, 3)), TRUE); +check(eq(array(1, 2, 3), array(1, 2, 3)), TRUE); +check(eq(\PharenVector::create_from_array(array(1, 2, 3)), \PharenVector::create_from_array(array(1, 2, 3))), TRUE); +check(eq(\PharenVector::create_from_array(array(1, 2, 3)), array(1, 2, 3)), TRUE); +check((\PharenVector::create_from_array(array(1, 2, 3)) == array(1, 2, 3)), FALSE); + $__scope_id = Lexical::init_closure("_Users_aarti_pharen_test_tmpphp_interop", 343); +$sum = 100; + Lexical::bind_lexing("_Users_aarti_pharen_test_tmpphp_interop", 343, '$sum', $sum); +function _Users_aarti_pharen_test_tmpphp_interop__lambdafunc41($x, $__closure_id){ + $sum = Lexical::get_lexical_binding('_Users_aarti_pharen_test_tmpphp_interop', 343, '$sum', isset($__closure_id)?$__closure_id:0);; + return ($x + $sum); +} + + +check(array_map(new \PharenLambda("\\_Users_aarti_pharen_test_tmpphp_interop__lambdafunc41", Lexical::get_closure_id("_Users_aarti_pharen_test_tmpphp_interop", $__scope_id)), arr(\PharenVector::create_from_array(array(1, 2, 3)))), array(101, 102, 103)); +$sum2 = 101; +Lexical::bind_lexing("_Users_aarti_pharen_test_tmpphp_interop", 338, '$sum2', $sum2); +function _Users_aarti_pharen_test_tmpphp_interop__lambdafunc42($x, $__closure_id){ + $sum2 = Lexical::get_lexical_binding('_Users_aarti_pharen_test_tmpphp_interop', 338, '$sum2', isset($__closure_id)?$__closure_id:0);; + return ($x + $sum2); +} + + +check(array_map(new \PharenLambda("\\_Users_aarti_pharen_test_tmpphp_interop__lambdafunc42", Lexical::get_closure_id("_Users_aarti_pharen_test_tmpphp_interop", $__scope_id)), arr(\PharenVector::create_from_array(array(1, 2, 3)))), array(102, 103, 104)); diff --git a/test/tmp/plambda.php b/test/tmp/plambda.php new file mode 100644 index 0000000..d90799c --- /dev/null +++ b/test/tmp/plambda.php @@ -0,0 +1,56 @@ +