madlisp/bootstrap.php

30 lines
815 B
PHP
Raw Normal View History

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();
2020-06-06 08:31:09 +00:00
$eval = new MadLisp\Evaller($tokenizer, $reader);
2020-05-30 11:47:54 +00:00
$printer = new MadLisp\Printer();
$lisp = new MadLisp\Lisp($tokenizer, $reader, $eval, $printer);
// Environment
2020-06-06 08:31:09 +00:00
$env = new MadLisp\Env('root');
2020-05-28 04:55:58 +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-03 12:57:58 +00:00
(new MadLisp\Lib\IO())->register($env);
2020-06-02 02:51:21 +00:00
(new MadLisp\Lib\Math())->register($env);
2020-06-02 11:03:05 +00:00
(new MadLisp\Lib\Strings())->register($env);
2020-06-03 11:15:36 +00:00
(new MadLisp\Lib\Time())->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
}