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 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 78DF2BBC4 for ; Thu, 2 Apr 2009 14:39:33 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgQDAMhO1EnCpx6vi2dsb2JhbACNG4h+AQEBCgsKGLlGg3wG X-IronPort-AV: E=Sophos;i="4.39,314,1235948400"; d="scan'208";a="23806356" Received: from smtpka.univ-orleans.fr (HELO ka.univ-orleans.fr) ([194.167.30.175]) by mail2-smtp-roc.national.inria.fr with ESMTP; 02 Apr 2009 14:39:33 +0200 Received: from smtps.univ-orleans.fr (localhost [127.0.0.1]) by ka.univ-orleans.fr (Postfix) with ESMTP id 9F9A012AD68; Thu, 2 Apr 2009 14:39:32 +0200 (CEST) Received: from [147.210.129.240] (laptop-147-210-129-240.labri.fr [147.210.129.240]) by smtps.univ-orleans.fr (Postfix) with ESMTP id 54F9B36E60; Thu, 2 Apr 2009 14:39:34 +0200 (CEST) Subject: Re: [Caml-list] How to achieve this camlp4 syntax extension From: David Teller To: Conglun Yao Cc: caml-list@yquem.inria.fr In-Reply-To: References: Content-Type: text/plain Date: Thu, 02 Apr 2009 14:40:07 +0200 Message-Id: <1238676007.6207.1.camel@Blefuscu> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; camlp:01 syntax: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 ocaml:01 Hi, I'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 _ = open M1.M2 in e will execute [e] using module [M1.M2]. Cheers, David 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 _ = M1.M2.[ here is my syntax, using M1.M2 module ] > > Here is my attempt (failed) > > EXTEND Gram > > GLOBAL: expr; > > expr: LEVEL "top"[ > [ e1 = module_longident; "."; "["; (*t = test_syntax;*) "]" -> > <:expr< $id:e1$ test >> > ]]; > > END > > Different kinds of error happened, when trying to use it. > > Even the ordinary expression: List.length [1; 2;3 ], failed. 'List' > 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 >