کد مقاله | کد نشریه | سال انتشار | مقاله انگلیسی | نسخه تمام متن |
---|---|---|---|---|
433725 | 1441665 | 2014 | 19 صفحه PDF | دانلود رایگان |
• We describe a Haskell library of strongly typed first-class attribute grammars.
• We extend the library with a set of combinators to define semantic macros.
• We show how to define language semantics by re-using and adapting existing semantics.
• We show how to redefine attributes.
• We describe an example implemented using the techniques introduced in this paper.
Having extensible languages is appealing, but raises the question of how to construct extensible compilers and how to compose compilers out of a collection of pre-compiled components. We show how having attribute grammar fragments as first-class values can be put into good use to answer this question; the approach leads naturally to a plug-in architecture, in which a core compiler can be constructed out of a (collection of) pre-compiled component(s), to which extra components can safely be added as the need arises.We extend AspectAG, our Haskell library for building strongly typed first-class attribute grammars, with a set of combinators that make it easy to describe new semantics in terms of already existing semantics, just as syntax macros extend the syntax of a language. We especially show how semantics thus defined can be redefined, thus adapting some aspects of the behavior as defined by the macro system only.
Journal: Science of Computer Programming - Volume 96, Part 2, 15 December 2014, Pages 211–229