-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathAst.ml
92 lines (69 loc) · 2.67 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
78
79
80
81
82
83
84
85
86
87
88
89
(*
* Copyright (c) 2015 Stefan Krah. All rights reserved.
*
* This file is distributed under the terms of the Q Public License
* version 1.0.
*)
open Shared
open Symbol
(**********************************************************************)
(* Types *)
(**********************************************************************)
type type_description =
{ atyp_id: Tycon.t;
atyp_loc: Location.t }
(**********************************************************************)
(* Values *)
(**********************************************************************)
type value_description =
{ avd_id: ValueID.t;
avd_constraint: Types.t option;
avd_loc: Location.t }
(**********************************************************************)
(* Expressions *)
(**********************************************************************)
type expression =
{ aexp_desc: expression_desc;
aexp_type: Types.t option;
aexp_loc: Location.t }
and expression_desc
= Aexp_any
| Aexp_nil
| Aexp_bool of bool
| Aexp_int of Int64.t
| Aexp_float of float
| Aexp_string of string
| Aexp_path of path
| Aexp_uminus of expression
| Aexp_op of expression * Shared.binary_operator * expression
| Aexp_assign of path * Shared.assign_operator * expression
| Aexp_tuple of expression list
| Aexp_record of (Tyfield.t * expression) list
| Aexp_array of expression * expression
| Aexp_if of expression * expression * expression option
| Aexp_while of expression * expression
| Aexp_for of value_binding list * expression * expression
| Aexp_lambda of lambda_expression
| Aexp_call of expression * expression
| Aexp_let of rec_flag * value_binding list * expression
| Aexp_sequence of expression list
and path
= Avar_simple of ValueID.t * ScopeID.t * Location.t
| Avar_field of path * Tyfield.t * Location.t
| Avar_subscript of path * expression * Location.t
and value_binding =
{ avb_desc: value_description;
avb_expr: expression }
and lambda_expression =
{ afun_id: ScopeID.t;
afun_params: value_description list;
afun_body: expression }
(**********************************************************************)
(* Modules *)
(**********************************************************************)
and structure_item
= Astr_type of type_description list
| Astr_primitive of value_binding
| Astr_value of rec_flag * value_binding list
type structure = structure_item list
type module_expr = Amod_structure of structure