[ast2C] adding the (->) construct

This commit is contained in:
dsac 2022-12-18 00:11:02 +01:00
parent 791af71913
commit 243e8f245a
3 changed files with 8 additions and 6 deletions

View File

@ -118,7 +118,9 @@ let rec cp_value fmt (value, (hloc: (ident * bool, string * int) Hashtbl.t)) =
| CVInput n -> n) in
let (arr, idx) = Hashtbl.find hloc (varname, true) in
Format.fprintf fmt "state->%s[%d]" arr idx
| CBinOp (BOp_arrow, v, v') -> failwith "[cprint.ml] (->) TODO!"
| CBinOp (BOp_arrow, v, v') ->
Format.fprintf fmt "(state->is_init ? (%a) : (%a))"
cp_value (v, hloc) cp_value (v', hloc)
| CBinOp (op, v, v') ->
Format.fprintf fmt "(%a) %s (%a)"
cp_value (v, hloc) (string_of_binop op) cp_value (v', hloc)

View File

@ -41,10 +41,10 @@ let equation_to_expression ((hloc: (ident * bool, string * int)Hashtbl.t), ((vl,
| IEBinOp (op, e, e') ->
CAssign (fetch_unique_var (),
CBinOp (op, iexpression_to_cvalue e, iexpression_to_cvalue e'))
(*| IEComp (op, e, e') ->
CComp (op, iexpression_to_cvalue e, iexpression_to_cvalue e')
| IEConst c -> CConst c
TODO!
| IEComp (op, e, e') ->
CAssign (fetch_unique_var (),
CComp (op, iexpression_to_cvalue e, iexpression_to_cvalue e'))
(*TODO!
| IETriOp of triop * i_expression * i_expression * i_expression
| IEWhen of i_expression * i_expression
| IEReset of i_expression * i_expression

View File

@ -1,7 +1,7 @@
node n (i: int) returns (o: int);
var v, t: int; a, b: bool;
let
a = true;
a = true -> false;
b = a and not (pre a);
o = 1;
v = pre o;