Commit 5aabfea3 authored by Julien Lopez's avatar Julien Lopez

Add syntactic sugar for if_then:

	if cond then expr <=> if cond then expr else []

Note that in case of ambiguity the "else" statement is part of the last "if"
statement:

	if a then if b then c else d <=> if a then (if b then c else d)
parent 17e63c21
......@@ -251,6 +251,8 @@ EXTEND Gram
exp _loc (Map (e,b))
| "xtransform"; e = SELF; "with"; b = branches ->
exp _loc (Xtrans (e,b))
| "if"; e = SELF; "then"; e1 = SELF ->
exp _loc (if_then_else e e1 cst_nil)
| "if"; e = SELF; "then"; e1 = SELF; "else"; e2 = SELF ->
exp _loc (if_then_else e e1 e2)
| "transform"; e = SELF; "with"; b = branches ->
......
......@@ -7,12 +7,12 @@ let nb_tests = ref Int (0)
(* TODO: Bugfix: it works here if you replace 'a with 'b *)
(* let run_test_suite (l : [(Latin1, 'a, 'a)*]) : [] =
iter (fun ((Latin1, 'a, 'a) -> []) (_, x, y) -> nb_tests := !nb_tests + 1;
if x = y then nb_success := !nb_success + 1 else []) l *)
if x = y then nb_success := !nb_success + 1) l *)
let run_test_suite (l : [(Latin1, 'a, 'a)*]) : [] = match l with
| [] -> []
| [(_, x, y) rest::(Latin1, 'a, 'a)*] -> nb_tests := !nb_tests + 1;
(if x = y then nb_success := !nb_success + 1 else []);
(if x = y then nb_success := !nb_success + 1);
run_test_suite rest
let run_test_suite_debug (l : [(Latin1, 'a, 'a)*]) : [] = match l with
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment