1
1
mirror of https://github.com/kanaka/mal.git synced 2024-09-21 18:48:12 +03:00
mal/perl/step0.5_repl.pl

34 lines
454 B
Perl
Raw Normal View History

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