Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Xavier Leroy <xavier.leroy@inria.fr>
To: John Max Skaller <skaller@ozemail.com.au>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] ocamllex -- ambiguous regex
Date: Mon, 1 Jul 2002 13:45:51 +0200	[thread overview]
Message-ID: <20020701134551.A32025@pauillac.inria.fr> (raw)
In-Reply-To: <3D1F3EFB.6090303@ozemail.com.au>; from skaller@ozemail.com.au on Mon, Jul 01, 2002 at 03:25:15AM +1000

> What happens if there is an ambiguous regexp in ocamllex input?
> [The manual doesn't say]

That's an oversight in the manual; thanks for reporting it.
If several regexps match a prefix of the input, the regexp selected is
- the one that matches the longest prefix (so-called "longest match rule")
- in case of tie on prefix length, the regexp that occurs first in the
  source .mll lexer.

For instance:
   "kwd"      { rule 1 }
 | ['a'-'z']+ { rule 2 }

The input "kwdkwd" will trigger rule 2 (longest match), but "kwd01"
will trigger rule 1 (first rule among the two that have longest match).

- Xavier Leroy

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  reply	other threads:[~2002-07-01 11:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-23 21:48 [Caml-list] Stack Overflow... (recursion in try-statement) Oliver Bandel
2002-04-23 22:23 ` Will Benton
2002-04-23 22:50 ` Oliver Bandel
2002-04-23 23:25   ` John Prevost
2002-05-21 18:34     ` [Caml-list] Is CVS version of ocaml faster? John Max Skaller
2002-05-22  3:03       ` Jacques Garrigue
2002-05-22 16:29         ` John Max Skaller
2002-06-30 17:25     ` [Caml-list] ocamllex -- ambiguous regex John Max Skaller
2002-07-01 11:45       ` Xavier Leroy [this message]
2002-06-30 17:27     ` [Caml-list] Manual broken -- set John Max Skaller
2002-04-24  1:01 ` [Caml-list] Stack Overflow... (recursion in try-statement) Warp
2002-04-24 13:22   ` Oliver Bandel
2002-04-24  4:10 ` John Prevost
2002-04-24  4:52 ` Alan Schmitt
2002-04-24  5:31   ` Charles Martin
2002-04-24 13:25   ` Oliver Bandel

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=20020701134551.A32025@pauillac.inria.fr \
    --to=xavier.leroy@inria.fr \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /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