Created
December 15, 2013 03:28
-
-
Save camlspotter/7968496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Id = struct | |
let name = "pa_fun_fields" | |
let version = "1.0" | |
end | |
open Camlp4 | |
module Make (Syntax : Sig.Camlp4Syntax) = struct | |
include Syntax | |
EXTEND Gram | |
GLOBAL: expr | |
; | |
expr: LEVEL "simple" | |
[ | |
[ "("; "."; l = label_longident; ")" | |
-> <:expr< fun x -> x . $id:l$ >> (* [l : ident] but [e : expr] at [x.e] *) | |
| "("; "#"; l = label; ")" | |
-> <:expr< fun x -> x # $l$ >> | |
] | |
]; | |
END | |
end | |
let module M = Register.OCamlSyntaxExtension(Id)(Make) in () |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment