separate coreLibs and userLibs for LispFactory

This commit is contained in:
Pekka Laiho 2020-06-17 18:31:13 +07:00
parent 90a9b3aa53
commit 871df1f691

View File

@ -3,7 +3,7 @@ namespace MadLisp;
class LispFactory
{
public function make(array $libraries = []): Lisp
public function make(array $coreLibs = [], array $userLibs = []): Lisp
{
$tokenizer = new Tokenizer();
$reader = new Reader();
@ -50,14 +50,19 @@ class LispFactory
(new Lib\Time())->register($env);
(new Lib\Types())->register($env);
// Register additional libraries
foreach ($libraries as $lib) {
// Register additional libs for root env
foreach ($coreLibs as $lib) {
$lib->register($env);
}
// User environment
$env = new Env('user', $env);
// Register additional libs for user env
foreach ($userLibs as $lib) {
$lib->register($env);
}
return new Lisp($tokenizer, $reader, $eval, $printer, $env);
}
}