From: Pierre Weis <pierre.weis@inria.fr>
To: martin_jambon@emailuser.net (Martin Jambon)
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Printing text with holes
Date: Mon, 29 Sep 2003 19:00:16 +0200 (MET DST) [thread overview]
Message-ID: <200309291700.TAA27229@pauillac.inria.fr> (raw)
In-Reply-To: <Pine.LNX.4.40.0309291422530.2504-100000@pc-bioinfo1> from Martin Jambon at "Sep 29, 103 03:16:38 pm"
Hello,
> I am curious to know what people use to print long text written in a
> natural language, and containing many holes, like dynamically generated
> web pages.
[...]
> Does anyone need this kind of approach?
> Any better ideas?
>
> I put my implementation here (it is quite ugly, I still ignore everything
> about Camlp4):
> http://martin.jambon.free.fr/bazar/printfer.tar.gz
Many people use the same approach with dollars. In the 3.07 release of
Objective Caml there is some support to easily obtain such a feature:
in the interface of the module Buffer, we find
val add_substitute : t -> (string -> string) -> string -> unit
(** [add_substitute b f s] appends the string pattern [s] at the end
of the buffer [b] with substitution.
The substitution process looks for variables into
the pattern and substitutes each variable name by its value, as
obtained by applying the mapping [f] to the variable name. Inside the
string pattern, a variable name immediately follows a non-escaped
[$] character and is one of the following:
- a non empty sequence of alphanumeric or [_] characters,
- an arbitrary sequence of characters enclosed by a pair of
matching parentheses or curly brackets.
An escaped [$] character is a [$] that immediately follows a backslash
character; it then stands for a plain [$].
Raise [Not_found] if the closing character of a parenthesized variable
cannot be found. *)
This may be used to create strings with $identifiers to expand in them.
Hope this helps,
Pierre Weis
INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
next prev parent reply other threads:[~2003-09-29 17:00 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-29 13:16 Martin Jambon
2003-09-29 14:10 ` Christian Lindig
2003-09-29 16:25 ` Benjamin Geer
2003-09-29 16:39 ` Brian Hurt
2003-09-29 17:45 ` Jean-Marc EBER
2003-09-29 18:22 ` Brian Hurt
2003-09-29 20:48 ` Pierre Weis
2003-09-29 21:52 ` Richard Jones
2003-09-29 22:07 ` Fred Yankowski
2003-09-29 22:14 ` Daniel M. Albro
2003-09-29 22:19 ` Richard Jones
2003-09-29 22:23 ` Matthieu Sozeau
2003-09-30 3:56 ` Brian Hurt
2003-09-30 4:40 ` Brian Hurt
2003-09-30 6:11 ` David Brown
2003-09-29 18:57 ` Martin Jambon
2003-09-29 21:25 ` Pierre Weis
2003-09-30 12:52 ` skaller
2003-09-30 17:48 ` Martin Jambon
2003-09-29 18:16 ` Richard Jones
2003-09-29 17:00 ` Pierre Weis [this message]
2003-09-29 17:03 ` Karl Zilles
2003-09-29 21:47 ` Pierre Weis
2003-09-30 7:20 ` Jean-Christophe Filliatre
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=200309291700.TAA27229@pauillac.inria.fr \
--to=pierre.weis@inria.fr \
--cc=caml-list@inria.fr \
--cc=martin_jambon@emailuser.net \
/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