Getting into boost spirit; Qi or X3?

烂漫一生 提交于 2019-12-31 02:41:19

问题


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 threat things differently


回答1:


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

  • https://www.boost.org/doc/libs/1_68_0/libs/spirit/doc/html/spirit/qi.html
  • https://www.boost.org/doc/libs/1_68_0/libs/spirit/doc/x3/html/index.html


来源:https://stackoverflow.com/questions/52990661/getting-into-boost-spirit-qi-or-x3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!