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.8 required=5.0 tests=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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id E5B1FBBAF for ; Tue, 10 Mar 2009 23:07:50 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ai4CABeCtklKfU4bk2dsb2JhbACUbz8BAQEBCQkKCREDq2uBB49RAQMBA4QJBoMX X-IronPort-AV: E=Sophos;i="4.38,337,1233529200"; d="scan'208";a="25378230" Received: from ey-out-2122.google.com ([74.125.78.27]) by mail1-smtp-roc.national.inria.fr with ESMTP; 10 Mar 2009 23:07:50 +0100 Received: by ey-out-2122.google.com with SMTP id 9so270792eyd.15 for ; Tue, 10 Mar 2009 15:07:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:mime-version :content-transfer-encoding:from:message-id:in-reply-to:cc:date :references:content-type:to:x-mailer; bh=L9cuXBBaIX+DTb19YoB7M89GGi2Jyhlo+Dfc2zyjuQU=; b=s3u+RfJsuuqPcKaZXzUBnZF1EqscuDrQs+FPkPfWWQf5ZnQwoup5xztMg6BH2Z739V mcJAIOLC6GD3F/1fON2N6v9JFrxJ0SsAhjX9SqOqwbQ7xF0GFAN9L7FP4rdsI3tDEpO8 yY6vO3dhnpx6zKjJCAZNNoKISkEv5wFuApdZc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-transfer-encoding:from:message-id :in-reply-to:cc:date:references:content-type:to:x-mailer; b=FzUKee9FmaqGJX7bQCPaJnpM15cDf8FUi18eOi9/D/TBf3YrgZ31ybJQjwqQUrnXFC ba1IBYBqmrmkh+LUBL/48aXMzpSlWyxv4Js/HuudfaP+h27NfIKIgpjHjo0SEiE8Gdcv bTr3y80rlCTOhwvMd3T+V4aravfDiNOxHqlxw= Received: by 10.216.45.73 with SMTP id o51mr3064138web.10.1236722870088; Tue, 10 Mar 2009 15:07:50 -0700 (PDT) Received: from ?10.10.30.6? (8.Red-88-3-5.dynamicIP.rima-tde.net [88.3.5.8]) by mx.google.com with ESMTPS id 10sm1292871eyz.0.2009.03.10.15.07.48 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 10 Mar 2009 15:07:49 -0700 (PDT) Subject: Re: [Caml-list] camlp4 grammar and LIST1 Mime-Version: 1.0 (Apple Message framework v1043) Content-Transfer-Encoding: 7bit From: Joel Reymont Message-Id: In-Reply-To: Cc: "O'Caml Mailing List" Date: Tue, 10 Mar 2009 22:07:45 +0000 References: <6485A041-8698-471F-9D9C-BF3DFF0D3018@gmail.com> Content-Type: text/plain; delsp=yes; charset=us-ascii; format=flowed To: Jake Donham X-Mailer: Apple Mail (2.1043) X-Spam: no; 0.00; camlp:01 camlp:01 parsers:01 backtracking:01 expr:01 expr:01 10,:98 token:01 token:01 wrote:01 parsing:01 caml-list:01 grammar:02 parse:02 distinguish:05 On Mar 10, 2009, at 9:48 PM, Jake Donham wrote: >> statement: [ [ s = openStatement -> s | s = closedStatement -> s ] ]; > > Syntactically it is fine but I don't think this is going to do what > you want. Camlp4 parsers aren't backtracking; you have to distinguish > openStatement from closedStatement by parsing a token. I have it like this at the moment. Are you saying it won't work? What does it mean to parse a token then? Does that token have to be in the same rule? Thanks, Joel --- statement: [ [ openStatement | closedStatement ] ]; openStatement: [ [ openIfStatement ] ]; openIfStatement: [ [ "If"; e = expr; "Then"; s1 = closedStatement; "Else"; s2 = openStatement -> If (e, s1, s2) | "If"; e = expr; "Then"; s = statement -> If (e, s, Skip) ] ]; closedIfStatement: [ [ "If"; e = expr; "Then"; s1 = closedStatement; "Else"; s2 = closedStatement -> If (e, s1, s2) ] ]; closedStatement: [ [ inputDeclarations | varDeclarations | arrayDeclarations | compoundStatement | assignment | closedIfStatement | whileStatement | forStatement | tradeStatement | preprocessorStatement | procCall ] ]; inputDeclarations: [ [ "Input"; ":"; l = LIST1 [ x = inputDeclaration -> x ] SEP "," -> InputDecls l ] ]; ... --- http://tinyco.de --- Mac & iPhone