Skip to content

Instantly share code, notes, and snippets.

@camlspotter
Created December 15, 2013 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save camlspotter/7968496 to your computer and use it in GitHub Desktop.
Save camlspotter/7968496 to your computer and use it in GitHub Desktop.
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