caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Martin Jambon <martin.jambon@ens-lyon.org>
To: Joel Reymont <joelr1@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Case-insensitive lexing
Date: Fri, 23 Feb 2007 11:04:29 -0800 (PST)	[thread overview]
Message-ID: <Pine.LNX.4.58.0702231047450.30925@localhost> (raw)
In-Reply-To: <7504EE4A-36DE-46EF-B60C-A9F4ADEEED6F@gmail.com>

On Fri, 23 Feb 2007, Joel Reymont wrote:

>
> On Feb 23, 2007, at 3:50 PM, Christian Lindig wrote:
>
> > I assume you define identifier to a sequence of upper and lower
> > characters. What is wrong with this solution and what would you
> > have liked to see instead?
>
> I was hoping not having to write this (from a Lex file):
>
> A       [Aa]
> B       [Bb]
> ..
> Y       [Yy]
> Z       [Zz]
>
> {A}{B}{O}{V}{E}                 { return(ABOVE); }
> {A}{G}{O}                       { return(AGO); }
> {A}{L}{E}{R}{T}                 { return(ALERT); }
>
> Or even uglier
>
> {N}{U}{M}{E}{R}{I}{C}{A}{R}{R}{A}{Y}{R}{E}{F}         ('ARRAY-NUM-
> REF, yytext)
> {T}{R}{U}{E}{F}{A}{L}{S}{E}{A}{R}{R}{A}{Y}            ('ARRAY-NUM,
> yytext)
> {T}{R}{U}{E}{F}{A}{L}{S}{E}{A}{R}{R}{A}{Y}{R}{E}{F}   ('ARRAY-NUM-
> REF, yytext)

The ocamllex version would look like:

let a = ['A' 'a']
let b = ['B' 'b']
...

  a b o v e                 { ABOVE }
| a g o                     { AGO }
| a l e r t                 { ALERT }


Note that in micmatch--which is not ocamllex but supports the same core
syntax--there is a tilde operator which makes the regexp case-insensitive
according to latin1. It doesn't work with every language or encoding
though.


Martin

--
Martin Jambon
http://martin.jambon.free.fr


  reply	other threads:[~2007-02-23 19:05 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-23 15:32 Joel Reymont
2007-02-23 15:41 ` [Caml-list] " Denis Bueno
     [not found] ` <011EB42A-05E3-4686-BED7-2DB8B2663221@cs.uni-sb.de>
2007-02-23 16:02   ` Joel Reymont
2007-02-23 19:04     ` Martin Jambon [this message]
     [not found]     ` <42EFE4CF-F2F8-4AD2-9909-D0CF027A17AD@cs.uni-sb.de>
2007-02-23 21:03       ` Joel Reymont
2007-02-23 22:51         ` Erik de Castro Lopo
2007-02-23 23:00           ` Jon Harrop
2007-02-23 23:39             ` Tom
2007-02-24  0:32               ` Jon Harrop
2007-03-17 19:55                 ` Oliver Bandel
2007-02-23 20:21 ` Francois Rouaix
2007-02-24  2:25 ` skaller
2007-02-24  2:46 ` Jon Harrop

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=Pine.LNX.4.58.0702231047450.30925@localhost \
    --to=martin.jambon@ens-lyon.org \
    --cc=caml-list@inria.fr \
    --cc=joelr1@gmail.com \
    /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).