From: Chris King <colanderman@gmail.com>
To: "O'Caml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Thread safe Str
Date: Tue, 11 Jan 2005 14:58:52 -0500 [thread overview]
Message-ID: <875c7e0705011111583fac3741@mail.gmail.com> (raw)
In-Reply-To: <875c7e07050111115618692184@mail.gmail.com>
Forgot to CC this to the list, sorry if anyone gets a dupe....
> I'm sure you'd agree there are separable issues here:
>
> (1) using a string encoding of a regexp as opposed to
> a lex like one -- this has nothing to do with
> captures.
Yes. As I stated in another e-mail in this thread, I'd love to see an
API that exposes the parse tree of a regexp.
> (2) Captures
I'd like to add (3) Parsing vs. substitution. You can't effectively
do the latter without captures (of course it can be done but it's
messy).
> The fact that the regexp syntax is not checked statically
> isn't relevant in a dynamic language since the typing
> of the rest of the program isn't either.
I think we're talking about different things... I used the "s//g"
syntax to represent the substitution function in whatever language is
being used, not as an example of something to be compiled. (regexp
"foo(.*)bar") certainly has a static type, and if it's malformed it
simply raises an exception.
> I'm trying to provide that in Felix. It has Python style literals,
> and Python style substrings. However it is still clumbsy compared
> with Perl (I guess .. I can't write Perl ..)
Perl string mangling is clumsy compared with Python. The key is that
Python treats strings as arrays (or lists) of characters.
> > True. Performing multiple replacements on a single string with a
> > regexp is retarded. But so is writing a lexer for a simple one-shot
> > replacement job.
>
> That depends on how hard it is to write a lexer.
Specifically, a lexer whose input and output are both strings and
which performs substitution. Not pretty, unless captures are
provided.
> At present, Felix regexps have to be constants. It will be possible
> in the bootstrapped compiler to generate them as text, and then
> compile and link (i.e. there will be a function sort of like 'eval').
That's not acceptable for, say, an incremental search, though, where a
new regexp must be generated on each keystroke. (Yes I know regexps
aren't the best way to go about that but I'm sure there are better
examples.)
> > My point is just that regexps are useful enough to co-exist with lexers.
>
> But they're the same thing. Lexer provide regular definitions,
> which is just a way of naming regexps, and reusing the regexps
> by providing the name.
Not in the form of lex/flex/ocamllex. Yes, lexer token definitions
are equivalent to regexps, but everything else about them is different
(specifically, lexers are event-based, and don't provied captures).
I'd love to see a regexp engine allowing dynamic creation of
token-based regexps, complete with captures. It could easily serve as
both the base of a lexer and a substitution engine. Heck, that sounds
like a fun project... what I am doing this weekend? :P
next prev parent reply other threads:[~2005-01-11 19:58 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 [this message]
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=875c7e0705011111583fac3741@mail.gmail.com \
--to=colanderman@gmail.com \
--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