From: Jon Harrop <jon@ffconsultancy.com>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Case-insensitive lexing
Date: Sat, 24 Feb 2007 02:46:13 +0000 [thread overview]
Message-ID: <200702240246.13960.jon@ffconsultancy.com> (raw)
In-Reply-To: <23E977DC-77FF-44A2-8675-5EAA8F61505F@gmail.com>
On Friday 23 February 2007 15:32, Joel Reymont wrote:
> Is there a way to make a case-insensitive lexer with ocamllex?
Preprocess the character stream, making all chars lower case before they even
reach ocamllex.
Take the existing definition of Lexing.from_channel:
let from_channel ic =
from_function (fun buf n -> input ic buf 0 n)
and alter it to change the case of chars as they are read (off the top of my
head):
let from_case_insensitive_channel ic =
let aux buf n =
let i = input ic buf 0 n in
for i=0 to i-1 do
buf.[i] <- Char.lowercase buf.[i]
done;
i in
from_function aux
Now create your lexbuf using from_case_insensitive_channel.
--
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists
prev parent reply other threads:[~2007-02-24 2:52 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
[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 [this message]
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=200702240246.13960.jon@ffconsultancy.com \
--to=jon@ffconsultancy.com \
--cc=caml-list@yquem.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