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.1 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id 0AEB9BC69 for ; Thu, 29 Mar 2007 17:29:17 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.239]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2TFTFVa013991 for ; Thu, 29 Mar 2007 17:29:16 +0200 Received: by nz-out-0506.google.com with SMTP id l8so184217nzf for ; Thu, 29 Mar 2007 08:29:15 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=upWBgNcxPnBpRlUauMqPaJ27tH6vQho5GEtFM7bFB2ZpQaQnvRBttu27dZD6QdUsnM3BcWmYSl4TSN+6H+pmYi8Al8YXv/L6rqhUytmZHqqr+4H8CIgFPfAesfUmoIUe6E889rQ1mCZ+BZwUYzuFuTdY1r1TH3x0n5z/kz0DOLk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=SnbWVuEkjg3jI7NFBFvPihHkhIuu95y5pAv4DzQE61sDPuor9lrCOu/PzBSHGl6OsRR4EWJuJakK25QSrP3h+uvoW/FxkupwV1tecbB2+tT0W72YC0BMUAGdxa1nM+mj8JRXR48/2jixudEQ6WU5g4e7BwYG0yeMmgtBMqiZWxI= Received: by 10.115.89.1 with SMTP id r1mr301498wal.1175182154640; Thu, 29 Mar 2007 08:29:14 -0700 (PDT) Received: by 10.114.183.4 with HTTP; Thu, 29 Mar 2007 08:29:14 -0700 (PDT) Message-ID: Date: Thu, 29 Mar 2007 17:29:14 +0200 From: "Nicolas Pouillard" To: "Harrison, John R" Subject: Re: [Caml-list] Hacking the lexer in the new camlp4 Cc: caml-list@inria.fr In-Reply-To: <509223F0BF55E74FA1247D17207E7A0C01433DE5@orsmsx419.amr.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <509223F0BF55E74FA1247D17207E7A0C01433DE5@orsmsx419.amr.corp.intel.com> X-j-chkmail-Score: MSGID : 460BDB4B.000 on discorde : j-chkmail score : X : 0/20 1 0.000 -> 1 X-Miltered: at discorde with ID 460BDB4B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lexer:01 camlp:01 camlp:01 lexer:01 modular:01 ocamllex:01 patching:01 sig:01 wrote:01 token:01 token:01 extensible:01 caml-list:01 ugly:03 stream:04 On 3/29/07, Harrison, John R wrote: > | > In the current camlp4, the only way I found to do this was basically > | > to copy the existing lexer and edit it. Although it works, it's ugly > | > and invariably means that I've had to change something with almost > | > every new version of camlp4. Does the new camlp4 offer a nicer way > of > | > changing the lexer? > | > | How did you that in the previous one without copy/paste the old lexer? > > Indeed, that's exactly what I did in the old camlp4. But I am curious if > the new camlp4 offers, or could offer, a more modular solution. Ok, so the new one is build with ocamllex, so it's not really extensible. If you want to accept something that is currently rejected by the lexer you need to change it. However if it's just a matter of patching the token stream you can do it more easily by adding a token filter (Camlp4.Sig.Token.Filter). -- Nicolas Pouillard