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=HTML_MESSAGE autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id DD334BC6B for ; Tue, 30 Oct 2007 15:00:21 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAPvVJkeAKs4Fnmdsb2JhbACCcotuAgEBBwQGERg X-IronPort-AV: E=Sophos;i="4.21,347,1188770400"; d="scan'208,217";a="5281814" Received: from netscaler2.rice.edu (HELO mh2.mail.rice.edu) ([128.42.206.5]) by mail3-smtp-sop.national.inria.fr with ESMTP; 30 Oct 2007 15:00:20 +0100 Received: from mh2.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh2.mail.rice.edu (Postfix) with ESMTP id E844136D4C2 for ; Tue, 30 Oct 2007 09:00:18 -0500 (CDT) X-Virus-Scanned: by amavis-2.4.4 at mh2.mail.rice.edu Received: from mh2.mail.rice.edu ([127.0.0.1]) by mh2.mail.rice.edu (mh2.mail.rice.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nORgXfblRZjh for ; Tue, 30 Oct 2007 09:00:18 -0500 (CDT) Received: from [10.194.94.87] (unknown [10.194.94.87]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by mh2.mail.rice.edu (Postfix) with ESMTP id A97CD36D4D0 for ; Tue, 30 Oct 2007 09:00:18 -0500 (CDT) Mime-Version: 1.0 (Apple Message framework v752.3) To: caml-list@yquem.inria.fr Message-Id: <6C4DFFEF-0A5E-496F-9468-56693FFA4DC2@cs.rice.edu> Content-Type: multipart/alternative; boundary=Apple-Mail-41-697251759 From: Angela Zhu Subject: Problem with precedence declaration in .mly file Date: Tue, 30 Oct 2007 09:00:16 -0500 X-Mailer: Apple Mail (2.752.3) X-Spam: no; 0.00; ocaml:01 parser:01 parser:01 interprets:01 ocaml:01 interprets:01 angela:98 angela:98 monaco:98 monaco:98 wrote:01 wrote:01 helvetica:98 precedence:01 precedence:01 --Apple-Mail-41-697251759 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Hi all, I have some problem with precedence declaration in OCaml parser. If I what to say exponential(ATOB) is prior to *(STAR) and / (DIVIDE), * and / are prior to +(PLUS) and -(MINUS), I wrote the following in the parser: /***** Precedence Rules *****/ ... %left PLUS MINUS %left STAR DIVIDE %left ATOB ... But I still have the following problems: (1) It appears that the parser reads "test = 2^2 + 7;" as "test = 2^9" instead of "test = 4+7", which would follow the conventional order of operations. (2)It also interprets "test = (1^2)/3 + 1;" as "test = (1 ^ 2 / (3 + 1));" Can any one help me to see why it happens? Why the precedence rules doesn't work? Thanks, Angela ------------------------------------------ Dept. of CS, Rice U. http://www.cs.rice.edu/~yz2/ ------------------------------------------ --Apple-Mail-41-697251759 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=ISO-8859-1
Hi = all,=A0

I have some problem with precedence declaration in = OCaml parser.
If I what to say = exponential(ATOB) is prior to *(STAR) and / (DIVIDE),
=A0* and / are prior to +(PLUS)=A0 and = -(MINUS),
I wrote the following in the = parser:


/***** Precedence = Rules=A0 *****/
...
%left PLUS MINUS =A0
%left STAR DIVIDE = =A0
%left ATOB
...

But I still have the following problems:
(1) It appears that the parser
reads "test =3D 2^2 + 7;" as "test =3D 2^9" instead = of "test =3D 4+7", which
would follow = the conventional order of operations.
(2)It also interprets "test = =3D (1^2)/3 + 1;" as "test =3D (1 ^ 2
/ (3 + = 1));"

Can any one help me to see why it happens? Why the = precedence rules doesn't work?

Thanks,
Dept. of CS, Rice U.