aboutsummaryrefslogtreecommitdiff
path: root/expression.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@chimrod.com>2017-10-31 16:07:04 +0100
committerSébastien Dailly <sebastien@chimrod.com>2017-10-31 16:07:04 +0100
commitab721136f50914a21f6cca89f0fcfb055ba58cd2 (patch)
tree60f788e3e8733a6d3606e801bc21a24e419e070e /expression.ml
parentdb627ca2cfc745bbf2e489251e64054ab2b3bff9 (diff)
parentd8ed0babfa1c03c8f1968443a465972bb3bf460c (diff)
Update ScTypes.types with types used in evaluator
Diffstat (limited to 'expression.ml')
-rwxr-xr-xexpression.ml19
1 files changed, 10 insertions, 9 deletions
diff --git a/expression.ml b/expression.ml
index 0bc8f43..31b6369 100755
--- a/expression.ml
+++ b/expression.ml
@@ -3,9 +3,9 @@ module Tuple2 = Tools.Tuple2
let u = UTF8.from_utf8string
type t =
- | Basic of ScTypes.types (** A direct type *)
- | Formula of formula (** A formula *)
- | Undefined (** The content is not defined *)
+ | Basic: 'a ScTypes.types -> t (** A direct type *)
+ | Formula: formula -> t (** A formula *)
+ | Undefined: t (** The content is not defined *)
and formula =
| Expression of ScTypes.expression (** A valid expression *)
@@ -33,11 +33,12 @@ let load content = begin
let content' =
try String.sub content 0 (String.index content '\000')
with Not_found -> content in
- Basic (
- try Lexing.from_string content'
- |> ExpressionParser.content ExpressionLexer.read
- with _ -> ScTypes.Str (UTF8.from_utf8string content')
- )
+ try
+ let ScTypes.Result r =
+ ExpressionParser.content ExpressionLexer.read
+ @@ Lexing.from_string content' in
+ Basic r
+ with _ -> Basic (ScTypes.Str (UTF8.from_utf8string content'))
)
) else (
(* If the string in empty, build an undefined value *)
@@ -58,7 +59,7 @@ let eval expr sources = begin
begin try match expr with
| Basic value -> ScTypes.Result value
- | Formula (Expression f) -> ScTypes.Result (eval_exp f)
+ | Formula (Expression f) -> eval_exp f
| Formula (Error (i, s)) -> ScTypes.Error ScTypes.Error
| Undefined -> ScTypes.Error Not_found
with ex -> ScTypes.Error ex