Javascript 解析器生成器
我见过一些 javascript 解析器生成器:
I've seen some javascript parser generators:
吉森 (http://zaach.github.com/jison/)
PEG.js (http://pegjs.majda.cz/)
ANTLR (http://www.antlr.org/)
JS/CC (http://jscc.jmksf.com/)
有人有经验吗?
有什么好处和坏处?这些库准备好投入生产了吗?和性能?
What are the pros and cons? Are these libraries ready for production? And performance?
编辑:
我想在 javascript 中解析和运行不同的语言
EDIT:
I want to parse and run a different language in javascript
推荐答案
我不确定你是想要一个可以生成 JavaScript 编写的解析器的解析器生成器,还是一个使用 JavaScript 语法来构建 JavaScript 解析器的解析器生成器.
I'm not sure if you want a parser generator that would spit a JavaScript written parser or a parser generator that would use a JavaScript grammar to build a JavaScript parser.
无论如何,我只使用过 ANTLR 和 JavaCC.ANTLR 允许您以不同的语言(C、C#、Java)生成解析器,并且在它们的 GUI 树状形式上检查您的上下文无关语法表达式非常酷.但是从来没有找到它的 JavaScript 语法.
Anyway, I've only used ANTLR and JavaCC. ANTLR allows you to generate your parser in different languages (C, C#, Java) and it's pretty cool checking your Context-free grammar expressions on their GUI tree-like form. Never found a JavaScript grammar for it though.
JavaCC 有一个缺点.仅在 Java 中生成解析器.另一方面,我发现学习和从构建解析器的部分开始更容易 - 我发现这是最好的部分 - 围绕它构建你想要的任何东西,例如代码翻译器、改写器等.
JavaCC has a downside. Only generates the parser in Java. On the other hand, I found it easier to learn and to step from the part where you build the parser to - what I found to be the best part - building whatever you want around it e.g., code translator, rephraser, etc, etc.
相关文章