[LLVMdev] LLVM OCaml Tutorial

Erick Tryzelaar idadesub at users.sourceforge.net
Mon Apr 20 20:46:16 PDT 2009

2009/4/13 Chris Wailes <chris.wailes at gmail.com>:
> I'm currently going through the LLVM OCaml bindings tutorial in preparation
> for using LLVM in my own project.  While the tutorial is very helpful, it
> was somewhat hard to start due to the fact that I plan on using ocamllex and
> ocmalyacc and the tutorial hand rolls their own lexer and parser.
> I have managed to adapt almost all of the tutorial code into using ocamllex
> and ocamlyacc (the only thing I'm missing is the ability to assign
> precendence to user defined binary and unary operators), and was wondering
> if ther would be an interest in adding my code as supplimental material.

Great! I'd be happy to add this, though I think as as an addendum
instead of a replacement unless the community feels strongly about it.
Since most of the llvm documentation is for c++, I wanted the ocaml
developers to be able to read the ocaml tutorial then the c++ tutorial
and it be nearly one-to-one. I thought camlp4 did a much better job of
matching the c++ tutorial than ocamllex/ocamlyacc. That said, a lot of
people use them and it'd be handy to see how to use them with llvm as

On Sat, Apr 18, 2009 at 11:02 AM, Jon Harrop <jon at ffconsultancy.com> wrote:
> You may also want to write an even smaller parser using camlp4...

I'm happy to apply any patches :) Even better if you wanted to extend
the tutorial to support things like garbage collection.

2009/4/19 Chris Wailes <chris.wailes at gmail.com>:
> I would consider doing this, but one of the main reasons I couldn't use the
> main tutorial was because the Fedora 10 camlp4 package was messed up and the
> pre processors weren't linked correctly (I don't think Fedora likes OCaml
> much).

What was the problem? I just tested it out on fedora 10 and it worked
after I installed the ocaml, ocaml-camlp4, and ocaml-camlp4-devel

> Anyway, I think it might be best to not include camlp4 macros in the
> parser, simply to reduce the number of tools that someone needs to know to
> understand the files.  If they know camlp4 they can always add support for
> it in their own projects or as an exercise in understanding the tutorial
> code.

Well you still run into that with ocamllex/ocamlyacc :) Maybe I'm just
used to the stream syntax extension, but I figured it was fair game
since it's part of the standard install. It's not my fault the fedora
project decided to make it not part of the standard ocaml install :)

More information about the llvm-dev mailing list