diff options
| author | Chouser <chouser@n01se.net> | 2015-01-21 20:53:51 -0500 |
|---|---|---|
| committer | Chouser <chouser@n01se.net> | 2015-01-30 12:54:42 -0500 |
| commit | ca51c4f77235d8f9b8606ebc8c255778c83c9050 (patch) | |
| tree | 192a8bb9792e92ea30a3f687aaadbe7094cd74e3 | |
| parent | bf518367d0706b2fa727acc5326230ef8d3c812b (diff) | |
| download | mal-ca51c4f77235d8f9b8606ebc8c255778c83c9050.tar.gz mal-ca51c4f77235d8f9b8606ebc8c255778c83c9050.zip | |
OCaml: add step 0
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | ocaml/step0_repl.ml | 23 |
3 files changed, 28 insertions, 1 deletions
@@ -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 @@ -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 -> () |
