This repository has been archived by the owner on Sep 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathast.ml
77 lines (63 loc) · 1.73 KB
/
ast.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
open Sexplib.Std
type ref_contents =
| RNone
| RInt of int
| RVar of string [@@deriving sexp]
type ref_init = ref_contents [@@deriving sexp]
type fn_call = {
callee: string;
arg_names: string list;
label: int;
} [@@deriving sexp]
type imm_op =
IVar of string
| IInt of int [@@deriving sexp]
type lhs =
| Var of string
| Const of int
| Mkref of ref_init
| MkArray of string
| Call of fn_call
| Deref of string
| Tuple of ref_contents list
| Nondet of RefinementTypes.symbolic_refinement option
| Read of string * string
| LengthOf of string
| Null [@@deriving sexp]
type patt =
| PVar of string
| PTuple of patt list
| PNone [@@deriving sexp]
type relation = {
rop1: imm_op;
cond: string;
rop2: imm_op
} [@@deriving sexp]
type position = int * Lexing.position
let sexp_of_position (id,pos) =
let open Sexplib.Sexp in
List [ [%sexp_of: int] id; Locations.sexp_of_location pos]
let position_of_sexp sexp =
let open Sexplib.Sexp in
match sexp with
| List [ id; pos ] ->
([%of_sexp: int] id, Locations.location_of_sexp pos)
| _ -> Sexplib.Conv_error.tuple_of_size_n_expected "position" 2 sexp
type src_ap =
| AVar of string
| AProj of string * int
| ADeref of string
| APtrProj of string * int [@@deriving sexp]
type raw_exp =
| EVar of string
| Cond of string * exp * exp
| NCond of string * exp * exp
| Seq of exp * exp
| Assign of string * imm_op * exp
| Update of string * string * string * exp
| Let of patt * lhs * exp
| Alias of string * src_ap * exp
| Assert of relation * exp [@@deriving sexp]
and exp = position * raw_exp [@@deriving sexp]
type fn = { name: string; args: (string list); body: exp } [@@deriving sexp]
type prog = fn list * exp [@@deriving sexp]