From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 8CAC7BC3D for ; Mon, 8 Aug 2005 08:47:21 +0200 (CEST) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.196]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j786lKiR014401 for ; Mon, 8 Aug 2005 08:47:21 +0200 Received: by rproxy.gmail.com with SMTP id a36so1188852rnf for ; Sun, 07 Aug 2005 23:47:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=JsMZDdgcn6L/O7YwIpajLx8UoIqxpL3DZ4090qgea+ibzae0K0D3yluWqXozYn2UzT0bdAttVNZg+DBCZfJI1cPVPZzeBM+FrXIHCzQSO4Y8rYhIaLBY8sYosv3flyTcTrlHVngVk4+J1zmDMwnqYN6MfJ68V/5Q1Ofs91r2CG0= Received: by 10.38.79.39 with SMTP id c39mr1365121rnb; Sun, 07 Aug 2005 23:47:20 -0700 (PDT) Received: by 10.38.209.44 with HTTP; Sun, 7 Aug 2005 23:47:20 -0700 (PDT) Message-ID: Date: Mon, 8 Aug 2005 18:47:20 +1200 From: Jonathan Roewen To: Jon Harrop Subject: Re: [Caml-list] ocamllex+ocamlyacc and not parsing properly Cc: caml-list@yquem.inria.fr In-Reply-To: <200508080739.04662.jon@ffconsultancy.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <200508080739.04662.jon@ffconsultancy.com> X-Miltered: at nez-perce with ID 42F6FFF8.002 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 ocamllex:01 ocamlyacc:01 parsing:01 grammar:01 lexer:01 ocaml:01 lexing:01 lexing:01 parsing:01 ocaml:01 lexer:01 parser:01 parser:01 wrote:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_BY_IP autolearn=disabled version=3.0.3 On 8/8/05, Jon Harrop wrote: > On Monday 08 August 2005 06:03, Jonathan Roewen wrote: > > BTW: A tutorial on these sorts of things (i.e. something a bit more > > complicated than the calculator example) would be great to have as a > > resource. >=20 > Given that the grammar is tiny and the lexer has almost as much OCaml cod= e as > lexing rules, I think this is a good candidate for not using lexing and > parsing at all. If you wrote this as an OCaml function, how long would it= be? I have no idea, and don't really want to think about it either. Perhaps someone could come up with a fancy regex using the Str module that could do it in a single line, although you'd still need to generate the types with some big function. The lexer and parser are straightforward and simple, and they work (now -- using a ref). Not to mention clear to read :) I think a giant regex and type generating function would be less clear and understandable. Sure it'll prolly add about 10Kb using lexer+parser, but I don't care too much about that. Jon