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.7 required=5.0 tests=AWL,DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 18CC6BBAF for ; Sun, 8 Mar 2009 16:07:56 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AsACAEp7s0nZkrEBmWdsb2JhbACVKgEBAQEBCAsKBxGtfoEHjiUBBIQF X-IronPort-AV: E=Sophos;i="4.38,325,1233529200"; d="scan'208";a="22219486" Received: from web27001.mail.ukl.yahoo.com ([217.146.177.1]) by mail2-smtp-roc.national.inria.fr with SMTP; 08 Mar 2009 16:07:55 +0100 Received: (qmail 79804 invoked by uid 60001); 8 Mar 2009 15:07:55 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.fr; s=s1024; t=1236524875; bh=njDELtCWnE63rzcYokSmWwB/YUimJFaLK45hBx9CXSE=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=H8jhsJBBQY2WDrLcTmQHFcw/7Z918MemOqIUI3quVT+bUnoblX9Ww5kjwaaZpb23Kvh7PynzFlR+DGXSszF7Qeu50nje1eXk605lqWsdeDDtHfckL5BjyxYlZwTdGQGe3FTdUU6xRKslaWcfDPCXk0wgpKIA1M6GosiTsh8d8fI= DomainKey-Signature:a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Message-ID:X-YMail-OSG:Received:X-Mailer:References:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=bIQvGlQakAwHXSGxabBqzXgjwxmNQu1v93t7SsXxCZ1mxHkzHWxNbKuuBfPn3Zxc5clfM8GCG4a8mbf66YC9grkpnARM773vRhpfg26iCx0FfOW/BiVEs+eQyd2DVIkMfPrGVDBXo1lHmPuO4xOq/uGolmM+96gTeDsBJ1EL18E=; Message-ID: <149632.77706.qm@web27001.mail.ukl.yahoo.com> X-YMail-OSG: 48c_hEMVM1mngYvqm8f2JjMn4FI_Igeza.SHuIWNxq1P01LYH1GuoDL8je2VQyY9lUveQaRW9zZxQLBeZ7zkt2O0ErDnLNu3MkWnbOr1LL1egFVVS4oaWcmLJhZ4fr3mpKc8c6ZIPr9DIz6ltw2oLC7oIzLhV3PojOZg_LnAPYwlfwsjWv9nz_lsb_aYNg-- Received: from [82.242.132.106] by web27001.mail.ukl.yahoo.com via HTTP; Sun, 08 Mar 2009 15:07:55 GMT X-Mailer: YahooMailRC/1155.45 YahooMailWebService/0.7.289.1 References: <24D11586-4F15-4B6E-8FB7-58651317164D@gmail.com> <46331.52510.qm@web27007.mail.ukl.yahoo.com> <0B508092-FD71-4733-BC95-B6B87A6D3E6B@gmail.com> <154139.25342.qm@web27007.mail.ukl.yahoo.com> <46FCBABD-7E4A-4077-8227-3816FD6D635D@gmail.com> <279881.54090.qm@web27008.mail.ukl.yahoo.com> <58D957FE-F549-4B2F-9794-6A6651A20A29@gmail.com> <843379.3763.qm@web27007.mail.ukl.yahoo.com> <801023.45786.qm@web27008.mail.ukl.yahoo.com> <2368FDC0-FD1F-49B8-BDE0-53C2D641070B@gmail.com> Date: Sun, 8 Mar 2009 15:07:55 +0000 (GMT) From: Matthieu Wipliez Subject: Re : Re : [Caml-list] Re: camlp4 stream parser syntax To: O'Caml Mailing List MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; matthieu:01 camlp:01 parser:01 syntax:01 hash:01 lowercase:01 parser:01 lexer:01 lexer:01 kwd:01 kwd:01 lowercase:01 cheers:01 matthieu:01 ahhh:98 > And this is the part that I object to. I have quite a number of keywords = and I =0A> don't want to have a bunch of if statements or have a hash table= mapping =0A> lowercase to camel case. This would mean having to track the = parser (camel case) =0A> version in two places: the lexer and the parser.= =0A=0AAhhh ok, I (finally) got it!=0AI believe there is a (partially accept= able) solution, if you are willing to accept having all your keywords in lo= wer-case in the grammar (not in the lexer), ie you match against "buyorsell= ", "sellshort" etc.=0A=0AThen you can change the functions match_keyword an= d keyword_conversion as follows:=0A=0Alet keyword_conversion tok is_kwd =3D= =0A match tok with=0A SYMBOL s | IDENT s when is_kwd (String.lowercase = s) -> KEYWORD s=0A | _ -> tok=0A=0AThis will pass lower-cased identifiers = to "is_kwd", so "BuyOrSell" becomes a valid keyword.=0A=0Alet match_keyword= kwd =3D function=0A KEYWORD kwd' when kwd =3D String.lowercase kwd' -> tr= ue=0A| _ -> false=0A=0AHere kwd is the keyword from the grammar ("buyorsell= ") and kwd' is the content of the keyword produced by the lexer ("BuyOrSell= "), and they match.=0A=0ACheers,=0AMatthieu=0A=0A=0A=0A