On 3/30/07, Hugo Ferreira <[EMAIL PROTECTED]> wrote: > > Hello, > > I have been been trying to figure out how to substitute a function call > by another. Lets assume I have something like: > > let _ = Logic.print term in > ... > > and I would like to change that to: > > let _ = Logic.print env term in > ... > > where env is declared by the extension. > > Looking at the Pcaml module I would say I am after a Pcaml.expr (Because > at first I thought we have a "let" label here, so this should be it). > > | "expr1" LEFTA > ... > | "let"; OPT "rec"; LIST1 let_binding SEP "and"; "in"; expr LEVEL "top"
Please don't do this. Not that way... You should traverse the AST and then substitute function calls. In the new camlp4 one can do that easily with filters: open Camlp4.PreCast;; AstFilters.register_str_item_filter begin Ast.map_expr begin function | <:[EMAIL PROTECTED]< Logic.print $e$ >> -> <:[EMAIL PROTECTED]< Logic.print env $e$ >> | e -> e end end#str_item;; Cheers, -- Nicolas Pouillard --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ocaml-developer" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/ocaml-developer?hl=en For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html -~----------~----~----~----~------~----~------~--~---
