-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwhere.ml
More file actions
29 lines (23 loc) · 736 Bytes
/
where.ml
File metadata and controls
29 lines (23 loc) · 736 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
29
open Camlp4
module Id : Sig.Id = struct
let name = "where"
let version = "0.1"
end
module Make (Syntax : Sig.Camlp4Syntax) = struct
include Syntax
let _loc = Loc.ghost
let rec exp_let_bindings body = function
| [] -> <:expr< >>
| [(rf,lb)] -> <:expr< let $rec:rf$ $lb$ in $body$ >>
| (rf,lb)::xs -> <:expr< let $rec:rf$ $lb$ in $exp_let_bindings body xs$ >>
EXTEND Gram
GLOBAL: expr;
let_binding_seq: [[ rf = opt_rec; lb = let_binding -> (rf,lb) ]];
expr: BEFORE ":="
[ "where"
[ e = SELF; "where"; lb = LIST1 let_binding_seq SEP "and" ->
<:expr< $exp_let_bindings e lb$ >> ]
];
END
end
module M = Register.OCamlSyntaxExtension(Id)(Make)