PMD 可以定制以完全支持新语言吗?

发布于 2024-09-01 21:22:34 字数 304 浏览 2 评论 0原文

能否在合理的时间内定制 PMD 以完全支持新语言?我的意思是我知道从技术上讲几乎任何事情都可以完成,但我想知道这是否可以在合理的时间内完成?例如< 2 周

本页提到如何编写 CPD 解析器 http://pmd.sourceforge.net /cpd-parser-howto.html

但这只是为了复制/粘贴检测吗?编写 CPD 解析器是否可以在规则集方面完全支持 PMD?

Can PMD be customized to fully support a new language, in a reasonable amount of time. I mean I know that technically almost anything can be done, but im wondering if this can be done in a reasonable amount of time? E.g. < 2 weeks

This page mentions how to write a CPD parser http://pmd.sourceforge.net/cpd-parser-howto.html

But is this just for copy / paste detection? Does writing a CPD parser give me full support of PMD in terms of rile sets?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

北笙凉宸 2024-09-08 21:22:34

我猜不会,但我不是 PMD 专家(我有自己的偏见,请检查我的简历)。

问题是:

  • 你能否快速为我的语言定义一个语法(也许,取决于你的水平、语言的混乱程度以及 PMD 提供的解析机制的强度)
  • 你能否定义我的语言的语义,以便PMD 工作提供的“语义检查”。您必须这样做,因为语法实际上并没有告诉您(和工具)任何有关语法语义的信息。我猜测 PMD 工具“语义检查”与 Java 的精确细节非常相关;如果你的语言与java完美匹配,这将是零工作。但事实并非如此,否则你也不会问这个问题。语言语义的差异,即使是微小的差异,也会导致代码解释的不连续变化。在开始执行“严肃的”语义之前,您可能必须构建一个符号表,将代码中的标识符映射到这些符号的声明(以及“语义”类型)。根据我使用的工具基础设施,对于真正的语言来说,仅此一步就需要 1-2 个月的时间。
  • 最后,您可能必须编写特定于您的语言的特殊 PMD 检查代码。这也需要时间和精力。

我构建了通用的编译器类型的机器(解析器、流分析器、样式/错误检查器),并且在我们的机器上一直被问到与这个问题相当的问题。我们尝试拥有大量可用的机器,尝试让新语言的集成变得容易,15 年来我们一直致力于让这种“方便快捷”。它仍然不方便,并且在几周内用我们的工具无法做到这一点。我怀疑 PMD 更好。

I would guess not, but I'm not a PMD expert (and I have my own bias, check my bio).

The issues are:

  • Can you define a syntax for my langauge quickly (maybe, depending on how good you are, how messy the language is, and the strength of the parsing machinery offered by PMD)
  • Can you define the semantics of my language so that "semantic checks" provided by PMD work. You have to do this, because syntax tells you (and a tool) literally nothing about semantic of the syntax. I would guess that the PMD tool 'semantic checks' are pretty wired into the precise details of Java; if you language matched java perfectly, this would be zero work. But it doesn't, or you wouldn't be asking the question. And langauge semantics differences, even minor ones, cause discontinuous changes to the interpreation of the code. Before you get to doing even "serious" semantics, you're likely to have to build a symbol table mapping identifiers in the code to declarations (and the "semantic" type) for those symbols. Based on tool infrastructure I work with, this step alone takes 1-2 months for a real language.
  • Lastly, you are likely to have to code special PMD checks that are specific to your langauge. That takes time and energy, too.

I build generic compiler-type machinery (parsers, flow analyzers, style/error checkers) and get asked the equivalent of this question all the time WRT to our machinery. We try to have a lot of machinery available, try to make it easy to integrate new langauges, and we've been working on trying to make this "convenient and fast" for 15+ years. Its still not convenient, and there's no way to do this with our tools in a few weeks. I doubt PMD is better.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文