aboutsummaryrefslogtreecommitdiff
path: root/src/evaluator.ml
diff options
context:
space:
mode:
Diffstat (limited to 'src/evaluator.ml')
-rwxr-xr-xsrc/evaluator.ml16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/evaluator.ml b/src/evaluator.ml
index ed384e6..05b975f 100755
--- a/src/evaluator.ml
+++ b/src/evaluator.ml
@@ -108,33 +108,35 @@ let eval mapper value = begin
end in
(** Extract the value from an expression.
- [extract typ expr] will evaluate the expression and return it. If the
- result cannot be evaluated (because of references pointing to missing
- values) a default value of type [typ] will be returned.
+ [extract expr] will evaluate the expression and return it. If the result
+ cannot be evaluated (because of references pointing to missing values) a
+ default value of type [typ] will be returned.
*)
let rec extract = begin function
(* For a reference to an external we first extract the value pointed *)
| ScTypes.Ref r -> ScTypes.Refs.(
begin match ScTypes.Refs.get_content @@ mapper r with
- | C (Value (format, f)) -> begin match format with
+ | Value (format, f) -> begin match format with
| ScTypes.Date -> Result (Data.Num (format, f))
| ScTypes.Number -> Result (Data.Num (format, f))
| ScTypes.String -> Result (Data.String f)
| ScTypes.Bool -> Result (Data.Bool f)
end
- | C (List (format, l)) -> Result (Data.List (format, l))
- | C (Matrix (format, l)) -> Result (Data.Matrix (format, l))
+ | List (format, l) -> Result (Data.List (format, l))
+ | Matrix (format, l) -> Result (Data.Matrix (format, l))
end)
(* Evaluate the expression *)
| ScTypes.Expression e -> extract e
| ScTypes.Value v -> extract_value (ScTypes.Result v)
| ScTypes.Call (name, args) ->
+ (* The function is not tail recursive, but I don't think we will have
+ more than 100 nested functions here... *)
let args' = List.map extract args in
call name args'
end in
- let Result r = ((extract[@tailrec]) value) in
+ let Result r = extract value in
begin match r with
| Data.Bool b -> ScTypes.Result (ScTypes.boolean b)
| Data.String s -> ScTypes.Result (ScTypes.string s)