(* à ajouter à la fin du cours 6 *) type instruction = Printstr of string | Print of expression | Block of instruction list | Affectation of int * expression | While of expression * instruction;; let rec exec = function | Printstr s -> print_string s | Print e -> print_int (eval e) | Block [] -> () | Block (x::xs) -> exec x; exec (Block xs) | Affectation (n, e) when n < 4 && n >= 0 -> etats.(n) <- (eval e) | Affectation (n, e) -> raise Segfault | While (e, i) as w -> (match (eval e) with | 0 -> () | _ -> exec i; exec w);; "x = 10; while (x < 40) { print x; println; x = x + 10; }";; let p = Block [ Affectation (0, Ent 10); While ( Inf (Var 0, Ent 40), Block [ Print (Var 0); Printstr "\n"; Affectation (0, Plus ((Var 0), Ent 10)) ]) ];; exec p;;