2021-04-01 22:44:06 +02:00
|
|
|
use lib "./lib";
|
|
|
|
|
|
|
|
use Minilisp;
|
|
|
|
use Data::Dumper;
|
|
|
|
|
|
|
|
my $term = <<EOF;
|
2021-04-02 02:46:43 +02:00
|
|
|
(defun fact (n) (if (> n 1) (* n (fact (- n 1))) 1))
|
2021-04-02 01:07:23 +02:00
|
|
|
|
2021-04-02 02:46:43 +02:00
|
|
|
(write-line (fact 5))
|
2021-04-01 22:44:06 +02:00
|
|
|
EOF
|
|
|
|
|
|
|
|
my $parsed = Minilisp::compile($term);
|
|
|
|
|
|
|
|
my $ctx = {
|
|
|
|
'a' => "bar",
|
|
|
|
};
|
|
|
|
|
|
|
|
print "$term\n";
|
|
|
|
print ":= " . $parsed->($ctx) . "\n";
|