Add comments
This commit is contained in:
parent
b6e00cd862
commit
dbcba252bf
1 changed files with 4 additions and 1 deletions
5
eval.ml
5
eval.ml
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue