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 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 AF9C5BBC4 for ; Sat, 21 Mar 2009 17:10:30 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApoEAK+uxEnIuX5EgWdsb2JhbACNCYhnFiK+EIN+BmI X-IronPort-AV: E=Sophos;i="4.38,400,1233529200"; d="scan'208";a="22987101" Received: from mta21.f3.k8.com.br ([200.185.126.68]) by mail2-smtp-roc.national.inria.fr with ESMTP; 21 Mar 2009 17:10:29 +0100 Received: from localhost (localhost [127.0.0.1]) by smtpa.f3.k8.com.br (Postfix) with ESMTP id 6D8EA28000A4; Sat, 21 Mar 2009 16:10:26 +0000 (GMT) X-Virus-Scanned: amavisd-new at k8.com.br Received: from smtpa.f3.k8.com.br ([127.0.0.1]) by localhost (mta21.f3.k8.com.br [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 9RlHkMnJTgXJ; Sat, 21 Mar 2009 16:10:26 +0000 (GMT) Received: from [189.106.100.42] (unknown [189.106.100.42]) by smtpa.f3.k8.com.br (Postfix) with ESMTP id B552628000A3; Sat, 21 Mar 2009 16:10:23 +0000 (GMT) Subject: Re: [Caml-list] Camlp4 help From: Andre Nathan To: blue storm Cc: caml-list@inria.fr In-Reply-To: <527cf6bc0903210826r5a0c079bm71068f5b1d89ebe1@mail.gmail.com> References: <1237606863.5943.0.camel@homesick> <527cf6bc0903210826r5a0c079bm71068f5b1d89ebe1@mail.gmail.com> Content-Type: text/plain Date: Sat, 21 Mar 2009 13:14:36 -0300 Message-Id: <1237652076.6137.15.camel@homesick> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 Content-Transfer-Encoding: 7bit X-Spam: no; 0.00; camlp:01 0100,:01 camlp:01 expr:01 expr:01 syntax:01 syntax:01 seq:01 seq:01 beginner's:01 ocaml:01 bug:01 beginner's:01 ocaml:01 bug:01 Hi On Sat, 2009-03-21 at 16:26 +0100, blue storm wrote: > This is not a camlp4-specific problem : the grammar you described > apparently do not conform to what you have in mind. I think I understand, although I thought the "x = expr" rule in the sum form definition meant that before "plus" any expression would be allowed. I want to allow any expression inside a "sum" block, which I think I could do by defining it as a new rule in "expr", but I'd like "plus" expressions to only be allowed inside a "sum" block, which I'm not sure how to do. Thanks, Andre > > 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 > > > > _______________________________________________ > 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