开发者

Javascript parser generator [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 9 years ago.

I've seen some javascript parser generators:

  1. Jison (http://zaach.github.com/jison/)

  2. PEG.js (http://pegjs.majda.cz/)

  3. ANTLR (http://www.antlr.org/)

  4. JS/CC (http://jscc.jmksf.com/)

Does any one have any experience with them?

What are the pros and cons? Are these libraries ready for production? And performance?

开发者_JAVA技巧EDIT:

I want to parse and run a different language in javascript


PEG.js is incredibly easy to work with. Its "try online" feature is really useful in learning how to use the system quickly. I'm currently using it in the Rhino environment to parse a language I'm writing. I'm not a big fan of Rhino, but PEG.js sure is nice.


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.

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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜