Skip to content

Commit 01e112d

Browse files
bgregoirlyonel2017
authored andcommitted
remove use
1 parent 63f0e0d commit 01e112d

6 files changed

Lines changed: 12 additions & 35 deletions

File tree

examples/exception.ec

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ op p2: int -> bool.
99
module M' ={
1010
proc truc (x:int) : int = {
1111
if (! p1 x \/ ! p2 x) else raise assume;
12-
ensure (! p1 x \/ ! p2 x) -> assume;
1312
if (!p1 x \/ !p2 x) { raise assert;}
1413
return x;
1514
}
@@ -54,7 +53,7 @@ exception e3.
5453

5554
module M ={
5655
proc f1 (x:int) : int = {
57-
ensure (x <> 3) -> e1;
56+
if (x <> 3) else raise e1;
5857
x <- 5;
5958
return x;
6059
}
@@ -196,7 +195,7 @@ proof.
196195
proc. wp. skip => //.
197196
qed.
198197

199-
exception return ['a]
198+
200199

201200

202201

src/ecLexer.mll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
"admitted" , ADMITTED ; (* KW: dangerous *)
3737

3838
"forall" , FORALL ; (* KW: prog *)
39-
"ensure" , ENSURE ; (* KW: prog *)
4039
"exists" , EXIST ; (* KW: prog *)
4140
"fun" , FUN ; (* KW: prog *)
4241
"glob" , GLOB ; (* KW: prog *)
@@ -54,7 +53,6 @@
5453
"match" , MATCH ; (* KW: prog *)
5554
"for" , FOR ; (* KW: prog *)
5655
"while" , WHILE ; (* KW: prog *)
57-
"ensure" , ENSURE ; (* KW: prog *)
5856
"raise" , RAISE ; (* KW: prog *)
5957
"return" , RETURN ; (* KW: prog *)
6058
"res" , RES ; (* KW: prog *)

src/ecParser.mly

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,6 @@
437437
%token ELIM
438438
%token ELSE
439439
%token END
440-
%token ENSURE
441440
%token EOF
442441
%token EQ
443442
%token EQUIV
@@ -1365,10 +1364,7 @@ base_instr:
13651364
{ PScall (None, f, es) }
13661365

13671366
| RAISE ex=expr
1368-
{ PSraise (ex, None) }
1369-
1370-
| ENSURE e=expr RARROW ex=expr
1371-
{ PSraise (ex, Some e) }
1367+
{ PSraise ex }
13721368

13731369
instr:
13741370
| bi=base_instr SEMICOLON
@@ -1387,8 +1383,8 @@ instr:
13871383
{ PSmatch (e, `If ((c, b1), b2)) }
13881384

13891385
%inline if_expr:
1390-
| IF c=paren(expr) b=block el=if_else_expr
1391-
{ PSif ((c, b), fst el, snd el) }
1386+
| IF c=paren(expr) b=block? el=if_else_expr
1387+
{ PSif ((c, odfl [] b), fst el, snd el) }
13921388

13931389
if_else_expr:
13941390
| /* empty */ { ([], []) }

src/ecParsetree.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ and pinstr_r =
161161
| PSif of pscond * pscond list * pstmt
162162
| PSwhile of pscond
163163
| PSmatch of pexpr * psmatch
164-
| PSraise of pexpr * pexpr option
164+
| PSraise of pexpr
165165

166166
and psmatch = [
167167
| `Full of (ppattern * pstmt) list

src/ecPrinting.ml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,7 +2679,6 @@ let pp_axiom ?(long=false) (ppe : PPEnv.t) fmt (x, ax) =
26792679
type ppnode1 = [
26802680
| `Asgn of (EcModules.lvalue * EcTypes.expr)
26812681
| `Raise of EcTypes.expr
2682-
| `ERaise of (EcTypes.expr * EcTypes.expr)
26832682
| `Call of (EcModules.lvalue option * P.xpath * EcTypes.expr list)
26842683
| `Rnd of (EcModules.lvalue * EcTypes.expr)
26852684
| `Abstract of EcIdent.t
@@ -2708,10 +2707,6 @@ let at (ppe : PPEnv.t) n i =
27082707
| Swhile (e, s), 0 -> Some (`While e, `P, s.s_node)
27092708
| Swhile _ , 1 -> Some (`EBlk , `B, [])
27102709

2711-
| Sif (e, {s_node=[{i_node=Sraise p}]}, {s_node= []}), 0 ->
2712-
Some (`ERaise (p,e), `P, [])
2713-
| Sif (_, {s_node=[{i_node=Sraise _}]}, {s_node= []}), 1 ->
2714-
None
27152710
| Sif (e, s, _ ), 0 -> Some (`If e, `P, s.s_node)
27162711
| Sif (_, _, s ), 1 -> begin
27172712
match s.s_node with
@@ -2804,10 +2799,6 @@ let pp_i_asgn (ppe : PPEnv.t) fmt (lv, e) =
28042799
let pp_i_raise (ppe : PPEnv.t) fmt (e : expr) =
28052800
Format.fprintf fmt "raise %a" (pp_expr ppe) e
28062801

2807-
let pp_i_eraise (ppe : PPEnv.t) fmt (p,e) =
2808-
Format.fprintf fmt "ensure %a -> %a"
2809-
(pp_expr ppe) (add_not e) (pp_expr ppe) p
2810-
28112802
let pp_i_call (ppe : PPEnv.t) fmt (lv, xp, args) =
28122803
match lv with
28132804
| None ->
@@ -2854,7 +2845,6 @@ let c_ppnode1 ~width ppe (pp1 : ppnode1) =
28542845
match pp1 with
28552846
| `Asgn x -> c_split ~width (pp_i_asgn ppe) x
28562847
| `Raise x -> c_split ~width (pp_i_raise ppe) x
2857-
| `ERaise x -> c_split ~width (pp_i_eraise ppe) x
28582848
| `Call x -> c_split ~width (pp_i_call ppe) x
28592849
| `Rnd x -> c_split ~width (pp_i_rnd ppe) x
28602850
| `Abstract x -> c_split ~width (pp_i_abstract ppe) x
@@ -3481,19 +3471,18 @@ let rec pp_instr_r (ppe : PPEnv.t) fmt i =
34813471
Format.fprintf fmt "@[<v>while (@[%a@])%a@]"
34823472
(pp_expr ppe) e (pp_block ppe) s
34833473

3484-
| Sif (e, {s_node=[{i_node=Sraise p}]}, {s_node= []})->
3485-
Format.fprintf fmt "@[<hov 2>ensure@ @[%a@]@ ->@ %a@];"
3486-
(pp_expr ppe) (add_not e) (pp_expr ppe) p
3487-
34883474
| Sif (e, s1, s2) ->
3475+
let pp_then ppe fmt s =
3476+
if s.s_node = [] then ()
3477+
else pp_block ppe fmt s in
34893478
let pp_else ppe fmt s =
34903479
match s.s_node with
34913480
| [] -> ()
34923481
| [_] -> Format.fprintf fmt "@,else %a" (pp_block ppe) s
34933482
| _ -> Format.fprintf fmt "@ else %a" (pp_block ppe) s
34943483
in
34953484
Format.fprintf fmt "@[<v>if (@[%a@]) %a%a@]"
3496-
(pp_expr ppe) e (pp_block ppe) s1 (pp_else ppe) s2
3485+
(pp_expr ppe) e (pp_then ppe) s1 (pp_else ppe) s2
34973486

34983487
| Smatch (e, ps) ->
34993488
let p, tyd, typ = oget (EcEnv.Ty.get_top_decl e.e_ty ppe.PPEnv.ppe_env) in

src/ecTyping.ml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,15 +2822,10 @@ and transinstr
28222822
[ i_match (e, branches) ]
28232823
end
28242824

2825-
| PSraise (pex,pe) ->
2825+
| PSraise (pex) ->
28262826
let ex, exty = transexp env `InProc ue pex in
28272827
unify_or_fail env ue pex.pl_loc ~expct:texn exty;
2828-
match pe with
2829-
| None -> [i_raise ex]
2830-
| Some pe ->
2831-
let e, ety = transexp env `InProc ue pe in
2832-
unify_or_fail env ue pe.pl_loc ~expct:tbool ety;
2833-
[i_if (e_not e, stmt [i_raise ex], stmt [])]
2828+
[i_raise ex]
28342829

28352830
(* -------------------------------------------------------------------- *)
28362831
and trans_pv env { pl_desc = x; pl_loc = loc } =

0 commit comments

Comments
 (0)