caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michael Ekstrand <michael@elehack.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] what do I need to know to understand camlp4
Date: Thu, 23 Sep 2010 11:28:44 -0500	[thread overview]
Message-ID: <1285259324.1820.16.camel@knine> (raw)
In-Reply-To: <AANLkTimDGTYzqsQzEvQO4rgR-128q35VZKD4gk5n1LH+@mail.gmail.com>

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.  I provide a walk-through and
explanation of a minimal syntax extension which adds lazy list pattern
matching support based on Batteries.  The 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.  The 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.  For 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



  parent reply	other threads:[~2010-09-23 16:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-23 14:56 ben kuin
2010-09-23 15:21 ` [Caml-list] " David MENTRE
2010-09-23 19:50   ` ben kuin
2010-09-24  0:15     ` Elias Gabriel Amaral da Silva
2010-09-24  7:35       ` David House
2010-09-27 11:43         ` Elias Gabriel Amaral da Silva
2010-09-24  7:48     ` David MENTRE
2010-09-23 15:25 ` bluestorm
2010-09-23 16:23   ` Jake Donham
2010-09-23 18:49     ` ben kuin
2010-09-23 18:54       ` Jake Donham
2010-09-23 19:06       ` Yoann Padioleau
2010-09-23 16:28 ` Michael Ekstrand [this message]
2010-09-23 16:35 ` Sylvain Le Gall
     [not found] ` <1285259219.1820.15.camel@knine>
2010-09-23 18:43   ` [Caml-list] " ben kuin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1285259324.1820.16.camel@knine \
    --to=michael@elehack.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).