aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-01-21 20:53:51 -0500
committerChouser <chouser@n01se.net>2015-01-30 12:54:42 -0500
commitca51c4f77235d8f9b8606ebc8c255778c83c9050 (patch)
tree192a8bb9792e92ea30a3f687aaadbe7094cd74e3
parentbf518367d0706b2fa727acc5326230ef8d3c812b (diff)
downloadmal-ca51c4f77235d8f9b8606ebc8c255778c83c9050.tar.gz
mal-ca51c4f77235d8f9b8606ebc8c255778c83c9050.zip
OCaml: add step 0
-rw-r--r--.gitignore2
-rw-r--r--Makefile4
-rw-r--r--ocaml/step0_repl.ml23
3 files changed, 28 insertions, 1 deletions
diff --git a/.gitignore b/.gitignore
index 34b9b72..44ee760 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,8 @@ go/step*
go/mal
java/target/
java/dependency-reduced-pom.xml
+ocaml/*.cmi
+ocaml/*.swp
rust/target/
rust/mal
rust/Cargo.lock
diff --git a/Makefile b/Makefile
index 572bd25..b3d6278 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ PYTHON = python
#
IMPLS = bash c clojure coffee cs go haskell java js lua make mal \
- perl php ps python r racket ruby rust scala vb
+ ocaml perl php ps python r racket ruby rust scala vb
step0 = step0_repl
step1 = step1_read_print
@@ -60,6 +60,7 @@ js_STEP_TO_PROG = js/$($(1)).js
lua_STEP_TO_PROG = lua/$($(1)).lua
make_STEP_TO_PROG = make/$($(1)).mk
mal_STEP_TO_PROG = mal/$($(1)).mal
+ocaml_STEP_TO_PROG = ocaml/$($(1)).ml
perl_STEP_TO_PROG = perl/$($(1)).pl
php_STEP_TO_PROG = php/$($(1)).php
ps_STEP_TO_PROG = ps/$($(1)).ps
@@ -84,6 +85,7 @@ js_RUNSTEP = node ../$(2) $(3)
lua_RUNSTEP = ../$(2) $(3)
make_RUNSTEP = make -f ../$(2) $(3)
mal_RUNSTEP = $(call $(MAL_IMPL)_RUNSTEP,$(1),$(call $(MAL_IMPL)_STEP_TO_PROG,stepA),../$(2),") #"
+ocaml_RUNSTEP = ocaml ../$(2) $(3)
perl_RUNSTEP = perl ../$(2) --raw $(3)
php_RUNSTEP = php ../$(2) $(3)
ps_RUNSTEP = $(4)gs -q -I./ -dNODISPLAY -- ../$(2) $(3)$(4)
diff --git a/ocaml/step0_repl.ml b/ocaml/step0_repl.ml
new file mode 100644
index 0000000..e3478f7
--- /dev/null
+++ b/ocaml/step0_repl.ml
@@ -0,0 +1,23 @@
+(*
+ To try things at the ocaml repl:
+ rlwrap ocaml
+
+ To see type signatures of all functions:
+ ocamlc -i step0_repl.ml
+
+ To run the program:
+ ocaml step0_repl.ml
+*)
+
+let read str = str
+let eval ast any = ast
+let print exp = exp
+let rep str = print (eval (read str) "")
+
+let rec main =
+ try
+ while true do
+ print_string "user> ";
+ print_endline (rep (read_line ()));
+ done
+ with End_of_file -> ()