当前位置: X-MOL 学术J. Comput. Lang. › 论文详情
Our official English website, www.x-mol.net, welcomes your feedback! (Note: you will need to create a separate account there.)
Reflection of terms in attribute grammars: Design and applications
Journal of Computer Languages ( IF 1.7 ) Pub Date : 2021-03-31 , DOI: 10.1016/j.cola.2021.101033
Lucas Kramer , Ted Kaminski , Eric Van Wyk

This paper shows how reflection on undecorated syntax trees (terms) used in attribute grammars can significantly reduce the amount of boiler-plate specifications that must be written. The proposed reflection system is implemented in the form of a

function mapping terms and other values into a generic representation and a
function for the inverse mapping. The system is implemented in the Silver attribute grammar system. We demonstrate the usefulness of this approach to reflection in attribute grammars in several ways. The first use is in the serialization and de-serialization of the interface files Silver generates to support separate compilation; a custom interface language was replaced by a generic reflection-based implementation. Secondly, we describe an extension to Silver itself that simplifies writing language extensions for the ableC extensible C specification by allowing language engineers to specify C-language syntax trees using the concrete syntax of C (with typed holes) instead of writing abstract syntax trees. Third, strategic term rewriting in the style of Stratego is implemented using reflection as a library for, and extension to, Silver. Finally, an experimental implementation of staged interpreters for a small staged functional language is discussed.



中文翻译:

属性语法中术语的反映:设计和应用

本文显示了对属性语法中使用的未修饰语法树(术语)的思考如何能够显着减少必须编写的样板规范的数量。所提出的反射系统以以下形式实现:

函数将术语和其他值映射为通用表示形式和
逆映射功能。该系统在Silver属性语法系统中实现。我们以几种方式证明了这种方法在属性语法中进行反思的有用性。第一个用途是Silver生成的接口文件的序列化和反序列化,以支持单独的编译;自定义界面语言被基于反射的通用实现所取代。其次,我们描述了Silver本身的扩展,它简化了ableC的编写语言扩展。可扩展的C规范,允许语言工程师使用C的具体语法(带有带类型的孔)指定C语言语法树,而不用编写抽象语法树。第三,以Stratego风格进行的战略术语重写是使用反射作为Silver的库并对其进行扩展来实现的。最后,讨论了针对小型分段功能语言的分段解释器的实验实现。

更新日期:2021-04-30
down
wechat
bug