aboutsummaryrefslogtreecommitdiff
path: root/ocaml/reader.ml
diff options
context:
space:
mode:
authorChouser <chouser@n01se.net>2015-01-24 00:44:51 -0500
committerChouser <chouser@n01se.net>2015-01-30 12:54:42 -0500
commitb7ffcab96166f15d6203551ffbc487da5076f92e (patch)
treedc2aa07a80dbf3f03bfa2c331bb140bd530ab21f /ocaml/reader.ml
parentf2f11f6279e1b242ba75136cd037fabdd176118a (diff)
downloadmal-b7ffcab96166f15d6203551ffbc487da5076f92e.tar.gz
mal-b7ffcab96166f15d6203551ffbc487da5076f92e.zip
Ocaml: Add read, print for vector, map
Diffstat (limited to 'ocaml/reader.ml')
-rw-r--r--ocaml/reader.ml10
1 files changed, 9 insertions, 1 deletions
diff --git a/ocaml/reader.ml b/ocaml/reader.ml
index 58e72fe..c452e05 100644
--- a/ocaml/reader.ml
+++ b/ocaml/reader.ml
@@ -54,10 +54,18 @@ and read_form all_tokens =
| "`" -> read_quote "quasiquote" tokens
| "~" -> read_quote "unquote" tokens
| "~@" -> read_quote "splice-unquote" tokens
- | "[" | "(" | "{" -> let list_reader =
+ | "(" -> let list_reader =
read_list {list_form = []; tokens = tokens} in
{form = Types.List list_reader.list_form;
tokens = list_reader.tokens}
+ | "{" -> let list_reader =
+ read_list {list_form = []; tokens = tokens} in
+ {form = Types.Map list_reader.list_form;
+ tokens = list_reader.tokens}
+ | "[" -> let list_reader =
+ read_list {list_form = []; tokens = tokens} in
+ {form = Types.Vector list_reader.list_form;
+ tokens = list_reader.tokens}
| _ -> {form = read_atom token; tokens = tokens}
let read_str str = (read_form (List.filter ((<>) "") (find_re token_re str))).form