py_ast.ml 1.72 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 49 50 51 52
  | Sif of expr * stmt * stmt
  | Sreturn of expr
  | Sassign of ident * expr
  | Sprint of expr
  | Sblock of stmt list
53
  | Swhile of expr * Ptree.loop_annotation * stmt
54 55 56
  | Sfor of ident * expr * stmt
  | Seval of expr
  | Sset of expr * expr * expr (* e1[e2] = e3 *)
57
  | Sassert of Ptree.term
58 59 60 61 62

and def = ident * ident list * stmt

and file = def list * stmt