Search code examples
boost-spiritboost-spirit-qiboost-spirit-x3

Getting into boost spirit; Qi or X3?


I was making an interpreter for a small personal project with a friend; we started implementing all the classes and general structure in which the code would be translated to then execute just to postpone the actual parsing code into these structures.

Now we have to build the parser, and after some search I found posts and people all over the place speaking about spirit Qi and spirit X3 as if they were (i think they are) 2 different ways of making a parser, but no-one saying the difference, which one is more recent, which one should i begin with.

The purpose would be, given a code string, output eventual errors, and if everything respects grammar AND logic, translate the code into a tree of the classes we already built. We'd like to check consistencies during parsing, for example the "you're using a variable that wasn't declared" kind of error.

I'm not sure how the 2 libraries treat things differently.


Solution

  • X3 is more recent, still experimental and requires C++14.

    Qi is

    • more stable
    • supports more stateful options more easily
    • supports lazy parsers (which you might like)
    • is much slower to compile

    The docs are