madlisp/repl.php

22 lines
471 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
2020-06-06 08:31:09 +00:00
$userEnv = new MadLisp\Env('repl', $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);
}