柠檬力还是不柠檬力?
对于语法解析器,我曾经使用 Bison 来“玩”,它有它的优点/缺点。
上周,我在 SqLite 网站上注意到该引擎是用另一个语法解析器完成的:柠檬
读完薄文档后听起来很棒。
您对这个解析器有什么反馈吗?
无法真正在谷歌和维基百科上看到相关信息(只是一些例子,相同的教程)它似乎不是很受欢迎。 (Stack Overflow 中没有 lemon 标签 [ed :现在有:P])
For grammar parser, I used to "play" with Bison which have its pros/cons.
Last week, I noticed on SqLite site that the engine is done with another grammar parser: Lemon
Sounds great after reading the thin documentation.
Do you have some feedback about this parser?
Cannot really see pertinent information on Google and Wikipedia (just a few examples, same tutorials) It doesn't seem very popular. (there is no lemon tag in Stack Overflow [ed: there is now :P])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们在固件项目中使用 Lemon 的原因是:
当然,柠檬并不是灵丹妙药,它的应用范围有限。缺点是:
在做出选择之前权衡利弊。我已经完成了我的;-)
Reasons we are using Lemon in our firmware project are:
Surely Lemon is not a silver bullet, it has limited area of application. Among disadvantages:
Weigh the pros and cons before making your choice. I've done mine ;-)
有趣的发现!我没有实际使用过,所以评论是基于阅读文档。
重新设计使词法分析与解析分开进行似乎是有优点的。特别是,它有可能简化操作,例如处理多个或嵌套源文件。基于 Lex 的 yywrap() 机制不太理想。它避免了所有全局变量,并且具有仔细的内存分配和释放控制,这应该对它有利(它允许选择分配器和释放器也有很大帮助 - 至少对于我工作的环境来说,内存分配始终是一个问题) 。
重新思考如何组织规则以及如何识别终端是一个好主意。
总而言之,它看起来像是 Bison 经过深思熟虑的重新设计。
根据引用的网页,它属于公共领域。
Interesting find! I haven't actually used it, so the commentary is based on reading the documentation.
The redesign so that the lexical analysis is done separately from the parsing immediately seems to have merit. In particular, it has the potential to simplify operations such as handling multiple or nested source files. The Lex-based
yywrap()
mechanism is less than ideal. That it avoids all global variables and has careful memory allocation and deallocation control should count in its favour (that it allows the choice of allocator and deallocator greatly helps too - at least for the environments where I work, where memory allocation is always an issue).The rethinking on how the rules are organized and how the terminals are identified is a good idea.
All in all, it looks like a well thought out redesign of Bison.
It is in the public domain according to the referenced web pages.