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.0 required=5.0 tests=AWL,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 F1A44BC6B for ; Wed, 31 Oct 2007 12:52:12 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAALYJKEeCpA7unmdsb2JhbACOZAIBAQcEBhEY X-IronPort-AV: E=Sophos;i="4.21,351,1188770400"; d="scan'208";a="3874811" Received: from mailserv97-us.natinst.com ([130.164.14.238]) by mail1-smtp-roc.national.inria.fr with SMTP; 31 Oct 2007 12:52:12 +0100 Received: from mailserv97-us (mailserv97-usa [130.164.14.238]) by mailserv97-us.natinst.com (Postfix) with ESMTP id 948D26740E3; Wed, 31 Oct 2007 06:52:10 -0500 (CDT) Received: from dalek.amer.corp.natinst.com (10.0.44.32) by mailserv97-us (F-Secure/fsigk_smtp/488/mailserv97-us); Wed, 31 Oct 2007 06:52:10 -0600 (CST) X-Virus-Status: clean(F-Secure/fsigk_smtp/488/mailserv97-us) Received: from dalek.dy.natinst.com (peter@localhost.dy.natinst.com [127.0.0.1]) by dalek.dy.natinst.com (8.14.0/8.14.0) with ESMTP id l9VBqAsI015667; Wed, 31 Oct 2007 06:52:10 -0500 (CDT) Received: from localhost (peter@localhost) by dalek.dy.natinst.com (8.14.0/8.14.0/Submit) with ESMTP id l9VBq9p8026606; Wed, 31 Oct 2007 06:52:10 -0500 (CDT) X-Authentication-Warning: dalek.dy.natinst.com: peter owned process doing -bs Date: Wed, 31 Oct 2007 06:52:09 -0500 (CDT) From: Peter Ilberg X-X-Sender: peter@dalek.dy.natinst.com To: Angela Zhu Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Problem with precedence declaration in .mly file In-Reply-To: <23EC0ABA-12EE-49DE-B76A-1D91BCCAE1BA@cs.rice.edu> Message-ID: References: <6C4DFFEF-0A5E-496F-9468-56693FFA4DC2@cs.rice.edu> <1193753915.47273d3bb15f2@webmail.in-berlin.de> <23EC0ABA-12EE-49DE-B76A-1D91BCCAE1BA@cs.rice.edu> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam: no; 0.00; ocamlyacc:01 ocamlyacc:01 mult:01 mult:01 2007,:98 angela:98 $1,:98 $1,:98 wrote:01 precedence:01 precedence:01 caml-list:01 ident:01 mly:01 grammar:02 I have no experience with ocamlyacc, but looking at your grammar below, it seems that you don't need the 'value PLUS exp' etc rules. All these cases should be covered already by the 'exp PLUS exp' rules at the beginning and the 'value' rule at the end. Try removing the 'value PLUS exp' rules. Maybe ocamlyacc gets confused if it has two sets of productions that it has to disambiguate with precedence rules. --- Peter On Tue, 30 Oct 2007, Angela Zhu wrote: > exp: > ... > | exp PLUS exp { Add($1, $3) } > | MINUS exp { Sub(Value(VFloat(0.0)), $2) > } > | exp MINUS exp { Sub($1, $3) } > | exp DIVIDE exp { Divide($1, $3) } > | exp STAR exp { Mult($1, $3) } > | exp ATOB exp { Atob($1, $3) } *** do you really need these productions? > | value PLUS exp { Add(Value($1), $3) } > | value MINUS exp { Sub(Value($1), $3) } > | value DIVIDE exp { Divide(Value($1), $3) } > | value STAR exp { Mult(Value($1), $3) } > | value ATOB exp { Atob(Value($1), $3) } *** > ... > > | IDENT { Id($1) } > | value { Value($1) } > > > ;