From: David Monniaux <David.Monniaux@ens.fr>
To: Liste CAML <caml-list@inria.fr>
Subject: programmer-friendly regexp package
Date: Thu, 12 Oct 2000 18:42:56 +0200 (MET DST) [thread overview]
Message-ID: <Pine.GSO.4.03.10010121820590.5365-100000@basilic.ens.fr> (raw)
Heya all camlers,
I have an alpha version of a CamlP4 preprocessing package enabling the use
of a straightforward, easy syntax for regexps:
http://www.di.ens.fr/~monniaux/download/regexp.tar.gz
(* Defines and compiles the regexp; substrings to be extracted are
labelled "foo" and "bar" *)
let regexp = let k = "zzz" in (* notice the support for embedded
variables and expressions *)
RE { "X" (foo: (['0'-'9']+))? bar:(['a'-'z']+) "Y" k };;
(* Now the actual pattern matching *)
REmatch "+++X45aaabYzzz" with
regexp as contents ~bar ~foo ->
Printf.printf "str=%s bar=%s foo=%s\n" contents bar
(match foo with Some x -> x | None -> "<NONE>")
| _ -> Printf.printf "Not found!\n";;
It uses the "Str" library, but it may come to support PCRE as well.
It requires OCaml and CamlP4 3.00 and makes use of the labels (as a side
effect, when using the traditional mode, the user must supply the various
labels in the "as" clause in ASCII ordering).
No documentation is available yet. The syntax for the regexps is supposed
to be compatible with ocamllex. There are currently pitfalls in the
handling of character sets.
I specifically request comments on how to make this hack better, esp. with
syntactic choices. I plan to support the predefinition of regexp parts; it
is not yet decided whether the nesting will be preprocessing-time or
execution-time, or both.
Regards,
David Monniaux http://www.di.ens.fr/~monniaux
Laboratoire d'informatique de l'École Normale Supérieure,
Paris, France
reply other threads:[~2000-10-12 16:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.GSO.4.03.10010121820590.5365-100000@basilic.ens.fr \
--to=david.monniaux@ens.fr \
--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