2020-05-28 04:55:58 +00:00
|
|
|
<?php
|
|
|
|
require('vendor/autoload.php');
|
|
|
|
|
2020-05-30 11:47:54 +00:00
|
|
|
function ml_get_lisp(): array
|
2020-05-28 04:55:58 +00:00
|
|
|
{
|
2020-05-30 11:47:54 +00:00
|
|
|
$tokenizer = new MadLisp\Tokenizer();
|
|
|
|
$reader = new MadLisp\Reader();
|
|
|
|
$eval = new MadLisp\Evaller();
|
|
|
|
$printer = new MadLisp\Printer();
|
|
|
|
|
|
|
|
$lisp = new MadLisp\Lisp($tokenizer, $reader, $eval, $printer);
|
|
|
|
|
2020-05-31 14:16:20 +00:00
|
|
|
// Environment
|
2020-05-28 04:55:58 +00:00
|
|
|
$env = new MadLisp\Env();
|
|
|
|
|
2020-05-31 14:16:20 +00:00
|
|
|
// Register core functions
|
|
|
|
$lisp->register($env);
|
|
|
|
|
|
|
|
// Register libraries
|
2020-06-02 02:51:21 +00:00
|
|
|
(new MadLisp\Lib\Collections())->register($env);
|
2020-05-31 12:02:21 +00:00
|
|
|
(new MadLisp\Lib\Compare())->register($env);
|
2020-06-02 02:51:21 +00:00
|
|
|
(new MadLisp\Lib\Math())->register($env);
|
2020-05-31 12:16:40 +00:00
|
|
|
(new MadLisp\Lib\Types())->register($env);
|
2020-05-28 04:55:58 +00:00
|
|
|
|
2020-05-30 11:47:54 +00:00
|
|
|
return [$lisp, $env];
|
2020-05-28 10:10:00 +00:00
|
|
|
}
|