diff options
author | Alain Frisch <alain@frisch.fr> | 2013-09-26 08:27:00 +0000 |
---|---|---|
committer | Alain Frisch <alain@frisch.fr> | 2013-09-26 08:27:00 +0000 |
commit | d4230ffaa81d8affe46c00da8a654ced53c0dc3f (patch) | |
tree | 19531aa3dec48c1de4eec9ede22ca4b83539ffac | |
parent | 7994b4db284f5f43d04d2e849f70508688ab9496 (diff) | |
download | ocaml-d4230ffaa81d8affe46c00da8a654ced53c0dc3f.tar.gz |
Adapt one more example.
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14183 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r-- | experimental/frisch/ppx_matches.ml | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/experimental/frisch/ppx_matches.ml b/experimental/frisch/ppx_matches.ml index 7c26e67b64..52ac722d70 100644 --- a/experimental/frisch/ppx_matches.ml +++ b/experimental/frisch/ppx_matches.ml @@ -7,21 +7,21 @@ open Asttypes open Parsetree open Ast_helper -let mapper = - object(this) - inherit Ast_mapper.mapper as super - - method! expr e = - match e.pexp_desc with - | Pexp_extension({txt="matches";_}, PPat (p, guard)) -> - let p = this # pat p in - let guard = Ast_mapper.map_opt (this # expr) guard in +let mapper _args = + let open Ast_mapper in + let super = default_mapper in + let my_expr this e = + match e.pexp_desc with + | Pexp_extension({txt="matches";_}, PPat (p, guard)) -> + let p = pat this p in + let guard = Ast_mapper.map_opt (expr this) guard in Exp.function_ ~loc:e.pexp_loc - [ - Exp.case p ?guard (Convenience.constr "true" []); - Exp.case (Pat.any ()) (Convenience.constr "false" []); - ] - | _ -> super#expr e - end + [ + Exp.case p ?guard (Convenience.constr "true" []); + Exp.case (Pat.any ()) (Convenience.constr "false" []); + ] + | _ -> super.expr this e + in + {super with expr = my_expr} -let () = Ast_mapper.main mapper +let () = Ast_mapper.run_main mapper |