[LLVMdev] LLVM OCaml Tutorial
OvermindDL1
overminddl1 at gmail.com
Wed Apr 22 13:06:04 PDT 2009
On Wed, Apr 22, 2009 at 11:16 AM, Jon Harrop <jon at ffconsultancy.com> wrote:
> I found flex and bison really tedious to use from C++. That was a long time
> ago and there are probably better alternatives now though. Still much worse
> than anything with first-class lexical closures and algebraic datatypes, of
> course. :-)
Same here. I also have issue with them due to some restrictions in
the syntax type they use. Personally I use Boost.Spirit2x (and the
first project I made with llvm was a little functional language that
was taught at my school a decade ago in the intro compiler course) as
it is pure C++ (no nasty pre-compiling of other stuff needed) and it
is a PEG parser (meaning that, unlike EBNF and so forth, it is
completely unambiguous in all cases), and the latest versions are just
about faster then I could hand-code it.
I still have that project laying around, I could turn it into a
tutorial as well (although I think the language definition I used is
copyright, I might want to change it to use the same syntax as the
existing tutorials, they are *very* close in syntax anyway, may not
even need to change the tree Spirit2x generates). Instead of doing
things by using classes and using virtual dispatch, I used standard
visitors that nicely get mostly compiled out in release, so it is
quite fast, and I say it is also a great deal easier to read and
understand then the existing tutorials. However, if I did make a
tutorial using Boost.Spirit2x and the visitor pattern, it would have
the requirement of needing Boost (which I personally think any C++
programmer should have anyway, some of it is rather useless but there
are some absolute gems in Boost).
Would you all accept a tutorial of the language the current tutorial
uses, but using Boost.Spirit2x as the parser (*vastly* reduced and
easier to read parsing code, would be but a tiny section), using
visitors (much easier to read through in my opinion, as well as being
faster and more in-line with what a compiler should be doing for
proper practices), and other such niceties, in exchange for needing
Boost for the tutorial (would of course be a section on how to set
Boost up as the tutorial would only be using header-only Boost
libraries anyway, would be very simple)?
Oh, and yes, Boost.Spirit2x basically adds such closures and such due
to heavy use of Boost.Pheonix.
More information about the llvm-dev
mailing list