Revision d3e837ea
Added by Pierre-Loïc Garoche about 5 years ago
src/backends/EMF/EMF_backend.ml | ||
---|---|---|
26 | 26 |
| Expr_access (a, d) -> fprintf fmt "%a[%a]" pp_expr a Dimension.pp_dimension d |
27 | 27 |
| Expr_power (a, d) -> fprintf fmt "(%a^%a)" pp_expr a Dimension.pp_dimension d |
28 | 28 |
| Expr_tuple el -> fprintf fmt "(%a)" pp_tuple el |
29 |
| Expr_ite (c, t, e) -> fprintf fmt "(if %a then %a else %a)" pp_expr c pp_expr t pp_expr e
|
|
29 |
| Expr_ite (c, t, e) -> fprintf fmt "if %a; %a; else %a; end" pp_expr c pp_expr t pp_expr e
|
|
30 | 30 |
| Expr_arrow (e1, e2) ->( |
31 | 31 |
match e1.expr_desc, e2.expr_desc with |
32 | 32 |
| Expr_const c1, Expr_const c2 -> if c1 = Corelang.const_of_bool true && c2 = Corelang.const_of_bool false then fprintf fmt "STEP" else assert false (* only handle true -> false *) |
... | ... | |
99 | 99 |
(* first, we extract the expression and associated variables *) |
100 | 100 |
let vars = Utils.ISet.elements (Corelang.get_expr_vars eq.eq_rhs) in |
101 | 101 |
|
102 |
fprintf fmt "\"%s\": @[<v 2>{ \"expr\": \"%a\";@ \"vars\": [%a] @]}"
|
|
102 |
fprintf fmt "\"%s\": @[<v 2>{ \"expr\": \"%a\",@ \"vars\": [%a] @]}"
|
|
103 | 103 |
var |
104 | 104 |
(pp_expr vars) eq.eq_rhs (* todo_pp_expr expr *) |
105 | 105 |
(fprintf_list ~sep:", " pp_var_string) vars |
... | ... | |
109 | 109 |
| _ -> assert false (* should not happen with EMF backend *) |
110 | 110 |
|
111 | 111 |
let pp_node fmt nd = |
112 |
fprintf fmt "@[<v 2>\"%s\": {@ \"inputs\": [%a];@ \"outputs\": [%a];@ "
|
|
112 |
fprintf fmt "@[<v 2>\"%s\": {@ \"inputs\": [%a],@ \"outputs\": [%a],@ "
|
|
113 | 113 |
nd.node_id |
114 | 114 |
pp_node_args nd.node_inputs |
115 | 115 |
pp_node_args nd.node_outputs; |
116 | 116 |
fprintf fmt "\"exprs\": {@[<v 1> %a@]@ }" |
117 |
(fprintf_list ~sep:";@ " pp_stmt ) nd.node_stmts;
|
|
117 |
(fprintf_list ~sep:",@ " pp_stmt ) nd.node_stmts;
|
|
118 | 118 |
fprintf fmt "@]@ }" |
119 | 119 |
|
120 | 120 |
let pp_decl fmt decl = |
... | ... | |
128 | 128 |
|
129 | 129 |
let translate fmt prog = |
130 | 130 |
fprintf fmt "@[<v 0>{@ "; |
131 |
fprintf_list ~sep:"@ " pp_decl fmt prog; |
|
131 |
fprintf_list ~sep:",@ " pp_decl fmt prog;
|
|
132 | 132 |
fprintf fmt "@ @]}" |
133 | 133 |
|
Also available in: Unified diff
Changed the matlab function backend