Single variable for ForCollect, set k=>v aside for now.

This commit is contained in:
Georges Dupéron 2019-03-14 19:14:10 +01:00
parent 90e894f9f4
commit 689673ccfa

13
AST2.ml
View File

@ -89,7 +89,7 @@ module O = struct
and instr = and instr =
Assignment of { name: var_name; value: expr; orig: asttodo } Assignment of { name: var_name; value: expr; orig: asttodo }
| While of { condition: expr; body: instr list; orig: asttodo } | While of { condition: expr; body: instr list; orig: asttodo }
| ForCollection of { list: expr; key: var_name; value: var_name option; body: instr list; orig: asttodo } | ForCollection of { list: expr; var: var_name; body: instr list; orig: asttodo }
| If of { condition: expr; ifso: instr list; ifnot: instr list; orig: asttodo } | If of { condition: expr; ifso: instr list; ifnot: instr list; orig: asttodo }
| Match of { expr: expr; cases: (pattern * instr list) list; orig: asttodo } | Match of { expr: expr; cases: (pattern * instr list) list; orig: asttodo }
| ProcedureCall of { expr: expr; orig: asttodo } (* expr returns unit, drop the result. Similar to OCaml's ";". *) | ProcedureCall of { expr: expr; orig: asttodo } (* expr returns unit, drop the result. Similar to OCaml's ";". *)
@ -448,15 +448,18 @@ and s_for_int ({value={kwd_for;ass;down;kwd_to;bound;step;block}; region} : I.fo
and s_for_collect ({value={kwd_for;var;bind_to;kwd_in;expr;block}; _} : I.for_collect reg) : O.instr list = and s_for_collect ({value={kwd_for;var;bind_to;kwd_in;expr;block}; _} : I.for_collect reg) : O.instr list =
let () = ignore (kwd_for,kwd_in) in let () = ignore (kwd_for,kwd_in) in
[ let for_instr =
match s_bind_to bind_to with
Some _ ->
failwith "TODO: For on maps is not supported yet!"
| None ->
O.ForCollection { O.ForCollection {
list = s_expr expr; list = s_expr expr;
key = s_name var; var = s_name var;
value = s_bind_to bind_to;
body = s_block block; body = s_block block;
orig = `TODO orig = `TODO
} }
] in [for_instr]
and s_step : (I.kwd_step * I.expr) option -> O.expr = function and s_step : (I.kwd_step * I.expr) option -> O.expr = function
Some (kwd_step, expr) -> let () = ignore (kwd_step) in s_expr expr Some (kwd_step, expr) -> let () = ignore (kwd_step) in s_expr expr