From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 15BCFBC69 for ; Fri, 23 Feb 2007 21:21:45 +0100 (CET) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.242]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l1NKLhF4030388 for ; Fri, 23 Feb 2007 21:21:44 +0100 Received: by an-out-0708.google.com with SMTP id d26so461375and for ; Fri, 23 Feb 2007 12:21:42 -0800 (PST) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=DVF/XD+i6uAHzR7wFteYgMzPa0GbB+FldOVnzn+3YqsQH32XGtlTVtHlRty2A2C1rvKBYbe8BD+hFZp6TYSUTb+PcQvbFH9cA0N5r1oXZEhJ4wrx8PeVIfvStBAtNYflvwhw3HoZHU6AXDNvbgm3c/ETZGYCFCSbcx72MrGyDO8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=fKP+m7XwAmmWLEYW6ywmFo+LgivgXAQN+xKjkMxGKL0DKRzJrECPFxLpu9f7A7N+3JSrjKVZkSc/FT0qLA9S/oUzk3IuzYj8QpeFlVX2HBFNtNWZqvwDxI8Bnzj89u1Mz4fSKFk2BDu2Gv6QEYpoKQUyL2AbfWoieChfDEcInJM= Received: by 10.115.89.1 with SMTP id r1mr1187147wal.1172262098962; Fri, 23 Feb 2007 12:21:38 -0800 (PST) Received: by 10.115.72.15 with HTTP; Fri, 23 Feb 2007 12:21:38 -0800 (PST) Message-ID: Date: Fri, 23 Feb 2007 12:21:38 -0800 From: "Francois Rouaix" Sender: francois.rouaix@gmail.com To: "Joel Reymont" Subject: Re: [Caml-list] Case-insensitive lexing Cc: caml-list@inria.fr In-Reply-To: <23E977DC-77FF-44A2-8675-5EAA8F61505F@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_69777_12632047.1172262098918" References: <23E977DC-77FF-44A2-8675-5EAA8F61505F@gmail.com> X-Google-Sender-Auth: 65bdade2f5d05617 X-Miltered: at concorde with ID 45DF4CD7.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lexing:01 lexbuf:01 lowercase:01 lexer:01 lexer:01 ocamllex:01 lexeme:01 lexbuf:01 hashtbl:01 beginner's:01 ocaml:01 bug:01 lowercase:01 ocamllex:01 lexeme:01 ------=_Part_69777_12632047.1172262098918 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline You could wrap existing lexbuf generating functions with a layer that converts everything to uppercase or lowercase, and write your lexer accordingly? Won't work if you have constants strings, but otherwise it puts all the case logic in one place. On 2/23/07, Joel Reymont wrote: > > Folks, > > Is there a way to make a case-insensitive lexer with ocamllex? > > The only answer I was able to find is the following from John Skaller: > > | identifier { > let x = toupper (lexeme lexbuf) in > try Hashtbl.find keywords x > With Not_found -> x > } > > Thanks, Joel > > -- > http://wagerlabs.com/ > > > > > > _______________________________________________ > Caml-list mailing list. Subscription management: > http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list > Archives: http://caml.inria.fr > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs > ------=_Part_69777_12632047.1172262098918 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline You could wrap existing lexbuf generating functions with a layer that converts everything to uppercase or lowercase, and write your lexer accordingly? Won't work if you have constants strings, but otherwise it puts all the case logic in one place.


On 2/23/07, Joel Reymont <joelr1@gmail.com> wrote:
Folks,

Is there a way to make a case-insensitive lexer with ocamllex?

The only answer I was able to find is the following from John Skaller:

| identifier {
   let x = toupper (lexeme lexbuf) in
   try Hashtbl.find keywords x
   With Not_found -> x
}

        Thanks, Joel

--
http://wagerlabs.com/





_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

------=_Part_69777_12632047.1172262098918--