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.8 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 mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 5FA46BBC4 for ; Sat, 21 Mar 2009 16:26:46 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnADACKkxEnRVdmdkGdsb2JhbACNCYgmQQEBCQkTEQOuEIEHjwEBAwEDg3sG X-IronPort-AV: E=Sophos;i="4.38,399,1233529200"; d="scan'208";a="22985604" Received: from mail-gx0-f157.google.com ([209.85.217.157]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Mar 2009 16:26:45 +0100 Received: by gxk1 with SMTP id 1so6154170gxk.9 for ; Sat, 21 Mar 2009 08:26:44 -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=Nyfbb49EreasX1RlKXMXmYuL9B/gDMeQOvVpk0YTeY0=; b=oF+vu7INzOSWCHJjfCEJ5oA3Nuc6BzDQ6tXr5qxWZXzFT93aEly2RnXiq3nx3sPpYB 5+eDytyW/9LzXvECg3koYiEdnaKYriPVV+OXcExnoHh+W2T1wPYlv8e0fqKa/NpjTdEq O5re/MYnjubzJN38xB9t9k3u6FOeu/u4/kKoY= 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=pK7GCQ568xKuKneEgz9PZ1C5hGMtkRB29W5Q4hQYNP/gOQfScfHiTDgsRrdsT7BfKX WFeOZCrmo8EtYmA8LtsiwCVti1iIHfY7OwN8a9+8HFdEBM/1p3MDzW9Qsphejy5TZ/g5 8hXnOuaNNHNec6sOUfZBR77NOVrOmcllWyQzw= MIME-Version: 1.0 Received: by 10.151.110.9 with SMTP id n9mr8831277ybm.9.1237649204612; Sat, 21 Mar 2009 08:26:44 -0700 (PDT) In-Reply-To: <1237606863.5943.0.camel@homesick> References: <1237606863.5943.0.camel@homesick> Date: Sat, 21 Mar 2009 16:26:44 +0100 Message-ID: <527cf6bc0903210826r5a0c079bm71068f5b1d89ebe1@mail.gmail.com> Subject: Re: [Caml-list] Camlp4 help From: blue storm To: Andre Nathan Cc: caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; camlp:01 camlp:01 expr:01 syntax:01 syntax:01 expr:01 seq:01 seq:01 beginner's:01 ocaml:01 bug:01 storm:98 nathan:98 beginners:01 parsed:01 This is not a camlp4-specific problem : the grammar you described apparently do not conform to what you have in mind. According to your definition, the "sum do ... done" can only contain "sum" forms, not an arbitrary expression. The only valid way to parse "sum do let a = b in a plus c done" is thus "sum do (let a = b in a) plus b done", as "sum do let a = b in (a plus b) done" has an expression (instead of a sum) between do ... done (and a sum in expr position, wich is also incorrect, but it can also be parsed as a correct expression). What is the syntax you want to be supported ? On 3/21/09, Andre Nathan wrote: > 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 > > _______________________________________________ > 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 >