In model-driven engineering, developing a textual domain-specific language (DSL) involves constructing a meta-model, which defines an underlying abstract syntax, and a grammar, which defines the concrete syntax for the DSL. Language workbenches such as Xtext allow the grammar to be automatically generated from the meta-model, yet the generated grammar usually needs to be manually optimized to improve its usability. When the meta-model changes during rapid prototyping or language evolution, it can become necessary to re-generate the grammar and optimize it again, causing repeated effort and potential for errors. In this paper, we present GrammarOptimizer, an approach for optimizing generated grammars in the context of meta-model-based language evolution. To reduce the effort for language engineers during rapid prototyping and language evolution, it offers a catalog of configurable grammar optimization rules. Once configured, these rules can be automatically applied and re-applied after future evolution steps, greatly reducing redundant manual effort. In addition, some of the supported optimizations can globally change the style of concrete syntax elements, further significantly reducing the effort for manual optimizations. The grammar optimization rules were extracted from a comparison of generated and existing, expert-created grammars, based on seven available DSLs.
翻译:在模型驱动工程中,开发文本领域特定语言(DSL)涉及构建定义底层抽象语法的元模型,以及定义具体语法的文法。Xtext等语言工作台允许从元模型自动生成文法,但生成的文法通常需要手动优化以提升可用性。当元模型在快速原型开发或语言演化过程中发生变化时,可能需要重新生成并再次优化文法,导致重复劳动和潜在错误。本文提出GrammarOptimizer方法,用于在基于元模型的语言演化场景中优化生成的文法。为降低语言工程师在快速原型和语言演化中的工作量,该方法提供可配置的语法优化规则目录。一旦完成配置,这些规则可在后续演化步骤中自动执行和重复应用,大幅减少冗余的人工操作。此外,部分支持的优化能力可全局改变具体语法元素的风格,进一步显著减少手动优化的投入。这些语法优化规则基于七种现有DSL,通过对比生成文法与专家创建文法提取得出。