From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: weis Received: (from weis@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id QAA02825 for caml-redistribution; Wed, 18 Sep 1996 16:45:33 +0200 Received: (from xleroy@localhost) by pauillac.inria.fr (8.6.10/8.6.6) id QAA02733; Wed, 18 Sep 1996 16:42:12 +0200 From: Xavier Leroy Message-Id: <199609181442.QAA02733@pauillac.inria.fr> Subject: Re: Caml Parsing To: zdance@cs.cornell.edu (Stephan Zdancewic) Date: Wed, 18 Sep 1996 16:42:11 +0200 (MET DST) Cc: caml-list@pauillac.inria.fr In-Reply-To: <199609171857.OAA04386@earth.cs.cornell.edu> from "Stephan Zdancewic" at Sep 17, 96 02:57:12 pm MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: weis > I'm trying to use the SML version of yacc to write a parser > for Objective Caml, but I've run into problems because of some > differences in SML-yacc and Caml-yacc. More precisely, Caml-yacc > allows you to specify precedence and associativity for non-terminals > in the grammar, while SML-yacc will let you do this only for > terminals. If you're talking about the "%prec" directive, I'm very, very surprised that SML-yacc does not have an equivalent feature (to override the default precedence and associativities assigned to a production). It's the standard trick for handling e.g. unary minus, and also very useful to resolve reduce/reduce conflicts. You may want to check with the author of SML-yacc (David Tarditi, I think). > Alternatively, does there exist a specification > of the OCaml grammar that doesn't rely on these precedence > levels/associativities? There have been several attempts at writing recursive-descent parsers for Caml, but none that will handle the whole O'Caml syntax. More generally, it can be very hard to disambiguate a grammar by rewriting the rules (as opposed to playing with precedences). Regards, - Xavier Leroy