From: Gerd Stolpmann <info@gerd-stolpmann.de>
To: skaller@users.sourceforge.net
Cc: Chris King <colanderman@gmail.com>,
"O'Caml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Thread safe Str
Date: Tue, 11 Jan 2005 21:30:17 +0100 [thread overview]
Message-ID: <1105475416.15581.105.camel@ice.gerd-stolpmann.de> (raw)
In-Reply-To: <1105466124.2574.48.camel@pelican.wigram>
On Die, 2005-01-11 at 18:55, skaller wrote:
> On Tue, 2005-01-11 at 23:08, Gerd Stolpmann wrote:
>
>
> > Capturing just for the purpose of string extraction is not problematic.
>
> Unfortunately you're wrong. I had in fact hoped this was not
> the case, but having read a couple of paper on it,
> I now know that, unfortunately, they are. (See below).
It's a matter of taste. Granted, you cannot define capturing directly
for an automaton, only by a possibly poor backtracking algorithm. (This
means the approach is "definition by algorithm", not really the best way
to do it.)
Which leads to a more serious problem: One must know the algorithm of
the implementation to avoid running into a hard backtracking case (which
can be exponential). There are a lot of tutorials explaining good and
bad regexps. The lex-type scanners do not have this problem (but you may
run into space problems instead because the automaton becomes large).
> Alain Frisch is one of the leaders in this area, perhaps
> he can explain it better. You can get Cardelli and Frisch
> paper here:
>
> http://felix.sf.net/papers/greedy.pdf
When I understand the direction correctly, this paper explains how to
avoid backtracking by using a two-pass algorithm (automaton plus
expression-based postprocessing to get the captured strings).
> another by Ville Laurikari here:
>
> http://felix.sf.net/papers/spire2000-tnfa.ps
>
> and his Master thesis on the topic here:
>
> http://felix.sf.net/papers/regex-submatch.ps
>
> [and if you can figure out how to actually build
> a tagged DFA after reading any of that please let
> me know .. ]
>
> Frisch's algorithm used in CDuce works with a forward
> pass that ignores captures, but records the automaton states,
> and then a backwards pass the extracts the information
> (CDuce actually builds trees).
>
> Unfortunately this has a problem: it requires a
> bidirectional iterator, whereas a DFA only requires
> an input iterator. (NFA's require forward iterators)
For string regexps this is not a big problem, the string is in memory.
For XML, this is more a problem, especially when the XML document is
only available event by event (processing large documents).
Gerd
--
------------------------------------------------------------
Gerd Stolpmann * Viktoriastr. 45 * 64293 Darmstadt * Germany
gerd@gerd-stolpmann.de http://www.gerd-stolpmann.de
------------------------------------------------------------
next prev parent reply other threads:[~2005-01-11 20:30 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 [this message]
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
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=1105475416.15581.105.camel@ice.gerd-stolpmann.de \
--to=info@gerd-stolpmann.de \
--cc=caml-list@inria.fr \
--cc=colanderman@gmail.com \
--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