mirror of
https://github.com/kanaka/mal.git
synced 2024-11-10 12:47:45 +03:00
34 lines
454 B
Perl
34 lines
454 B
Perl
|
use strict;
|
||
|
use warnings FATAL => qw(all);
|
||
|
use readline qw(readline);
|
||
|
|
||
|
# read
|
||
|
sub READ {
|
||
|
my $str = shift;
|
||
|
return $str;
|
||
|
}
|
||
|
|
||
|
# eval
|
||
|
sub EVAL {
|
||
|
my($ast, $env) = @_;
|
||
|
return eval($ast);
|
||
|
}
|
||
|
|
||
|
# print
|
||
|
sub PRINT {
|
||
|
my $exp = shift;
|
||
|
return $exp;
|
||
|
}
|
||
|
|
||
|
# repl
|
||
|
sub REP {
|
||
|
my $str = shift;
|
||
|
return PRINT(EVAL(READ($str), {}));
|
||
|
}
|
||
|
|
||
|
while (1) {
|
||
|
my $line = readline("user> ");
|
||
|
if (! defined $line) { last; }
|
||
|
print(REP($line), "\n");
|
||
|
}
|