diff --git a/.gitignore b/.gitignore index 34b9b725fb..44ee760644 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 572bd2593b..b3d6278ccf 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 0000000000..e3478f726b --- /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 -> ()