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"


However I don't see any way of detecting when an expression is actual a 
function call. When I say function call I mean either a function with 
any number of its parameters defined.

In addition to this I figured that maybe the "let_binding" would give me 
this information but a top-level print Grammar.Entry.print does not show 
me anything.

Finally I found the definition of function application and used that as 
follows (just for testing):

let subst_func loc expr =
         let _ = print_endline "??????"
         in
         match expr with
         | <:expr< $f$ $arg$ >> -> let _ = print_endline "!!!!!!!"
                                   in
                                      expr
         | _ -> expr


EXTEND
   Pcaml.expr: LEVEL "expr1" [
     [
        e = Pcaml.expr  -> subst_func loc e
...


I now get a "stack overflow" exception, which in hindsight makes sense 
seeing as I keep return the same expression which is then processed 
again by the camlp4 parser.

So I have two problems:

1. How do I detect when we have a function call (not necessarily) an 
application.

2. How can I process such a general expressions without the stack 
overflow above.

Anyone have any experience/pointers with such issues.

TIA,
Hugo F.




--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to