什么是从boost.org灵分析器生成框架的缺点是什么? [英] What are the disadvantages of the Spirit parser-generator framework from boost.org?

查看:118
本文介绍了什么是从boost.org灵分析器生成框架的缺点是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一些问题我已经看到了精神建议从 boost.org 分析器生成框架,但在随后的评论没有从人们使用灵谁不快乐抱怨。将这些人请站出来,什么是缺点还是缺点使用精神给我们的其他解释?

In several questions I've seen recommendations for the Spirit parser-generator framework from boost.org, but then in the comments there is grumbling from people using Spirit who are not happy. Will those people please stand forth and explain to the rest of us what are the drawbacks or downsides to using Spirit?

推荐答案

这是一个相当酷的想法,我喜欢这样。这是特别有用,真正学会如何使用C ++模板。

It is a quite cool idea, and I liked it; it was especially useful to really learn how to use C++ templates.

但他们的文档推荐的精神,为小到中等规模的解析器使用。一种用于完整的语言解析器将采取年龄进行编译。
我将列出三个原因。

But their documentation recommends the usage of spirit for small to medium-size parsers. A parser for a full language would take ages to compile. I will list three reasons.


  • 无扫描解析。虽然这是相当简单的,需要回溯时,它可能会分析器放缓。它是可选的,但 - 词法分析器可以集成,看到精神特性,C preprocessor。的〜300线(包括h和.cpp文件)文法编译(未优化)至6M与海湾合作委员会的文件。内联和最大优化,得到了下来〜1,7M。

  • Scannerless parsing. While it's quite simpler, when backtracking is required it may slow down the parser. It's optional though - a lexer might be integrated, see the C preprocessor built with Spirit. A grammar of ~300 lines (including both .h and .cpp files) compiles (unoptimized) to a file of 6M with GCC. Inlining and maximum optimizations gets that down to ~1,7M.

慢解析 - 有语法没有静态检查,既不是暗示有关所需过度超前,也不是为了验证基本的错误,如为左递归(这会导致无限递归的递归下降的情况下使用解析器LL语法)。左递归是不是一个很艰难的bug跟踪,虽然,但过度超前可能导致指数解析倍。

Slow parsing - there is no static checking of the grammar, neither to hint about excessive lookahead required, nor to verify basic errors, such as for instance usage of left recursion (which leads to infinite recursion in recursive-descent parsers LL grammars). Left recursion is not a really hard bug to track down, though, but excessive lookahead might cause exponential parsing times.

重型模板的使用 - 虽然这有一定的优势,这会影响编译时间和code尺寸。此外,语法定义通常必须对所有其他用户都可以看到,影响更为编译时间。
我已经能够移动语法加入明确的模板实例与正确的参数.cpp文件,但它是不容易的。

Heavy template usage - while this has certain advantages, this impacts compilation times and code size. Additionally, the grammar definition must normally be visible to all other users, impacting even more compilation times. I've been able to move grammars to .cpp files by adding explicit template instantiations with the right parameters, but it was not easy.

更新:我的反应仅限于我的精神的经典,而不是精神V2的经验。我仍然认为精神是大量基于模板的,但现在我只是猜测。

UPDATE: my response is limited to my experience with Spirit classic, not Spirit V2. I would still expect Spirit to be heavily template-based, but now I'm just guessing.

这篇关于什么是从boost.org灵分析器生成框架的缺点是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆