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=0.0 required=5.0 tests=none 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 29F3EBBAF for ; Sun, 8 Mar 2009 11:27:24 +0100 (CET) X-IronPort-AV: E=Sophos;i="4.38,324,1233529200"; d="scan'208";a="22214222" Received: from yquem.inria.fr ([128.93.8.37]) by mail2-relais-roc.national.inria.fr with ESMTP; 08 Mar 2009 11:27:24 +0100 Received: by yquem.inria.fr (Postfix, from userid 25991) id 152B9BBAF; Sun, 8 Mar 2009 11:27:24 +0100 (CET) Date: Sun, 8 Mar 2009 11:27:24 +0100 From: Daniel de Rauglaudre To: caml-list@inria.fr Subject: Re : [Caml-list] Re: camlp4 stream parser syntax Message-ID: <20090308102724.GC5433@yquem.inria.fr> 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> <20090308093756.GB5433@yquem.inria.fr> <046C7516-62FF-4F46-B2D9-CEA1045132CD@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <046C7516-62FF-4F46-B2D9-CEA1045132CD@gmail.com> User-Agent: Mutt/1.5.9i X-Spam: no; 0.00; rauglaudre:01 rauglaudre:01 camlp:01 parser:01 syntax:01 lexer:01 ocamllex:01 lexer:01 camlp:01 grammars:01 lident:01 plexer:01 lident:01 lowercase:01 2009:98 Hi, On Sun, Mar 08, 2009 at 09:51:26AM +0000, Joel Reymont wrote: > I would prefer to use the #2 approach but I'm using a custom lexer > built by ocamllex. Mmm... I am not eventually sure that what I said was correct... I should test it myself, what I generally do before asserting things... :-) But I was not clear: I said that you had to program *both* items. It was not an "or" but an "and"... But... it was false... Bsakjfvouveoussasj.... I said nothing... I restart... A change in the lexer should be sufficient. If you cannot (or if you don't want): Only changing the "tok_match" record field (2nd point) would not work for keywords (defined by "just a string" in Camlp* grammars), because the lexer *must* recognize all combinations of the identifier as keywords, implying a change, anyway, in the lexer. On the other hand, if you can accept that these identifiers are not keywords (i.e. not reserved names), and if there a token for identifiers, like "LIDENT" of "UIDENT" in Camlp* proposed lexer (module Plexer in Camlp5), you can put them in your grammar as (for example): LIDENT "delay" instead of: "delay" In this case, a change of the "tok_match" record field should work. Define the function: let my_tok_match = function (p_con, "") -> begin function (con, prm) -> if con = p_con then prm else raise Stream.Failure end | (p_con, p_prm) -> begin function (con, prm) -> if String.lowercase con = p_con && prm = p_prm then prm else raise Stream.Failure end ;; Then look for an identifier named "tok_match" in your code, which should be a record field, and define that "tok_match" record field as "my_tok_match". If you don't find it, perhaps it is implicitely used by another Camlp* library function. In this case, well, more work may have been done. -- Daniel de Rauglaudre http://pauillac.inria.fr/~ddr/