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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 5181DBBC4 for ; Sat, 21 Mar 2009 04:36:55 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsDALz9w0nIuX5CgWdsb2JhbACVbgEBFiK+RoN+Bg X-IronPort-AV: E=Sophos;i="4.38,398,1233529200"; d="scan'208";a="36917126" Received: from mta19.f3.k8.com.br ([200.185.126.66]) by mail4-smtp-sop.national.inria.fr with ESMTP; 21 Mar 2009 04:36:54 +0100 Received: from localhost (localhost [127.0.0.1]) by smtpa.f3.k8.com.br (Postfix) with ESMTP id 6CDED2800091 for ; Sat, 21 Mar 2009 03:36:51 +0000 (GMT) X-Virus-Scanned: amavisd-new at k8.com.br Received: from smtpa.f3.k8.com.br ([127.0.0.1]) by localhost (mta19.f3.k8.com.br [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Ma7ZN9BBttqs for ; Sat, 21 Mar 2009 03:36:51 +0000 (GMT) Received: from [189.106.5.217] (unknown [189.106.5.217]) by smtpa.f3.k8.com.br (Postfix) with ESMTP id 1F333280008C for ; Sat, 21 Mar 2009 03:36:50 +0000 (GMT) Subject: Camlp4 help From: Andre Nathan To: caml-list@inria.fr Content-Type: text/plain Date: Sat, 21 Mar 2009 00:41:03 -0300 Message-Id: <1237606863.5943.0.camel@homesick> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; camlp:01 camlp:01 syntax:01 syntax:01 expr:01 seq:01 expr:01 seq:01 nathan:98 precedence:01 argument:02 breaks:02 parse:02 parse:02 let:03 Hello I'm just beginning with camlp4 here, and I'm stuck with what I think is a precedence issue. I have the following syntax extension: open Camlp4.PreCast open Syntax let sum = Gram.Entry.mk "sum" EXTEND Gram expr: LEVEL "top" [ [ "sum"; "do"; seq = LIST1 sum; "done" -> <:expr< do { $list:seq$ } >> ] ] ; sum: [ [ x = expr; "plus"; y = expr -> <:expr< $x$ + $y$ >> ] ] ; END This works fine for something like this: sum do 1 plus 2 done which becomes (1 + 2). However, it breaks on sum do let a = 1 in let b = 2 in a plus b done because it becomes ((let a = 1 in let b = 2 in a) + b). How can fix that (allowing "b" to be in scope for the second argument of "plus")? Also, sequences of operations don't parse: sum do 1 + 2; 3 + 4 done gives "Parse error: [sum] or "done" expected (in [expr])" What am I missing here? Thanks in advance, Andre