ability to give custom env into readEval function

This commit is contained in:
Pekka Laiho 2022-07-04 15:55:38 +07:00
parent 9aa9d4b20f
commit 34bb3fea8a

View File

@ -39,13 +39,13 @@ class Lisp
return $this->printer->pstr($value, $printReadable);
}
public function readEval(string $input)
public function readEval(string $input, ?Env $customEnv = null)
{
$tokens = $this->tokenizer->tokenize($input);
$expr = $this->reader->read($tokens);
return $this->eval->eval($expr, $this->env);
return $this->eval->eval($expr, $customEnv ? $customEnv : $this->env);
}
// read, eval, print