madlisp/repl.php

22 lines
463 B
PHP
Raw Normal View History

2020-05-26 08:43:59 +00:00
<?php
2020-05-28 04:55:58 +00:00
require('bootstrap.php');
2020-05-27 09:27:47 +00:00
2020-06-04 09:46:23 +00:00
list($lisp, $rootEnv) = ml_get_lisp();
// Create new env for user definitions
$userEnv = new MadLisp\Env($rootEnv);
2020-05-26 08:43:59 +00:00
while (true) {
$input = readline('> ');
try {
2020-06-04 09:46:23 +00:00
$lisp->rep($input, $userEnv);
2020-05-28 06:59:36 +00:00
} catch (MadLisp\MadLispException $ex) {
2020-05-26 08:43:59 +00:00
print('error: ' . $ex->getMessage());
2020-06-02 02:51:21 +00:00
} catch (TypeError $ex) {
print('error: invalid argument type: ' . $ex->getMessage());
2020-05-26 08:43:59 +00:00
}
print(PHP_EOL);
}