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 UAA26142; Fri, 13 Aug 2004 20:47:27 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id UAA25479 for ; Fri, 13 Aug 2004 20:47:26 +0200 (MET DST) Received: from herd.plethora.net (herd.plethora.net [205.166.146.1]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i7DIlORM032497; Fri, 13 Aug 2004 20:47:25 +0200 Received: from bhurt.plethora.net (bhurt.plethora.net [205.166.146.49]) by herd.plethora.net (8.11.6/8.10.1) with ESMTP id i7DIlMJ17809; Fri, 13 Aug 2004 13:47:22 -0500 (CDT) Date: Fri, 13 Aug 2004 13:55:13 -0500 (CDT) From: Brian Hurt X-X-Sender: bhurt@localhost.localdomain To: Xavier Leroy cc: David McClain , Ocaml Mailing List Subject: Re: [Caml-list] CFG's and OCaml In-Reply-To: <20040813164234.GA27886@yquem.inria.fr> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 411D0CBC.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 precedences:01 ocaml's:01 precedences:01 ocaml's:01 tweaking:01 parens:01 minix:01 behave:01 strangely:01 compiler:01 compiler:01 compilers:01 ocaml:01 ocaml:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 13 Aug 2004, Xavier Leroy wrote: > From this message and earlier messages of yours, I think you are under > the wrong impression that precedences and associativities can be used > (and would be used in OCaml's grammar) to resolve (or "hide" as you > say) reduce/reduce conflicts. > > This is incorrect: Yacc uses precedences and associativities to > resolve (i.e. choose to shift or choose to reduce) shift/reduce > conflicts only. If there were reduce/reduce conflicts in OCaml's > grammar, Yacc would say so and no among of precedence tweaking would > hide them. OK. I don't generally use explicitly stated precedences anyways. Of course, as a programmer, I work under the rule that multiplication and division happen before addition and subtraction, and that I should put parens around everything else. > > This said, it is true the OCaml grammar uses precedences a lot to deal > with shift/reduce situations. It is equally true that some of these > situations correspond to syntactic corners of the language that can > confuse the user. I see why it's done the way it is. It's an aesthetic decision. > Concerning David McClain's problems, I can only repeat the advice > given at the beginning of the ocamlyacc chapter in the OCaml manual: > > `` Readers unfamiliar with lex and yacc are referred to ``Compilers: > principles, techniques, and tools'' by Aho, Sethi and Ullman > (Addison-Wesley, 1986), or ``Lex & Yacc'', by Levine, Mason and Brown > (O'Reilly, 1992). '' > > (The latter is more practice-oriented.) > Having read all three, and several others as well, the O'Reilly book is a good reference if you already basically know Lex and Yacc. The Dragon Book (Aho et. al.) is a better book for building a compiler. But Holub's "Compiler Design in C" does a Minix, and actually builds a lex/yacc like tool. But it does this at the cost of actually using the tools to make a compiler, including such topics as code generation and optimization. A better title would be "Lex/Yacc Design in C". As such, I've found it a better book for explaining how the tools actually work, including why they occassionally behave strangely. IMHO, read Holub first. Then read Aho. The get the O'Reilly book to leave by your computer. -- "Usenet is like a herd of performing elephants with diarrhea -- massive, difficult to redirect, awe-inspiring, entertaining, and a source of mind-boggling amounts of excrement when you least expect it." - Gene Spafford Brian ------------------- 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