From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id KAA14949; Fri, 12 Sep 2003 10:42:31 +0200 (MET DST) Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id KAA19016 for ; Fri, 12 Sep 2003 10:42:30 +0200 (MET DST) Received: from indyio.rz.uni-saarland.de (indyio.rz.uni-saarland.de [134.96.7.3]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id h8C8gTT29343 for ; Fri, 12 Sep 2003 10:42:29 +0200 (MET DST) Received: from uni-sb.de (uni-sb.de [134.96.7.230]) by indyio.rz.uni-saarland.de (8.12.9/8.12.9) with ESMTP id h8C8gTnS18836809 for ; Fri, 12 Sep 2003 10:42:29 +0200 (CST) Received: from cs.uni-sb.de (cs.uni-sb.de [134.96.252.31]) by uni-sb.de (8.12.9/2003073000) with ESMTP id h8C8gS1K024874; Fri, 12 Sep 2003 10:42:28 +0200 (CEST) Received: from mail.cs.uni-sb.de (mail.cs.uni-sb.de [134.96.254.200]) by cs.uni-sb.de (8.12.9/2003091100) with ESMTP id h8C8gCk5007229; Fri, 12 Sep 2003 10:42:27 +0200 (CEST) Received: from mail.st.cs.uni-sb.de (goscinny.cs.uni-sb.de [134.96.235.32]) by mail.cs.uni-sb.de (8.12.9/2003073000) with ESMTP id h8C8elPi005598; Fri, 12 Sep 2003 10:40:48 +0200 (CEST) X-Authentication-Warning: email: Host goscinny.cs.uni-sb.de [134.96.235.32] claimed to be mail.st.cs.uni-sb.de Received: from jacobs.cs.uni-sb.de (jacobs.cs.uni-sb.de [134.96.235.135]) by mail.st.cs.uni-sb.de (Postfix) with ESMTP id B708834B5C9; Fri, 12 Sep 2003 10:40:47 +0200 (CEST) Received: by jacobs.cs.uni-sb.de (Postfix, from userid 7528) id 7900697BA2; Fri, 12 Sep 2003 10:40:47 +0200 (CEST) Date: Fri, 12 Sep 2003 10:40:47 +0200 From: Christian Lindig To: "Rafael 'Dido' Sevilla" Cc: Caml Mailing List Subject: Re: [Caml-list] eliminating shift/reduce conflicts Message-ID: <20030912084047.GB31078@st> Mail-Followup-To: Christian Lindig , Rafael 'Dido' Sevilla , Caml Mailing List References: <20030912082632.GA9048@imperium.ph> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030912082632.GA9048@imperium.ph> X-No-Archive: yes X-URL: http://www.st.cs.uni-sb.de/~lindig/ User-Agent: Mutt/1.5.4i X-Loop: caml-list@inria.fr X-Spam: no; 0.00; lindig:01 lindig:01 uni-sb:01 caml-list:01 rafael:01 'dido':01 foo:01 foo:01 baz:01 baz:01 uni-sb:01 tokens:01 token:01 sep:01 unit:03 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, Sep 12, 2003 at 04:26:32PM +0800, Rafael 'Dido' Sevilla wrote: > I have an ocamlyacc grammar that contains productions that look like: > > foo_list: FOO { [$1] } > | foo_list COMMA FOO { $3 :: $1 } > ; > > bar: foo_list COLON xyzzy { ... } > baz: FOO COLON yzzyx { ... } > > This of course produces a shift/reduce conflict, and shifting fails to > parse the 'bar' correctly. I have tried to build a little grammar to reproduce your problem but failed. If you could post a small stand-alone grammar for OCamlyacc somebody might be able to help you. The easiest way to remove conflicts in Yacc is to alter the precedence of individual tokens using %left or %right. Read the section about 'Declarations' in the OCamlYacc manual. My toy grammar is below. %token COLON COMMA FOO ETC %start start %typestart %% start : foo_list ETC bar ETC baz {} ; foo_list : FOO {} | foo_list COMMA FOO {} ; bar : foo_list COLON ETC {} ; baz : FOO COLON ETC {} %% -- Christian -- Christian Lindig http://www.st.cs.uni-sb.de/~lindig/ ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners