caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Hendrik Tews <tews@tcs.inf.tu-dresden.de>
To: Ocaml <caml-list@inria.fr>
Subject: Re: [Caml-list] Camlp4 in a Unix pipe
Date: Thu, 24 Nov 2005 12:30:19 +0100	[thread overview]
Message-ID: <rlr796z3jo.fsf@ithif59.inf.tu-dresden.de> (raw)
In-Reply-To: <4384522B.3010309@barettadeit.com>

Alessandro Baretta <a.baretta@barettadeit.com> writes:

   I'm not sure I understand your point.
   
   My original attempt at this problem was the following:
   
   cat - | camlp4 pa_o.cmo pr_o.cmo
   
If you don't set a filename nothing is done, see function go in
camlp4/camlp4/argl.ml: 

      if Pcaml.input_file.val <> "" then
        match file_kind.val with
        [ Intf -> process_intf ()
        | Impl -> process_impl () ]
      else ()

(the input_file reference is set via -intf, -impl and from
arguments ending in .ml or .mli)

   This seemed strange to me, because, according the camlp4 manpage
   
Agreed, the docs could be more precise. But all the camlp4 docs
are quite outdated.

   alex@alex:~/void$ cat - | camlp4 pa_o.cmo pr_r.cmo -impl /dev/stdin
   let 1 = 1;;
   I/O error: Illegal seek

pr_r and pr_o contain seek's to copy parts of source (for
instance comments) into the output. It will work if you use
another printer.

   alex@alex:~/void$ cat - | camlp4 pa_o.cmo pr_r.cmo -impl -
   
   The '-' option to camlp4 is undocumented, as far as I can see from the

I wouldn't say '-' is an option, rather it is a special filename,
see parse_file in camlp4/camlp4/argl.ml: 

  let name = Pcaml.input_file.val in
  do {
    Pcaml.warning.val := print_warning;
    let ic = if name = "-" then stdin else open_in_bin name in


Alessandro Baretta continues:

   found this clue. Also, if '-' means to read from stdin, as is the case
   with many command line tools, why should this work any better than

Because the offending seeks are covered by if's, like in
apply_printer, camlp4/etc/pr_o.ml:

  if Pcaml.input_file.val <> "-" && Pcaml.input_file.val <> "" then do {

Bye,

Hendrik


  reply	other threads:[~2005-11-24 11:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 14:20 Alessandro Baretta
2005-11-21  9:39 ` [Caml-list] " Hendrik Tews
2005-11-22 16:42   ` Alessandro Baretta
2005-11-22 18:15     ` Florian Hars
2005-11-23 11:27       ` Alessandro Baretta
2005-11-24 11:30         ` Hendrik Tews [this message]
2005-11-22 22:34     ` Christophe Raffalli
2005-11-23  9:05     ` Hendrik Tews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=rlr796z3jo.fsf@ithif59.inf.tu-dresden.de \
    --to=tews@tcs.inf.tu-dresden.de \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).