论文标题
使用参考属性语法跨不同领域的语言重复使用静态分析
Reusing Static Analysis across Different Domain-Specific Languages using Reference Attribute Grammars
论文作者
论文摘要
上下文:特定于领域的语言(DSL)使域专家能够自己指定任务和问题,同时促进静态分析以尽早阐明模型域中的问题。尽管语言工作台简化了DSL和通用语言扩展的设计,但仍必须手动实施静态分析。 查询:此外,静态分析,例如复杂度指标,依赖性分析和声明使用分析通常是依赖域的,并且不能轻易重复使用。因此,将现有的静态分析转移到另一个DSL会导致大量实施开销。但是,该开销并不总是本质上必要的:在许多情况下,虽然进行静态分析的DSL的概念是特定于域特异性的,但分析中采用的基本算法实际上是与域无关的,因此可以原则上重复使用,并根据指定的方式重复使用。尽管当前方法可以内部或与外部访问者实现静态分析,但该实现与该语言的语法相关联,并且不能轻易重复使用。到目前为止,实现可重复使用的静态分析的一种常用方法依赖于对进行分析进行分析的中间表示。但是,这需要相当多的实施工作。 方法:为了解决这一点,已经提出了将必要的特定领域概念映射到算法与域无关的数据结构中,但没有实际的实现和重用的证明。因此,为了再次重复使用静态分析,我们通过使用高阶属性来创建与域无关的覆盖结构的映射来采用关系参考属性语法(RAG)。 知识:我们描述了如何在特定于分析的数据结构上指定静态分析,关系破布如何帮助规范以及如何从域特异性语言中进行映射。此外,我们演示了如何在另一种通用语言中对DSL的静态分析进行外部化和重复使用。 接地:使用抹布系统jastadd评估该方法。为了说明可重复性,我们实施了两种分析,每种都有两种寻址语言:用于小型状态机DSL中的周期检测分析,用于检测Java类型和软件包中的循环依赖性,以及对Java和Modelica Modeling语言应用的可变阴影分析。因此,我们证明了在三个完全不同域中的两种分析算法的重复使用。此外,我们使用周期检测分析来通过将我们的外部分析与分析Qualitas语料库中所有Java程序的内部参考实现进行比较来评估效率,从而表明外部化分析仅会导致最小的开销。 重要性:我们再次使静态分析可重复使用,显示了使用关系抹布对DSL和通用语言外部化静态分析的实用性和效率。
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.