summaryrefslogtreecommitdiff
path: root/abstract/formula_printer.ml
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ansys.com>2014-07-01 15:42:57 +0200
committerAlex Auvolat <alex.auvolat@ansys.com>2014-07-01 15:42:57 +0200
commitf97a886970bef9e1d6e8a1e217732d6ef8be087e (patch)
treef79d165af76f23fece80c5bcc5003d5e2b82bd38 /abstract/formula_printer.ml
parent2d322a06b882542bab3d98cf08abefa906a54942 (diff)
downloadscade-analyzer-f97a886970bef9e1d6e8a1e217732d6ef8be087e.tar.gz
scade-analyzer-f97a886970bef9e1d6e8a1e217732d6ef8be087e.zip
Adapt for real type with Apron ; not very efficient ATM.
Diffstat (limited to 'abstract/formula_printer.ml')
-rw-r--r--abstract/formula_printer.ml21
1 files changed, 12 insertions, 9 deletions
diff --git a/abstract/formula_printer.ml b/abstract/formula_printer.ml
index 383500c..9c6c403 100644
--- a/abstract/formula_printer.ml
+++ b/abstract/formula_printer.ml
@@ -12,12 +12,12 @@ let string_of_binary_rel = function
| AST_GE -> "≥"
let ne_prec = function
- | NUnary(op, _) -> unary_precedence
- | NBinary(op, _, _) -> binary_op_precedence op
+ | NUnary _ -> unary_precedence
+ | NBinary(op, _, _, _) -> binary_op_precedence op
| _ -> 100
let be_prec = function
- | BRel(op, _, _) -> binary_rel_precedence op
+ | BRel(op, _, _, _) -> binary_rel_precedence op
| BAnd _ -> binary_bool_precedence AST_AND
| BOr _ -> binary_bool_precedence AST_OR
| BNot _ -> unary_precedence
@@ -49,12 +49,14 @@ let rec print_num_expr fmt e = match e with
| NRealConst f -> Format.fprintf fmt "%f" f
| NIdent id ->
print_id fmt id
- | NBinary(op, a, b) ->
+ | NBinary(op, a, b, is_real) ->
print_ch fmt print_num_expr ne_prec a ne_prec e;
- Format.fprintf fmt "@ %s " (string_of_binary_op op);
+ Format.fprintf fmt "@ %s%s " (string_of_binary_op op)
+ (if is_real then "." else "");
print_ah fmt print_num_expr ne_prec b ne_prec e
- | NUnary(op, a) ->
- Format.fprintf fmt "%s " (string_of_unary_op op);
+ | NUnary(op, a, is_real) ->
+ Format.fprintf fmt "%s%s " (string_of_unary_op op)
+ (if is_real then "." else "");
print_ah fmt print_num_expr ne_prec a ne_prec e
(* Enumeated expressions *)
@@ -75,9 +77,10 @@ let print_econs fmt (op, a, b) =
let rec print_bool_expr fmt e = match e with
| BConst b -> Format.fprintf fmt "%s" (if b then "true" else "false")
| BEnumCons c -> print_econs fmt c
- | BRel(op, a, b) ->
+ | BRel(op, a, b, is_real) ->
print_ch fmt print_num_expr ne_prec a be_prec e;
- Format.fprintf fmt "@ %s " (string_of_binary_rel op);
+ Format.fprintf fmt "@ %s%s " (string_of_binary_rel op)
+ (if is_real then "." else "");
print_ch fmt print_num_expr ne_prec b be_prec e
| BAnd (a, b) ->