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=2.1 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 1F938BBC4 for ; Thu, 2 Apr 2009 14:48:13 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmkCAGdQ1EnRVdykkGdsb2JhbACNG4g/PwEBAQEJCQwHEQOoBoEIkB8BAwEDg3kG X-IronPort-AV: E=Sophos;i="4.39,314,1235948400"; d="scan'208";a="25499853" Received: from mail-fx0-f164.google.com ([209.85.220.164]) by mail3-smtp-sop.national.inria.fr with ESMTP; 02 Apr 2009 14:48:12 +0200 Received: by fxm8 with SMTP id 8so570282fxm.27 for ; Thu, 02 Apr 2009 05:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ISj6OLjm4UrSuE6n54hXsXH31Wx9LY/WbTf5qv5oa2s=; b=F9/bzxGptOrO949EU7aWgyMeXhJFmi1qHXqQoGkFvqWzLu1OwCmmEYz0gskj7GFxkF OVf/heYYOAXB/gtOlrQCYVbhluS64tA8W5ZqdcVuiKH2W0+umMu4TtT3PwuS4ZGDb7y0 PP/H75DrpXpJpAStKjh2f+nx0Z7kvGI+fOoSI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=ow96ctehNi7URQe8YcJhCxVF6+5YrB7BBV1G2s2dNqTHHLvPhBcpUz55L9aGyquewq 7gp7TftUrzLAGCYp3DyBweKTSAK25WfNJQDoZclUsBr3Etviyfw2pv70mne/FPIMf7Cb fcpItO1t4a/OKx1CQAj2dTFDBLfgiT4thMWlc= MIME-Version: 1.0 Received: by 10.103.228.19 with SMTP id f19mr697mur.18.1238676491662; Thu, 02 Apr 2009 05:48:11 -0700 (PDT) In-Reply-To: <1238676007.6207.1.camel@Blefuscu> References: <1238676007.6207.1.camel@Blefuscu> Date: Thu, 2 Apr 2009 13:48:11 +0100 Message-ID: Subject: Re: [Caml-list] How to achieve this camlp4 syntax extension From: Conglun Yao To: David Teller Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; camlp:01 syntax:01 infix:01 univ-orleans:01 camlp:01 frisch:01 cheers:01 0100,:01 syntax:01 expr:01 expr:01 longident:01 'list':01 longident:01 beginner's:01 David and J=E9r=E9mie, Thanks for your guys quick response. It seems I get idea how to achieve it. pa_do and pa_open are useful! It's a pity I viewed the code of pa_infix before, but never noticed it was part of a project. Conglun On Thu, Apr 2, 2009 at 1:40 PM, David Teller wrote: > =A0 Hi, > =A0I'm not going to quite answer your question yet -- I'd need to check > the source of Camlp4 for this. However, I can point out that what you're > trying to do looks very much like pa_open, by Alain Frisch. > > let _ =3D open M1.M2 in e > > will execute [e] using module [M1.M2]. > > Cheers, > =A0David > > On Thu, 2009-04-02 at 12:42 +0100, Conglun Yao wrote: >> Dear all, >> >> I tried to achieve the following syntax extension, but failed. >> >> Add expression .[ ] after a module name, inside .[ ] I want to refer >> to the specified module, like >> >> let _ =3D M1.M2.[ here is my syntax, =A0using M1.M2 module ] >> >> Here is my attempt (failed) >> >> EXTEND Gram >> >> GLOBAL: expr; >> >> expr: LEVEL "top"[ >> [ e1 =3D module_longident; "."; =A0"["; =A0(*t =3D test_syntax;*) =A0"]"= -> >> =A0 <:expr< $id:e1$ test >> >> ]]; >> >> END >> >> Different kinds of error happened, when trying to use it. >> >> Even the ordinary expression: =A0List.length [1; 2;3 ], =A0failed. =A0'L= ist' >> is parsed as module_longident, try to match the rule I defined. >> >> Thanks for any help. >> >> Conglun >> >> _______________________________________________ >> 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 >> > >