| _ -> assert false
in
instantiate_fold_right env)
+ | If (_, body)
+ | Unless (_, body) -> aux env body
| _ -> assert false
in
aux env term
let env' = Env.remove_names env (List.map fst magic_map) in
Some (env', pid)))
(fun _ -> None)
- candidates
+ (List.rev candidates)
in
let match_cb rows =
let candidates =
| _ -> assert false)
| Pt.If (guard, p) ->
- prerr_endline ("guard = " ^ CicNotationPp.pp_term guard) ;
- prerr_endline ("p = " ^ CicNotationPp.pp_term p) ;
let compiled_guard = compiler [guard, 0]
and compiled_p = compiler [p, 0] in
(fun term env ->
- prerr_endline "GUARDIA?" ;
match compiled_guard term with
| None -> None
| Some _ ->
match compiled_p term with
| None -> None
| Some (env', _) ->
- prerr_endline "guardia ok" ;
Some (env' @ env)
end)
+ | Pt.Unless (guard, p) ->
+ let compiled_guard = compiler [guard, 0]
+ and compiled_p = compiler [p, 0] in
+ (fun term env ->
+ match compiled_guard term with
+ | None ->
+ begin
+ match compiled_p term with
+ | None -> None
+ | Some (env', _) ->
+ Some (env' @ env)
+ end
+ | Some _ -> None)
+
| _ -> assert false
end
DELIM "\\["; guard = l2_pattern; DELIM "\\]";
DELIM "\\["; p = l2_pattern; DELIM "\\]" ->
If (guard, p)
+ | SYMBOL "\\UNLESS";
+ DELIM "\\["; guard = l2_pattern; DELIM "\\]";
+ DELIM "\\["; p = l2_pattern; DELIM "\\]" ->
+ Unless (guard, p)
]
];
l2_pattern: LEVEL "10" (* let in *)
sprintf "\\DEFAULT \\[%s\\] \\[%s\\]" (pp_term p_some) (pp_term p_none)
| If (p_guard, p) ->
sprintf "\\IF \\[%s\\] \\[%s\\]" (pp_term p_guard) (pp_term p)
+ | Unless (p_guard, p) ->
+ sprintf "\\UNLESS \\[%s\\] \\[%s\\]" (pp_term p_guard) (pp_term p)
and pp_fold_kind = function
| `Left -> "left"
| Fold of fold_kind * term * string list * term
(* base case pattern, recursive case bound names, recursive case pattern *)
| Default of term * term (* "some" case pattern, "none" case pattern *)
- | If of term * term (* guard, pattern *)
+ | If of term * term (* guard, body *)
+ | Unless of term * term (* guard, body *)
and pattern_variable =
(* level 1 and 2 variables *)
| Fold (kind, t1, names, t2) -> Fold (kind, k t1, names, k t2)
| Default (t1, t2) -> Default (k t1, k t2)
| If (t1, t2) -> If (k t1, k t2)
+ | Unless (t1, t2) -> Unless (k t1, k t2)
let variables_of_term t =
let rec vars = ref [] in