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.0 required=5.0 tests=AWL,DNS_FROM_SECURITYSAGE, SPF_FAIL 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 69042BB84 for ; Wed, 12 Nov 2008 14:13:02 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjIDAL1kGknAXQImgWdsb2JhbACBdpI5AQEWIroignZh X-IronPort-AV: E=Sophos;i="4.33,590,1220220000"; d="scan'208";a="19111939" Received: from discorde.inria.fr ([192.93.2.38]) by mail3-smtp-sop.national.inria.fr with ESMTP; 12 Nov 2008 14:13:01 +0100 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id mACDCwbk012417 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Wed, 12 Nov 2008 14:13:01 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhAFAL1kGknZCiKb/2dsb2JhbACBds0VgnZh X-IronPort-AV: E=Sophos;i="4.33,590,1220220000"; d="scan'208";a="19873191" Received: from av6800.comex.ru (HELO home.mk.pp.ru) ([217.10.34.155]) by mail1-smtp-roc.national.inria.fr with ESMTP; 12 Nov 2008 14:13:00 +0100 Received: from ermine.home (ermine.home [192.168.2.2]) by home.mk.pp.ru (Postfix) with ESMTP id 0BAE120A2B for ; Wed, 12 Nov 2008 16:13:00 +0300 (MSK) Received: by ermine.home (Postfix, from userid 1000) id 3C6101B58E3; Wed, 12 Nov 2008 16:13:00 +0300 (MSK) Date: Wed, 12 Nov 2008 16:13:00 +0300 From: Anastasia Gornostaeva To: caml-list@inria.fr Subject: stupid q(2): camlp4 Message-ID: <20081112131300.GA67784@ermine.home> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Miltered: at discorde with ID 491AD65B.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 syntax:01 camlp:01 expr:01 expr:01 associative:01 wrote:01 jambon:01 construct:02 construct:02 binding:02 external:03 suggestion:03 let:03 let:03 Hello. Readihg http://martin.jambon.free.fr/extend-ocaml-syntax.html, I attempt to solve the exercise from chapter 13: "Suggested exercise: implement and test a syntax extension which supports a where construct. For instance, a + b where a = 1 and b = 2 means let a = 1 and b = 2 in a + b We decide that let a = 1 in a where a = 2 should be read as let a = 1 in (a where a = 2) (* returns 2 *) and not (let a = 1 in a) where a = 2 (* returns 1 *) Also, the where construct is right-associative: x + y where x = y where y = 1 means x + y where x = (y where y = 1) (* depends on an external y *) and not (x + y where x = y) where y = 1 (* returns 2 *)" I wrote (for old camlp4/camlp5): EXTEND expr: LEVEL "expr1" [ RIGHTA [ x = SELF; "where"; lb = V (LIST1 let_binding SEP "and") -> <:expr< let $_list:lb$ in $x$ >> ] ]; END but it does not satisfy the second suggestion. How can I have true RIGHTA associative? Thanks! ermine