Add comments

This commit is contained in:
백현웅 2022-02-19 20:39:50 +09:00
parent b6e00cd862
commit dbcba252bf

View file

@ -20,6 +20,7 @@ and env = (string * value) list
exception No_operation
exception Too_many_arguments
(* TODO: add proper type system *)
module Type = struct
type t =
| Int
@ -146,6 +147,7 @@ module Operator = struct
let lt a b = Bool (compare a b < 0)
(* operator table *)
(* TODO: refactor operator finding alg (support type vars) *)
let operators =
let open Type in
let ip = Int, Int and fp = Float, Float in
@ -248,6 +250,7 @@ let rec binop op l r =
exception Unbound of string
(* TODO: refactor eval, split function into parts *)
let rec eval env ast =
let rec aux = function
| Nothing -> Nop
@ -328,7 +331,7 @@ let rec eval env ast =
let eval_top env_ref ast =
let var, v = match ast with
| Let (var, Nfunction (arg, e)) ->
| Let (var, Nfunction (arg, e)) -> (* named function *)
var, Function (Some var, arg, e, !env_ref)
| Let (var, e) -> var, eval !env_ref e
| ast -> "-", eval !env_ref ast