-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.ml
More file actions
92 lines (88 loc) · 2.13 KB
/
types.ml
File metadata and controls
92 lines (88 loc) · 2.13 KB
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
90
91
92
(*== structure ==*)
type id = string
type constructor = string
type op1 = Not | Neg
type logop = And | Or
type eqop = Eq | Neq
type compop = Less | Greater | LeEq | GrEq
type strongop = Times | Divide | Modulo
type weakop = Plus | Minus
type op2 =
| Listop
| Logop of logop
| Eqop of eqop
| Compop of compop
| Weakop of weakop
| Strongop of strongop
type field = Hd | Tl | Fst | Snd
type fieldexp =
| Nofield of id
| Field of fieldexp * field
type exp =
| Exp_field of fieldexp
| Exp_infix of exp * op2 * exp
| Exp_prefix of op1 * exp
| Exp_int of int
| Exp_char of char
| Exp_bool of bool
| Exp_function_call of id * exp list
| Exp_emptylist
| Exp_tuple of exp * exp
| Exp_low_bar
| Exp_constructor of constructor
type stmt =
| Stmt_if of exp * stmt list
| Stmt_if_else of exp * stmt list * stmt list
| Stmt_while of exp * stmt list
| Stmt_define of fieldexp * exp
| Stmt_function_call of id * exp list
| Stmt_return of exp option
| Stmt_match of exp * (exp * exp option * stmt list) list
type fargs = id list
type typetoken = Type_int | Type_bool | Type_char
| Type_tuple of typetoken * typetoken
| Type_list of typetoken
| Type_id of id
type rettype = Rettype of typetoken | Type_void
type funtype = typetoken list * rettype
type vardecl = typetoken option * id * exp
type fundecl = id * fargs * funtype option * vardecl list * stmt list
type typedecl =
| Rename of id * typetoken
| Enum of id * constructor list
(* | Typedef of id * (constructor * typetoken) list *)
type decl = Vardecl of vardecl | Fundecl of fundecl
type spl = typedecl list * decl list;;
(*== result ==*)
type 'a result = Error of string | Success of 'a;;
(*== token ==*)
type token =
| VAR
| EQ
| SEMICOLON
| OPEN_PAR | CLOSE_PAR
| DDPOINT
| OPEN_ACO | CLOSE_ACO
| VOID
| ARROW
| COMMA
| EMPTYLIST
| OPEN_BRACK | CLOSE_BRACK
| Basic_int | Basic_bool | Basic_char
| IF | ELSE | WHILE | RETURN
| FALSE | TRUE
| PERIOD
| Fieldtoken of field
| Optok of string
| Inttok of int
| IDtok of string
| Constructortok of string
| Chartok of char
| Startcomment
| Endcomment
| LOWBAR
| TYPE
| MATCH
| WITH
| PIPE
| WHEN;;