caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Behavior of camlp4o when used with -pp?
@ 2009-02-10 20:20 David Rajchenbach-Teller
  2009-02-10 21:10 ` [Caml-list] " Jake Donham
  0 siblings, 1 reply; 3+ messages in thread
From: David Rajchenbach-Teller @ 2009-02-10 20:20 UTC (permalink / raw)
  To: OCaml

    Dear list,
 I'm currently faced with a weird behaviour (bug?) of camlp4.

Assuming the existence of a file foo.ml, possibly empty.

camlp4o -no_comments foo.ml

understands option "-no_comments" correctly and pretty-prints the
contents of foo.ml, minus comments


However, when using camlp4o as a preprocessor,

ocamlc -i -pp "camlp4o -no_comments" foo.ml
-no_comments: unknown or misused option
Use option -help for usage
File "foo.ml", line 1, characters 0-1:
Error: Preprocessor error



Is this normal? Is there a workaround for this?

Thanks,
 David

-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
   « Ce matin Un crétin A tué un chercheur. » (air connu)
   Latest News of French Research: System being liquidated. Researchers angry.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Behavior of camlp4o when used with -pp?
  2009-02-10 20:20 Behavior of camlp4o when used with -pp? David Rajchenbach-Teller
@ 2009-02-10 21:10 ` Jake Donham
  2009-02-10 22:05   ` David Rajchenbach-Teller
  0 siblings, 1 reply; 3+ messages in thread
From: Jake Donham @ 2009-02-10 21:10 UTC (permalink / raw)
  To: David Rajchenbach-Teller; +Cc: OCaml

[-- Attachment #1: Type: text/plain, Size: 1077 bytes --]

On Tue, Feb 10, 2009 at 12:20 PM, David Rajchenbach-Teller <
David.Teller@ens-lyon.org> wrote:

> camlp4o -no_comments foo.ml
>
> understands option "-no_comments" correctly and pretty-prints the
> contents of foo.ml, minus comments
>
>
> However, when using camlp4o as a preprocessor,
>
> ocamlc -i -pp "camlp4o -no_comments" foo.ml
> -no_comments: unknown or misused option
> Use option -help for usage
> File "foo.ml", line 1, characters 0-1:
> Error: Preprocessor error
>

The default Camlp4 printer is the "auto" printer, which checks if its output
fd is a TTY; if so it uses the OCaml printer (which has -no_comments), if
not it uses the DumpOCamlAst printer (which does not). The point of this is
to pass the serialized AST through to the compiler without reparsing, for
speed and also to preserve the original locations in code that's been
transformed by a syntax extension.

Basically there is no reason to use -no_comments with -pp. But if you really
want to you can also give -printer o to camlp4o so you always get the OCaml
printer instead of autoselecting.

Jake

[-- Attachment #2: Type: text/html, Size: 1630 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] Behavior of camlp4o when used with -pp?
  2009-02-10 21:10 ` [Caml-list] " Jake Donham
@ 2009-02-10 22:05   ` David Rajchenbach-Teller
  0 siblings, 0 replies; 3+ messages in thread
From: David Rajchenbach-Teller @ 2009-02-10 22:05 UTC (permalink / raw)
  To: Jake Donham; +Cc: OCaml

Well, in that case, it's an attempt to work around a camlp4 bug. And I'm
not attempting to use -no_comments itself, it's just the shortest
example I could find of the behavior.

Thanks,
 David

On Tue, 2009-02-10 at 13:10 -0800, Jake Donham wrote:
> Basically there is no reason to use -no_comments with -pp. But if you
> really want to you can also give -printer o to camlp4o so you always
> get the OCaml printer instead of autoselecting.
> 
> Jake
> 
-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
   « Ce matin Un crétin A tué un chercheur. » (air connu)
   Latest News of French Research: System being liquidated. Researchers angry.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-02-10 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-10 20:20 Behavior of camlp4o when used with -pp? David Rajchenbach-Teller
2009-02-10 21:10 ` [Caml-list] " Jake Donham
2009-02-10 22:05   ` David Rajchenbach-Teller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).