From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Bruno De Fraine <Bruno.De.Fraine@vub.ac.be>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Format module for C-style syntax
Date: Tue, 06 Mar 2007 19:40:43 +0100 [thread overview]
Message-ID: <45EDB5AB.2000601@inria.fr> (raw)
In-Reply-To: <70DC8A37-C742-405E-83E4-2367664717F5@vub.ac.be>
> Has anybody used the Format module for pretty-printing C-style syntax?
> After reading the documentation ("Using the Format module"), I cannot
> get it to line up the braces in a manner that is convential for such a
> syntax.
Here is one possible solution:
let pretty_decl ppf (Procedure(name, body)) =
fprintf ppf "@[<hv 4>procedure %s {" name;
List.iter (fun (Call s) -> fprintf ppf "@ %s;" s) body;
fprintf ppf "@;<1 -4>}@]";;
The two tricks are:
1- using only one box that starts at "procedure", no need to start a new
box at the opening brace;
2- the "@;", a.k.a. print_break, with a negative offset that cancels
the indentation of the current block; it's a bit of a hack but
surprisingly useful.
Hope this helps,
- Xavier Leroy
next prev parent reply other threads:[~2007-03-06 18:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-06 18:07 Bruno De Fraine
2007-03-06 18:40 ` Xavier Leroy [this message]
2007-03-07 11:41 ` [Caml-list] " Christian Lindig
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=45EDB5AB.2000601@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=Bruno.De.Fraine@vub.ac.be \
--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