py_ast.ml 1.76 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
(********************************************************************)
(*                                                                  *)
(*  The Why3 Verification Platform   /   The Why3 Development Team  *)
(*  Copyright 2010-2016   --   INRIA - CNRS - Paris-Sud University  *)
(*                                                                  *)
(*  This software is distributed under the terms of the GNU Lesser  *)
(*  General Public License version 2.1, with the special exception  *)
(*  on linking described in file LICENSE.                           *)
(*                                                                  *)
(********************************************************************)
11

12
open Why3
13

14
type ident = Ptree.ident
15 16 17 18 19 20 21 22 23 24

type unop =
  | Uneg (* -e *)
  | Unot (* not e *)

type binop =
  | Badd | Bsub | Bmul | Bdiv | Bmod    (* + - * / % *)
  | Beq | Bneq | Blt | Ble | Bgt | Bge  (* == != < <= > >= *)
  | Band | Bor                          (* && || *)

25 26 27 28
type expr = {
  expr_desc: expr_desc;
  expr_loc : Why3.Loc.position;
}
29

30 31 32 33 34
and expr_desc =
  | Enone
  | Ebool of bool
  | Eint of string
  | Estring of string
35 36 37 38 39 40 41
  | Eident of ident
  | Ebinop of binop * expr * expr
  | Eunop of unop * expr
  | Ecall of ident * expr list
  | Elist of expr list
  | Eget of expr * expr (* e1[e2] *)

42 43 44 45 46 47
and stmt = {
  stmt_desc: stmt_desc;
  stmt_loc : Loc.position;
}

and stmt_desc =
48
  | Sif of expr * block * block
49 50 51
  | Sreturn of expr
  | Sassign of ident * expr
  | Sprint of expr
52
  | Swhile of expr * Ptree.loop_annotation * block
53
  | Sfor of ident * expr * Ptree.invariant * block
54 55
  | Seval of expr
  | Sset of expr * expr * expr (* e1[e2] = e3 *)
56
  | Sassert of Ptree.assertion_kind * Ptree.term
57

58 59 60 61 62
and block = stmt list

and def = ident * ident list * block

and file = def list * block
63 64