caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Radu Grigore <radugrigore@gmail.com>
To: skaller@users.sourceforge.net
Cc: Jean-Christophe Filliatre <Jean-Christophe.Filliatre@lri.fr>,
	"yjc01@doc.ic.ac.uk" <yjc01@doc.ic.ac.uk>,
	caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] index of substring
Date: Thu, 27 Jan 2005 19:20:06 +0200	[thread overview]
Message-ID: <7f8e92aa050127092017e7f423@mail.gmail.com> (raw)
In-Reply-To: <1106844935.12114.62.camel@pelican.wigram>

On 28 Jan 2005 03:55:36 +1100, skaller <skaller@users.sourceforge.net> wrote:
> Well it doesn't handle (* or *) in strings ..

Making things complicated just for fun isn't actually fun.

The fact is that a finite automaton by itself cannot detect matching
delimiters. Finite implies that the automaton can't count (at least
countable sets) and matching requires counting. Sure, there are lots
of nuances here: what does countable mean when you use 32b for
integers,... but that's splitting the hair. The basic idea remains
even after you look at these additional details.

So if you want to detect matching delimiters you need a counter. You
can either use an explicit one or use the stack as Jean-Christophe
Filliatre did.

> In particular the recursion only works 'by luck of
> the implementation' that allows sharing of a lexbuf
> between two lexer functions

What do you mean "by luck"? The documentation clearly passes the
lexbuf from one lexer to the other a few times. If the spec says it's
possible then in what way is it "luck"?

>  -- who knows how
> the lexer handles fallbacks?

IMO adding a 
  _ -> failwith "some error message"
whenever the programmer fails to provide an explicit "else" branch is
just fine. In fact I would prefer a "compile" error to be emitted by
ocamllex (or at least a warning) when such a clause is missing from
one lexer.

-- 
regards,
 radu
http://rgrig.idilis.ro/


  reply	other threads:[~2005-01-27 17:20 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 [this message]
2005-01-28  8:51         ` Jean-Christophe Filliatre
2005-01-28 13:31           ` skaller
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=7f8e92aa050127092017e7f423@mail.gmail.com \
    --to=radugrigore@gmail.com \
    --cc=Jean-Christophe.Filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=skaller@users.sourceforge.net \
    --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).