From bbfbc15a639d94eb8b021a84634c645ff3d071bf Mon Sep 17 00:00:00 2001
From: Christophe Garion <tofgarion@runbox.com>
Date: Thu, 5 Oct 2017 14:20:37 +0200
Subject: [PATCH] json-parser: remove Const_bool and use Const_tag

---
 src/lustreSpec.ml                              | 1 -
 src/tools/stateflow/parser-json/parser_json.ml | 9 +++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/src/lustreSpec.ml b/src/lustreSpec.ml
index 096fe9fc..82888e0f 100644
--- a/src/lustreSpec.ml
+++ b/src/lustreSpec.ml
@@ -47,7 +47,6 @@ and clock_dec_desc =
 
 
 type constant =
-  | Const_bool of bool
   | Const_int of int
   | Const_real of Num.num * int * string (* (a, b, c) means a * 10^-b. c is the original string *)
   | Const_array of constant list
diff --git a/src/tools/stateflow/parser-json/parser_json.ml b/src/tools/stateflow/parser-json/parser_json.ml
index 84ee7a53..a00f861d 100644
--- a/src/tools/stateflow/parser-json/parser_json.ml
+++ b/src/tools/stateflow/parser-json/parser_json.ml
@@ -130,8 +130,13 @@ struct
     let initial_value = json |> member "initial_value" |> to_string in
     match datatype with
     | "bool" -> (Tydec_bool, mkexpr location
-                   (Expr_const (Const_bool
-                                  (bool_of_string initial_value))))
+                   (Expr_const (Const_tag
+                                  ((fun s -> match s with
+                                     | "true"  -> tag_true
+                                     | "false" -> tag_false
+                                     | _       ->
+                                       failwith ("Invalid constant for
+     boolean: " ^ s)) initial_value))))
     | "int"  -> (Tydec_int, mkexpr location
                    (Expr_const (Const_int (int_of_string
                                              initial_value))))
-- 
GitLab