mirror of
https://github.com/peklaiho/madlisp.git
synced 2024-11-22 21:35:03 +00:00
34 lines
937 B
PHP
34 lines
937 B
PHP
<?php
|
|
require('vendor/autoload.php');
|
|
|
|
function ml_get_lisp(bool $debug): array
|
|
{
|
|
$tokenizer = new MadLisp\Tokenizer();
|
|
$reader = new MadLisp\Reader();
|
|
$printer = new MadLisp\Printer();
|
|
$eval = new MadLisp\Evaller($tokenizer, $reader, $printer);
|
|
$eval->setDebug($debug);
|
|
|
|
$lisp = new MadLisp\Lisp($tokenizer, $reader, $eval, $printer);
|
|
|
|
// Root environment
|
|
$env = new MadLisp\Env('root');
|
|
|
|
// Register core functions
|
|
$lisp->register($env);
|
|
|
|
// Register libraries
|
|
(new MadLisp\Lib\Collections())->register($env);
|
|
(new MadLisp\Lib\Compare())->register($env);
|
|
(new MadLisp\Lib\IO())->register($env);
|
|
(new MadLisp\Lib\Math())->register($env);
|
|
(new MadLisp\Lib\Strings())->register($env);
|
|
(new MadLisp\Lib\Time())->register($env);
|
|
(new MadLisp\Lib\Types())->register($env);
|
|
|
|
// User environment
|
|
$env = new MadLisp\Env('user', $env);
|
|
|
|
return [$lisp, $env];
|
|
}
|