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 HAA28647; Fri, 13 Aug 2004 07:22:39 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f 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 HAA19597 for ; Fri, 13 Aug 2004 07:22:38 +0200 (MET DST) Received: from smtp3.adl2.internode.on.net (smtp3.adl2.internode.on.net [203.16.214.203]) by nez-perce.inria.fr (8.12.10/8.12.10) with ESMTP id i7D5MYmL032381 for ; Fri, 13 Aug 2004 07:22:36 +0200 Received: from [192.168.1.200] (ppp197-3.lns1.syd2.internode.on.net [203.122.197.3]) by smtp3.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id i7D5MTHY024575; Fri, 13 Aug 2004 14:52:29 +0930 (CST) Subject: Re: [Caml-list] Context Free Grammars? From: skaller Reply-To: skaller@users.sourceforge.net To: Paul Snively Cc: David McClain , Joshua Smith , caml-list In-Reply-To: <55D5BF02-EC95-11D8-915C-000A27DEEC20@mac.com> References: <93BB4D7C-EC83-11D8-9939-000A95C19BAA@Avisere.com> <411BB09A.7010307@trdlnk.com> <7D827B04-EC8B-11D8-9939-000A95C19BAA@Avisere.com> <55D5BF02-EC95-11D8-915C-000A27DEEC20@mac.com> Content-Type: text/plain Message-Id: <1092374548.29139.86.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 13 Aug 2004 15:22:28 +1000 Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 411C501A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 sourceforge:01 2004:99 reductions:01 recursion:01 recursion:01 $1,:01 typecode:01 expr:01 $1,:01 9660:01 glebe:01 token:01 handles:01 nsw:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 2004-08-13 at 05:25, Paul Snively wrote: > 1) Only one token at a time is taken into account in reductions. > 2) Right-recursion will screw you over. Actually Ocamlyacc handles right recursion just fine. I have no idea why .. but it does, in fact its the prefered form in many cases: here's an example of BOTH left and right recursion being used: tlelement: | lelement COLON factor { $1,Some (typecode_of_expr $3) } | lelement { $1,None } lexprs: | tlelement COMMA lexprs { $1 :: $3 } | tlelement { [$1] } This works -- its part of the Felix grammar: tlelement is left recursive, lexprs is right recursive, and the reason is clear -- its the most efficient way to build a list. Perhaps someone can explain why this actually works ..?? -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net ------------------- 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