aboutsummaryrefslogtreecommitdiff
path: root/perl/step0_repl.pl
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-19 13:55:30 -0500
committerJoel Martin <github@martintribe.org>2014-04-19 13:57:00 -0500
commit9e5b215158a40ad983cbc22464761524845dd9bf (patch)
tree630a976d83ba43bbe78da57ea397b2d7e828b173 /perl/step0_repl.pl
parent86b689f3d7111a9fa13da389a30f3dfdf877d1a4 (diff)
downloadmal-9e5b215158a40ad983cbc22464761524845dd9bf.tar.gz
mal-9e5b215158a40ad983cbc22464761524845dd9bf.zip
Perl: add readline interface and step0_repl
Diffstat (limited to 'perl/step0_repl.pl')
-rw-r--r--perl/step0_repl.pl33
1 files changed, 33 insertions, 0 deletions
diff --git a/perl/step0_repl.pl b/perl/step0_repl.pl
new file mode 100644
index 0000000..8295cc0
--- /dev/null
+++ b/perl/step0_repl.pl
@@ -0,0 +1,33 @@
+use strict;
+use warnings;
+use readline qw(readline);
+
+# read
+sub READ {
+ my $str = shift;
+ return $str;
+}
+
+# eval
+sub EVAL {
+ my($ast, $env) = @_;
+ return $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");
+}