-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntax.ml
More file actions
28 lines (23 loc) · 960 Bytes
/
syntax.ml
File metadata and controls
28 lines (23 loc) · 960 Bytes
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
(** Syntax *)
type ctx = string * string list
type atom_name =
| PConstr of string (** constructor name *)
| PInt of int (** integer literal *)
| PLam of ctx * exp (** lambda abstraction *)
(** graph template *)
and graph =
| Zero
| Atom of atom_name * string list (** atom. e.g. a(_X, _Y) *)
| Ctx of ctx (** graph context. e.g. x[_X, _Y] *)
| Mol of graph * graph (** molecule *)
| Nu of string * graph (** hyperlink creation *)
(** expression *)
and exp =
| BinOp of (int -> int -> int) * string * exp * exp (** Binary operator *)
| RelOp of (int -> int -> bool) * string * exp * exp (** Binary operator *)
| Graph of graph (** Graph *)
| Case of exp * graph * exp * exp (** Case expression *)
| App of exp * exp (** Apply *)
| LetRec of ctx * ctx * exp * exp (** let rec f x = e1 in e2 *)
| Let of ctx * exp * exp (** let x = e1 in e2 *)
let make_lambda (_, xs) ctx exp = Graph (Atom (PLam (ctx, exp), xs))