mlox/lib/value.ml

16 lines
426 B
OCaml

type lox_value = String of string | Number of float | Bool of bool | Nil
[@@deriving show { with_path = false }]
let string_of_lox_value lox_value =
match lox_value with
| String s -> s
| Number x -> string_of_float x
| Bool b -> string_of_bool b
| Nil -> "nil"
let type_string_of_lox_value lox_value =
match lox_value with
| String _ -> "String"
| Number _ -> "Number"
| Bool _ -> "Bool"
| Nil -> "Nil"