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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 672FCBC57 for ; Thu, 23 Sep 2010 20:43:15 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AjkBAM88m0xKfVM2kGdsb2JhbACiLAgVAQEBAQkJDAcRAx+sQYk9ghSGay6IVQEBAwWFPQSKOA X-IronPort-AV: E=Sophos;i="4.57,224,1283724000"; d="scan'208";a="59026431" Received: from mail-gw0-f54.google.com ([74.125.83.54]) by mail3-smtp-sop.national.inria.fr with ESMTP; 23 Sep 2010 20:43:14 +0200 Received: by gwb15 with SMTP id 15so959225gwb.27 for ; Thu, 23 Sep 2010 11:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=06T4plVJlJcB07cZKg0j5qwAYx7UOSpFuJN5sx5imS8=; b=S2tozxZCq5Bt27GX6gtBEMbVasc/t0N4Cw7/LaOXnd6i84j9lxtIjDQzTgnE5hD6Hq HIjKz3ZFK5cqYlBa4bvcHYLo5HgfFC2WS839Og52Cw2gq0mW9lPuo7qcGuoZ2cIjeDlD QmM+hCMySOG2HYRaYAtFXMBIRn6xvoolartjY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=YGtnFyw0qObV7RQNGgs0HRchYllIofsinsMn7NyKxDtJKBbTfLM6FDqROX07vbzp+i Q3xJ3iyB+aZ6iszQVfgppqQ3BMEcn1qwKwHIoIi0FkAt8FSQs2O1S98fmQHP7MBqdjG1 +SPZfNTHfu+vJ5KndeAEPOflBjKzcxD8H9hU0= MIME-Version: 1.0 Received: by 10.151.98.15 with SMTP id a15mr3196952ybm.423.1285267388400; Thu, 23 Sep 2010 11:43:08 -0700 (PDT) Received: by 10.231.212.216 with HTTP; Thu, 23 Sep 2010 11:43:08 -0700 (PDT) In-Reply-To: <1285259219.1820.15.camel@knine> References: <1285259219.1820.15.camel@knine> Date: Thu, 23 Sep 2010 20:43:08 +0200 Message-ID: Subject: Re: [Caml-list] what do I need to know to understand camlp4 From: ben kuin To: Michael Ekstrand , caml-list@inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; camlp:01 0200,:01 camlp:01 syntax:01 context-free:01 grammars:01 wikipedia:01 syntax:01 ocaml:01 parser:01 ocaml:01 wikipedia:01 wiki:01 context-free:01 23,:98 thanks a lot for this information and the links, this is very helpful On Thu, Sep 23, 2010 at 6:26 PM, Michael Ekstrand wro= te: > On Thu, 2010-09-23 at 16:56 +0200, ben kuin wrote: >> Could someone give any idea how I can begin to understand how to write >> simple camlp4 extensions? > > Shameless self-plug, but I wrote a blog post this summer about my > experience figuring out how to do it. =A0I provide a walk-through and > explanation of a minimal syntax extension which adds lazy list pattern > matching support based on Batteries. =A0The URL: > > http://www.elehack.net/michael/blog/2010/06/ocaml-syntax-extension > > I do assume a basic knowledge of parsing context-free grammars, but a > generic tutorial on parsing with a tool such as Yacc can fill in that > gap. =A0The Wikipedia article[1] may also be helpful. > > Once you've lept the hurdle of figuring out what pieces you need to > write and build a syntax extension, the remaining tricky part is to > figure out what pieces of the grammar you need to extend to accomplish > your objective. =A0For that, I consult the definition of the OCaml parser > in Camlp4OCamlParser.ml in the OCaml source tree. > > - Michael > > 1. http://en.wikipedia.org/wiki/Context-free_grammar > > -- > Web/blog: http://elehack.net/michael > Jabber/Google Talk: this e-mail address > Twitter: http://twitter.com/elehack > mouse, n: a device for pointing at the xterm in which you want to type > >