The development of programming languages involves complex theoretical and practical challenges, particularly when addressing modularity and reusability through language extensions. While language workbenches aim to enable modular development under the constraints of the language extension problem, one critical constraint -- separate compilation -- is often relaxed due to its complexity. However, this relaxation undermines artifact reusability and integration with common dependency systems. A key difficulty under separate compilation arises from managing attribute grammars, as extensions may introduce new attributes that invalidate previously generated abstract syntax tree structures. Existing approaches, such as the use of dynamic maps in the Neverlang workbench, favor flexibility at the cost of compile-time correctness, leading to potential runtime errors due to undefined attributes. This work addresses this issue by introducing nlgcheck, a theoretically sound static analysis tool based on data-flow analysis for the Neverlang language workbench. nlgcheck detects potential runtime errors -- such as undefined attribute accesses -- at compile time, preserving separate compilation while maintaining strong static correctness guarantees. Experimental evaluation using mutation testing on Neverlang-based projects demonstrates that nlgcheck effectively enhances robustness without sacrificing modularity or flexibility and with a level of performance that does not impede its adoption in daily development activities.
翻译:编程语言的发展涉及复杂的理论与实际挑战,尤其在通过语言扩展解决模块化与可复用性问题时。虽然语言工作台旨在语言扩展问题的约束下实现模块化开发,但一个关键约束——独立编译——因其复杂性常被放宽。然而,这种放宽会损害制品的可复用性以及与常见依赖系统的集成。独立编译下的一个主要困难源于属性文法的管理,因为扩展可能引入新的属性,从而使先前生成的抽象语法树结构失效。现有方法(例如Neverlang工作台中使用的动态映射)以牺牲编译时正确性为代价换取灵活性,导致因未定义属性而可能产生运行时错误。本研究通过引入nlgcheck来解决这一问题,这是一个基于数据流分析、理论可靠的静态分析工具,专为Neverlang语言工作台设计。nlgcheck能在编译时检测潜在的运行时错误(例如未定义属性访问),在保持独立编译的同时提供强大的静态正确性保证。通过对基于Neverlang的项目进行变异测试的实验评估表明,nlgcheck能有效增强鲁棒性,且不牺牲模块化或灵活性,其性能水平亦不会阻碍在日常开发活动中的采用。