Generalized Type-Based Disambiguation of Meta Programs with Concrete Object Syntax

Martin Bravenboer, Rob Vermaas, Jurgen J. Vinju, Eelco Visser. Generalized Type-Based Disambiguation of Meta Programs with Concrete Object Syntax. In Robert Glück, Michael R. Lowry, editors, Generative Programming and Component Engineering, 4th International Conference, GPCE 2005. Volume 3676 of Lecture Notes in Computer Science, pages 157-172, Springer, Tallinn, Estonia, 2005. [doi]

Abstract

In meta programming with concrete object syntax, object-level programs are composed from fragments written in concrete syntax. The use of small program fragments in such quotations and the use of meta-level expressions within these fragments (anti-quotation) often leads to ambiguities. This problem is usually solved through explicit disambiguation, resulting in considerable syntactic overhead. A few systems manage to reduce this overhead by using type information during parsing. Since this is hard to achieve with traditional parsing technology, these systems provide specific combinations of meta and object languages, and their implementations are difficult to reuse. In this paper, we generalize these approaches and present a language independent method for introducing concrete object syntax without explicit disambiguation. The method uses scannerless generalized-LR parsing to parse meta programs with embedded object-level fragments, which produces a forest of all possible parses. This forest is reduced to a tree by a disambiguating type checker for the meta language. To validate our method we have developed embeddings of several object languages in Java, including AspectJ and Java itself.