使用引用属性文法在不同领域特定语言间重用静态分析
Reusing Static Analysis across Different Domain-Specific Languages using Reference Attribute Grammars
摘要:
内容:领域特定语言(DSL)使领域专家能够自己指定任务和问题,同时使静态分析能够尽早阐明建模领域中的问题。虽然语言工作台已经简化了DSL的设计和对通用语言的扩展,但静态分析仍然必须手动实现。查询:此外,静态分析,例如,复杂性度量、依赖性分析和声明使用分析通常是域相关的,并且不能容易地重用。因此,将现有的静态分析转移到另一个DSL会导致巨大的实现开销。然而,这种开销并不总是本质上是必要的:在许多情况下,虽然执行静态分析的DSL的概念是特定于域的,但分析中使用的底层算法实际上是与域无关的,因此原则上可以重用,这取决于它是如何指定的。虽然当前的方法要么在内部实现静态分析,要么使用外部访问者,但该实现与语言的语法相关联,并且不能容易地重用。到目前为止,实现可重用的静态分析的常用方法依赖于转换成执行分析的中间表示。然而,这需要作出相当多的额外执行努力。方法:为了解决这个问题,有人提出将必要的领域特定概念映射到算法的领域独立数据结构,但没有实际的实现和重用的演示。因此,为了使静态分析再次可重用,我们采用关系引用属性语法(RAG)通过创建这样的映射到域独立的覆盖结构,使用高阶属性。知识:我们描述了如何在特定于分析的数据结构上指定静态分析,关系RAG如何帮助规范,以及如何执行来自特定于域的语言的映射。此外,我们演示了如何静态分析的DSL可以外化和重用的另一种通用语言。接地:使用RAG系统JastAdd对该方法进行了评估。为了说明可重用性,我们实现了两个分析与两个寻址的语言:一个循环检测分析中使用的小型状态机DSL和检测Java类型和包中的循环依赖关系,变量阴影的分析,适用于Java和Modelica建模语言。因此,我们证明了在三个完全不同的域中的两个分析算法的重用。此外,我们使用的周期检测分析,以评估效率,通过比较我们的外部分析的内部参考实现分析所有的Java程序中的Qualitas语料库,从而能够表明,外部化的分析只会产生最小的开销。重要性:我们使静态分析可重用,再次显示的实用性和效率外化静态分析的DSL和通用语言使用关系RAG。
英文摘要:
Context: Domain-specific languages (DSLs) enable domain experts to specify tasks and problems themselves, while enabling static analysis to elucidate issues in the modelled domain early. Although language workbenches have simplified the design of DSLs and extensions to general purpose languages, static analyses must still be implemented manually. Inquiry: Moreover, static analyses, e.g., complexity metrics, dependency analysis, and declaration-use analysis, are usually domain-dependent and cannot be easily reused. Therefore, transferring existing static analyses to another DSL incurs a huge implementation overhead. However, this overhead is not always intrinsically necessary: in many cases, while the concepts of the DSL on which a static analysis is performed are domain-specific, the underlying algorithm employed in the analysis is actually domain-independent and thus can be reused in principle, depending on how it is specified. While current approaches either implement static analyses internally or with an external Visitor, the implementation is tied to the language's grammar and cannot be reused easily. Thus far, a commonly used approach that achieves reusable static analysis relies on the transformation into an intermediate representation upon which the analysis is performed. This, however, entails a considerable additional implementation effort. Approach: To remedy this, it has been proposed to map the necessary domain-specific concepts to the algorithm's domain-independent data structures, yet without a practical implementation and the demonstration of reuse. Thus, to make static analysis reusable again, we employ relational Reference Attribute Grammars (RAGs) by creating such a mapping to a domain-independent overlay structure using higher-order attributes. Knowledge: We describe how static analysis can be specified on analysis-specific data structures, how relational RAGs can help with the specification, and how a mapping from the domain-specific language can be performed. Furthermore, we demonstrate how a static analysis for a DSL can be externalized and reused in another general purpose language. Grounding: The approach was evaluated using the RAG system JastAdd. To illustrate reusability, we implemented two analyses with two addressed languages each: a cycle detection analysis used in a small state machine DSL and for detecting circular dependencies in Java types and packages, and an analysis of variable shadowing, applied to both Java and the Modelica modelling language. Thereby, we demonstrate the reuse of two analysis algorithms in three completely different domains. Additionally, we use the cycle detection analysis to evaluate the efficiency by comparing our external analysis to an internal reference implementation analysing all Java programs in the Qualitas Corpus and thereby are able to show that an externalized analysis incurs only minimal overhead. Importance: We make static analysis reusable, again, showing the practicality and efficiency of externalizing static analysis for both DSLs and general purpose languages using relational RAGs.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。