ANTLR 或 JavaCC 哪个更好? [英] What's better, ANTLR or JavaCC?

查看:102
本文介绍了ANTLR 或 JavaCC 哪个更好?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关注点是文档/可学习性、eclipse 集成、工具、社区支持和性能(大致按这个顺序).

Concerns are documentation/learnability, eclipse integration, tooling, community support and performance (in roughly that order).

推荐答案

您不应该排除以下几种选择:

There are a couple of alternatives you shouldn't rule out:

  • JParsec 是一个解析器组合器框架,可让您完全从代码构建解析器.
  • Scala 的解析器组合器框架 解决了类似的问题;然而,Scala 的语法使所有这些都更具可读性.
  • 然后还有由 John Metsker 为他的书 使用 Java 构建解析器;我不记得图书馆的确切位置,但至少过去它在互联网上流传.它解决了同样的问题:您没有在单独的非 Java 文件中定义语法和标记定义;相反,它全是 Java.
  • Fortress,Sun 多年来一直在开发的编程语言现在似乎建立在这个工具包上:大鼠.我没有太多信息,但我认为如果他们将它用于他们的新编程语言,它可能具有一些有趣的功能.
  • JParsec is a parser combinator framework that allows you to construct your parser entirely from code.
  • Scala's parser combinator framework addresses a similar concern; however, Scala's syntax makes all of this much more readable.
  • Then there's also the parser combinator framework done by John Metsker, for his book Building Parsers With Java; I don't remember exactly where the library is, but it was at least floating around on the Internet in the past. It addresses the same concern: you don't define your grammar and token definitions in a separate non-Java file; instead, it's all Java.
  • Fortress, the programming language Sun has been working on for years now seems to be build on this toolkit: Rats. I don't have much information, but I reckon if they use it for their new programming language, it probably has some interesting features.

总的来说,我的印象是代码生成器的时代已经结束.如果我是你,我会使用 Scala 的解析器组合器工具包.基本上,任何支持 Scala 的 IDE 也支持"这个解析器组合器框架.性能很好,AFAICT.

In general, I get the impression that the years of the code generators are over. If I would be you, I would use Scala's parser combinator toolkit. Basically, any IDE supporting Scala, also 'supports' this parser combinator framework. Performance is good, AFAICT.

顺便说一句,ANTLR 有相当不错的 IDE 支持,作为一个 Eclipse 插件(但也许 IntelliJ 中也有一些东西 - 我不记得了.)所以,如果你选择定义你的词法分析器的经典方法和您的语言之外的解析器,那么我认为 ANTLR 应该是您的选择.它在 Java 开发人员中占有最大的份额,有工具支持,还有 ANTLR 的作者写的一本好书.我不认为任何其他工具包可以声称这一点.

By the way, ANTLR has quite decent IDE support, as an Eclipse plugin (but perhaps there's also something in IntelliJ - I don't remember.) So, if you would opt for the classic approach of defining your lexical analyzer and parser outside of your language, then ANTLR should be your choice, I think. It has the biggest mindshare among Java developers, there is tool support, and there is a great book by the author of ANTLR. I don't think any of the other toolkits can claim that.

这篇关于ANTLR 或 JavaCC 哪个更好?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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