diff options
| author | Joel Martin <github@martintribe.org> | 2014-03-24 16:32:24 -0500 |
|---|---|---|
| committer | Joel Martin <github@martintribe.org> | 2014-03-24 16:32:24 -0500 |
| commit | 3169070063b2cb877200117ebb384269d73bcb93 (patch) | |
| tree | 23de3db1ea5c37afd21a45b6ed7771f56a08c0c4 /php/step0_repl.php | |
| download | mal-3169070063b2cb877200117ebb384269d73bcb93.tar.gz mal-3169070063b2cb877200117ebb384269d73bcb93.zip | |
Current state of mal for Clojure West lighting talk.
Diffstat (limited to 'php/step0_repl.php')
| -rw-r--r-- | php/step0_repl.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/php/step0_repl.php b/php/step0_repl.php new file mode 100644 index 0000000..64b086b --- /dev/null +++ b/php/step0_repl.php @@ -0,0 +1,33 @@ +<?php + +require_once 'readline.php'; + +// read +function READ($str) { + return $str; +} + +// eval +function MAL_EVAL($ast, $env) { + return eval($ast); +} + +// print +function MAL_PRINT($exp) { + return var_export($exp, true) . "\n"; +} + +// repl +function rep($str) { + return MAL_PRINT(MAL_EVAL(READ($str), array())); +} + +do { + $line = mal_readline("user> "); + if ($line === NULL) { break; } + if (!empty($line)) { + print(rep($line)); + } +} while (true); + +?> |
