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: OCaml IDE (Camlp4 for code formatting)

One feature I want my program to have is autoformatting, that is, the
ability to go through and indent source code for you in some standard way.
At first glance, OCamlp4 seemed like the way to go for this, but under
further inspection I'm not sure this is true.

My main problem with OCamlp4 is that it changes the input source code!
Expressions like "5;;" that are just used for side effect are replaced
with "let _ = 5;;" which is equivalent, but different code. I understand
why it makes this change, but since my program is intended for students
the last thing I want is for it to change their code, even in a trivial
way such as this. Also, I'm pretty sure I've observed OCamlp4 eating
comments, which obviously is no good.

Is there a nice way to get OCamlp4 not to change the source code it's
given in any way except for spacing? Is there some other convenient way to
autoformat OCaml source? Is there a documented standard of what properly
formatted OCaml code should look like? It's hard to derive a set of
indentation rules just from anecdotal code snippets.

On a similar note, is there any reference to the format in which Camlp4
outputs its syntax tree? I might be able to use the syntax tree for
formatting and other purposes in my ide, but I can't at all read the
binary format it spits out. Is this something easy to read, or is it only
meant to be accessed by OCaml itself?

Thanks,

  -- Nate Gaylinn