From: skaller <skaller@users.sourceforge.net>
To: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>
Cc: Radu Grigore <radugrigore@gmail.com>,
"yjc01@doc.ic.ac.uk" <yjc01@doc.ic.ac.uk>,
caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] index of substring
Date: 29 Jan 2005 00:31:09 +1100 [thread overview]
Message-ID: <1106919068.23562.74.camel@pelican.wigram> (raw)
In-Reply-To: <16889.64814.187592.903001@gargle.gargle.HOWL>
On Fri, 2005-01-28 at 19:51, Jean-Christophe Filliatre wrote:
> But that's precisely why ocamllex is so a powerful tool. You only need
> to know that ocamllex is building a set of mutually recusvive
> functions with the lexbuf as argument and then you are not limited in
> what you can do in the actions. You can even pass additional arguments
> to the lexing functions.
Yes, this is all true, provided you think of your code
as a stream pattern matcher: unfortunately lexbufs are
mutable rather than functional (which I suppose is necessary
for performance).
> I like to think about ocamllex as a general-purpose tool to insert a
> bit of regular expressions in ocaml programs
Yes, although the code is control inverted initially,
that is, your client action code is *called* with a lexeme and
lexbuf (and callbacks are a bit nasty sometimes).
Of course you also call the lexer to fetch what the callback
returns .. so yes I guess you can see this as 'inserting' a bit
of regular expressions into an ocaml program.
Interesting tradeoffs here! Ocaml lexers allow input
iterators (eg file streams) by using a lexbuf,
but aren't functional because the lexbuf modified.
Felix uses a C++ style forward iterator, and is
purely functional -- the end of lexeme pointer is
returned to be used in the next call as the new
starting point -- but if you want to handle
an input iterator you have to manage the buffering
yourself. [Ahem .. which can't be done transparently
at the moment .. woops .. design fault!]
--
John Skaller, mailto:skaller@users.sf.net
voice: 061-2-9660-0850,
snail: PO BOX 401 Glebe NSW 2037 Australia
Checkout the Felix programming language http://felix.sf.net
next prev parent reply other threads:[~2005-01-28 13:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-01-27 0:41 yjc01
2005-01-27 4:21 ` [Caml-list] " Matt Gushee
2005-01-27 6:44 ` Radu Grigore
2005-01-27 9:36 ` skaller
2005-01-27 10:20 ` Jean-Christophe Filliatre
2005-01-27 16:55 ` skaller
2005-01-27 17:20 ` Radu Grigore
2005-01-28 8:51 ` Jean-Christophe Filliatre
2005-01-28 13:31 ` skaller [this message]
2005-01-27 8:37 ` Oliver Bandel
2005-01-27 9:17 ` Xavier Leroy
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=1106919068.23562.74.camel@pelican.wigram \
--to=skaller@users.sourceforge.net \
--cc=Jean-Christophe.Filliatre@lri.fr \
--cc=caml-list@inria.fr \
--cc=radugrigore@gmail.com \
--cc=yjc01@doc.ic.ac.uk \
/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;
as well as URLs for NNTP newsgroup(s).