• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1(*===----------------------------------------------------------------------===
2 * Abstract Syntax Tree (aka Parse Tree)
3 *===----------------------------------------------------------------------===*)
4
5(* expr - Base type for all expression nodes. *)
6type expr =
7  (* variant for numeric literals like "1.0". *)
8  | Number of float
9
10  (* variant for referencing a variable, like "a". *)
11  | Variable of string
12
13  (* variant for a binary operator. *)
14  | Binary of char * expr * expr
15
16  (* variant for function calls. *)
17  | Call of string * expr array
18
19  (* variant for if/then/else. *)
20  | If of expr * expr * expr
21
22  (* variant for for/in. *)
23  | For of string * expr * expr * expr option * expr
24
25(* proto - This type represents the "prototype" for a function, which captures
26 * its name, and its argument names (thus implicitly the number of arguments the
27 * function takes). *)
28type proto = Prototype of string * string array
29
30(* func - This type represents a function definition itself. *)
31type func = Function of proto * expr
32