mirror of
https://github.com/kanaka/mal.git
synced 2024-11-13 01:43:50 +03:00
35 lines
461 B
PHP
35 lines
461 B
PHP
<?php
|
|
|
|
require_once 'readline.php';
|
|
|
|
// read
|
|
function READ($str) {
|
|
return $str;
|
|
}
|
|
|
|
// eval
|
|
function MAL_EVAL($ast, $env) {
|
|
return $ast;
|
|
}
|
|
|
|
// print
|
|
function MAL_PRINT($exp) {
|
|
return $exp;
|
|
}
|
|
|
|
// repl
|
|
function rep($str) {
|
|
return MAL_PRINT(MAL_EVAL(READ($str), array()));
|
|
}
|
|
|
|
// repl loop
|
|
do {
|
|
$line = mal_readline("user> ");
|
|
if ($line === NULL) { break; }
|
|
if ($line !== "") {
|
|
print(rep($line) . "\n");
|
|
}
|
|
} while (true);
|
|
|
|
?>
|