diff options
| author | Joel Martin <github@martintribe.org> | 2014-12-18 20:33:49 -0600 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2015-01-09 16:16:50 -0600 |
| commit | b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c (patch) | |
| tree | f4d977ed220e9a3f665cfbf4f68770a81e4c2095 /php/stepA_interop.php | |
| parent | aaba249304b184e12e2445ab22d66df1f39a51a5 (diff) | |
| download | mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.tar.gz mal-b8ee29b22fbaa7a01f2754b4d6dd9af52e02017c.zip | |
All: add keywords.
Also, fix nth and count to match cloure.
Diffstat (limited to 'php/stepA_interop.php')
| -rw-r--r-- | php/stepA_interop.php | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/php/stepA_interop.php b/php/stepA_interop.php index f38656f..8c67c66 100644 --- a/php/stepA_interop.php +++ b/php/stepA_interop.php @@ -35,13 +35,13 @@ function quasiquote($ast) { function is_macro_call($ast, $env) { return is_pair($ast) && _symbol_Q($ast[0]) && - $env->find($ast[0]->value) && - $env->get($ast[0]->value)->ismacro; + $env->find($ast[0]) && + $env->get($ast[0])->ismacro; } function macroexpand($ast, $env) { while (is_macro_call($ast, $env)) { - $mac = $env->get($ast[0]->value); + $mac = $env->get($ast[0]); $args = array_slice($ast->getArrayCopy(),1); $ast = $mac->apply($args); } @@ -50,7 +50,7 @@ function macroexpand($ast, $env) { function eval_ast($ast, $env) { if (_symbol_Q($ast)) { - return $env->get($ast->value); + return $env->get($ast); } elseif (_sequential_Q($ast)) { if (_list_Q($ast)) { $el = _list(); @@ -87,12 +87,12 @@ function MAL_EVAL($ast, $env) { switch ($a0v) { case "def!": $res = MAL_EVAL($ast[2], $env); - return $env->set($ast[1]->value, $res); + return $env->set($ast[1], $res); case "let*": $a1 = $ast[1]; $let_env = new Env($env); for ($i=0; $i < count($a1); $i+=2) { - $let_env->set($a1[$i]->value, MAL_EVAL($a1[$i+1], $let_env)); + $let_env->set($a1[$i], MAL_EVAL($a1[$i+1], $let_env)); } $ast = $ast[2]; $env = $let_env; @@ -105,7 +105,7 @@ function MAL_EVAL($ast, $env) { case "defmacro!": $func = MAL_EVAL($ast[2], $env); $func->ismacro = true; - return $env->set($ast[1]->value, $func); + return $env->set($ast[1], $func); case "macroexpand": return macroexpand($ast[1], $env); case "php*": @@ -174,16 +174,16 @@ function rep($str) { // core.php: defined using PHP foreach ($core_ns as $k=>$v) { - $repl_env->set($k, _function($v)); + $repl_env->set(_symbol($k), _function($v)); } -$repl_env->set('eval', _function(function($ast) { +$repl_env->set(_symbol('eval'), _function(function($ast) { global $repl_env; return MAL_EVAL($ast, $repl_env); })); $_argv = _list(); for ($i=2; $i < count($argv); $i++) { $_argv->append($argv[$i]); } -$repl_env->set('*ARGV*', $_argv); +$repl_env->set(_symbol('*ARGV*'), $_argv); // core.mal: defined using the language itself rep("(def! *host-language* \"php\")"); |
