On 4/10/07, Hugo Ferreira <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Nicolas Pouillard wrote:
> > On 4/8/07, Martin Jambon <[EMAIL PROTECTED]> wrote:
> >> On Sat, 7 Apr 2007, Nicolas Pouillard wrote:
> >>
> >>> On 4/5/07, Martin Jambon <[EMAIL PROTECTED]> wrote:
> >>>> On Thu, 5 Apr 2007, Hugo Ferreira wrote:
> >>>>
> >
[...]

>
> Just a comment: my greatest difficulty with camlp4 is twofold:
>
> - knowing how the AST maps to the actual Ocaml syntax.

You can ask to camlp4 itself!

Using the old one...

$ cat test.ml
(* here is some expression that you want to understand *)
fun e -> <:expr< let x= HEAP in $e$ >>

$ camlp4o q_MLast.cmo pr_o.cmo test.ml
let _ =
  fun e ->
    MLast.ExLet
      (_loc, false, [MLast.PaLid (_loc, "x"), MLast.ExUid (_loc, "HEAP")], e)

> - knowing when/where the camlp4 parser does its transformations so that
> I may alter these transformations (match and replace expressions).

That's not really transformations of the AST.

However there is some grammar tranformations:
When you add a rule to a grammar entry at a specific level camlp4
insert it in a tree to factor out the prefix or rules as much as
possible.

e1 = SELF; "+"; e2 = SELF -> ...
e1 = SELF; "*"; e2 = SELF -> ...

is in fact something like:

e1 = SELF; [ "+"; e2 = SELF -> ... | "*";  e2 = SELF -> ... ]

So if you add something make it as much as possible a prefix of existing ones.

[...]

> In effect I write Ocaml "expression" which is automatically matched and
> I only need write an Ocaml expression to introduce the changes I want.
> All this using simply using the quotation system. The rules and the AST
> structure itself should, in my humble opinion, be avoided.

Indeed, extension that are highly dependent on the actual grammar
should be avoided.

> This will also allow the underlying camlp4 system to change without unduly
> affecting user's code.

Exactly!

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

Reply via email to