aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-01-28 13:13:44 -0500
committerChouser <chouser@n01se.net>2015-01-30 12:54:43 -0500
commit776cf577064c2676e33987546f10c2be80b26344 (patch)
treeea9739cb9d4ba38dbd605864399677c21b6f6933
parentf64fac7bd1bcdfb0061dc983be4bd578f6d55856 (diff)
downloadmal-776cf577064c2676e33987546f10c2be80b26344.tar.gz
mal-776cf577064c2676e33987546f10c2be80b26344.zip
Ocaml: Finish adding step 6
-rw-r--r--ocaml/Makefile2
-rw-r--r--ocaml/reader.ml9
2 files changed, 9 insertions, 2 deletions
diff --git a/ocaml/Makefile b/ocaml/Makefile
index 299b2c4..ced6df4 100644
--- a/ocaml/Makefile
+++ b/ocaml/Makefile
@@ -1,5 +1,5 @@
STEPS = step0_repl.ml step1_read_print.ml step2_eval.ml step3_env.ml \
- step4_if_fn_do.ml step5_tco.ml
+ step4_if_fn_do.ml step5_tco.ml step6_file.ml
MODULES = types.ml reader.ml printer.ml env.ml core.ml
LIBS = str.cmxa
MAL_LIB = mal_lib.cmxa
diff --git a/ocaml/reader.ml b/ocaml/reader.ml
index 0bb4328..36f0b2a 100644
--- a/ocaml/reader.ml
+++ b/ocaml/reader.ml
@@ -1,10 +1,17 @@
module T = Types.Types
(* ^file ^module *)
+let slurp filename =
+ let chan = open_in filename in
+ let b = Buffer.create 27 in
+ Buffer.add_channel b chan (in_channel_length chan) ;
+ close_in chan ;
+ Buffer.contents b
+
let find_re re str =
List.map (function | Str.Delim x -> x | Str.Text x -> "impossible!")
(List.filter (function | Str.Delim x -> true | Str.Text x -> false)
- (Str.full_split re str)) ;;
+ (Str.full_split re str))
let gsub re f str =
String.concat