Skip to content

Commit

Permalink
OCaml: add step 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Chouser committed Jan 30, 2015
1 parent bf51836 commit ca51c4f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions ocaml/step0_repl.ml
Original file line number Diff line number Diff line change
@@ -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 -> ()

0 comments on commit ca51c4f

Please sign in to comment.