1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-20 10:07:45 +03:00
mal/perl/step0.5_repl.pl
Joel Martin b8ee29b22f All: add keywords.
Also, fix nth and count to match cloure.
2015-01-09 16:16:50 -06:00

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");
}