From: Martin Jambon <martin_jambon@emailuser.net>
To: skaller <skaller@users.sourceforge.net>
Cc: "O'Caml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Thread safe Str
Date: Wed, 12 Jan 2005 12:12:43 -0800 (PST) [thread overview]
Message-ID: <Pine.LNX.4.44.0501121055390.1299-100000@localhost> (raw)
In-Reply-To: <1105516763.2574.231.camel@pelican.wigram>
On 12 Jan 2005, skaller wrote:
> On Wed, 2005-01-12 at 07:53, Martin Jambon wrote:
> > On 11 Jan 2005, skaller wrote:
>
> > > See the ulex package for a model. The problem with micmatch
> > > is precisely that it does use Str.
> >
> > It uses either Str or PCRE.
>
> > You can also integrate ulex by yourself if it is possible.
>
> I'm not sure .. ulex doesn't use NFA's does it?
> AFIAK it doesn't support captures.
>
> The problem with micmatch is that it probably doesn't do what
> can be done with a system supported in the core language,
> linear matching over all cases. Felix does do it: in this code
>
> regmatch .. with
> | re1 => ..
> | re2 => ..
> | re3 =>..
> endmatch
>
> the input characters (from ...) are read exactly once,
> not only is there no backtracking, since a DFA is used,
> but it isn't a sequence of comparisons (it's a DFA based
> tokeniser, the token selecting the RHS expression).
>
> I would guess micmatch does not support that, although
> it probably could.
Sorry, I don't know the details of what can be done with DFA or NFA.
The idea of micmatch is to be compatible with the behavior of the regular
match...with, which allows us to mix both forms of pattern matching
(returning the first match, not the longest match).
The following returns `Case1:
match "abcde", 1 with
RE "abc", 1 -> `Case1
| RE "abcd", _ -> `Case2
And the following simplified code still returns `Case1:
match "abcde" with
RE "abc" -> `Case1
| RE "abcd" -> `Case2
And similarly this returns "abc":
match "abcde" with
RE ("abc" | "abcd" as x) -> x
I could implement the following syntax:
match subj with
RE (re1 as x1 => `Case1 x1 as y) | (re2 as x2 => `Case2 x2 as y) -> y
And the simplified forms:
match subj with
RE (re1 => `Case1 as y) | (re2 => `Case2 as y) -> y
match subj with
RE (re1 => f1 ()) | (re2 => f2 ()) -> ()
We could then do sophisticated things like that:
match subj with
RE ... ((re1 => f1 ()) | (re2 => raise Try_next_please)) ... -> ...
| ... (* next *) -> ...
but I don't know if these additions would be a good thing.
Martin
--
Martin Jambon, PhD
Researcher in Structural Bioinformatics since the 20th Century
The Burnham Institute http://www.burnham.org
San Diego, California
next prev parent reply other threads:[~2005-01-12 20:13 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-09 19:30 Christophe TROESTLER
2005-01-09 20:57 ` [Caml-list] " Gerd Stolpmann
2005-01-10 9:57 ` Alex Baretta
2005-01-10 15:49 ` Xavier Leroy
2005-01-10 16:39 ` Richard Jones
2005-01-10 18:21 ` Eric C. Cooper
2005-01-10 20:25 ` Martin Jambon
2005-01-11 3:54 ` skaller
2005-01-11 7:03 ` Chris King
2005-01-11 8:06 ` skaller
2005-01-11 12:08 ` Gerd Stolpmann
2005-01-11 17:55 ` skaller
2005-01-11 20:30 ` Gerd Stolpmann
2005-01-12 7:42 ` skaller
[not found] ` <875c7e070501111007dc3e86d@mail.gmail.com>
[not found] ` <1105471138.2574.88.camel@pelican.wigram>
[not found] ` <875c7e07050111115618692184@mail.gmail.com>
2005-01-11 19:58 ` Chris King
2005-01-11 20:53 ` Martin Jambon
2005-01-12 7:59 ` skaller
2005-01-12 20:12 ` Martin Jambon [this message]
2005-01-11 6:41 ` Chris King
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.LNX.4.44.0501121055390.1299-100000@localhost \
--to=martin_jambon@emailuser.net \
--cc=caml-list@inria.fr \
--cc=skaller@users.sourceforge.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