-
Notifications
You must be signed in to change notification settings - Fork 0
/
Ast.fs
50 lines (45 loc) · 980 Bytes
/
Ast.fs
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
module Ast
type DataType
= Null
| Identifier of string
| Boolean of bool
| Integer of int
| String of string
| Array of (Expr list)
| Function of args: Expr list * block: Stat list * env: Map<string, Expr>
| ReturnValue of Expr
| ErrorMsg of string
| Error
and Application
= FuncCall of f: Expr * args: Expr list
| FuncDef of args: Expr list * block: Stat list
| IndexAccess of index: Expr * array: Expr
| Binary of a: Expr * op: Operator * b: Expr
| Unary of op: Operator * e: Expr
| If of cond: Expr * truebranch: Stat list * falsebranch: Stat list
and Expr =
| DataType of DataType
| Application of Application
and Operator
= Add
| Sub
| Mul
| Div
| Mod
| Assign
| Equal
| NotEqual
| LessThan
| GreaterThan
| LessOrEqual
| GreaterOrEqual
| BitAnd
| BitOr
| BitXor
| LogicalAnd
| LogicalOr
and Stat
= Expr of Expr
| Let of name: string * value: Expr
| Block of Stat list
| Return of Expr option