Version française
Home     About     Download     Resources     Contact us    
Browse thread
OCaml IDE (Camlp4 for code formatting)
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Nathaniel J. Gaylinn <ngaylinn@c...>
Subject: Re: [Caml-list] OCaml IDE (Camlp4 for code formatting)


On Tue, 21 Jun 2005, Hendrik Tews wrote:

>    I understand why it makes this change,
>
> Could you explain? (Because I don't understand. "let _ = 5" and
> "5" are different internally.)

Heh, I didn't realize that they were handled different internally  ;)  I
thought it was a reasonable thing to do because it is more explicit and
equivalent, but if it isn't actually equivalent...

>
>    On a similar note, is there any reference to the format in which Camlp4
>    outputs its syntax tree?
>
> I don't think so. It is defined in the compiler sources and
> probably not for the general public. However, you can define your
> own camlp4 printers: Write a module that overwrites
> Pcaml.print_implem and load this module into camlp4. The function
> that you plug into Pcaml.print_implem has to pattern match on
> camlp4's ast, which is defined in mLast.mli. You can use the
> constructors from mLast.mli or the quotations from q_MLast. See
> the source of pr_o or other pretty printers (like in my ocamlp4
> package).

Would it be difficult to write a printer that had much direct access with
the original file? That's something that I'd quite obviously need.

In any way, I think I'm going to try to do more research into how Tuareg
does its indentation. It's unfortunately not well documented, but it has
the added benefit of being able to indent one line at a time. I'll take a
look into writing a new printer, but I suspect that that will be the
harder route... correct me if I'm wrong!

  -- Nate