Generalized Type-Based Disambiguation of Meta Programs with Concrete Object Syntax
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.
Unable to display preview. Download preview PDF.
- 7.van den Brand, M.G.J., Klusener, S., Moonen, L., Vinju, J.J.: Generalized Parsing and Term Rewriting - Semantics Directed Disambiguation. In: Bryant, B., Saraiva, J. (eds.) LDTA 2003. ENTCS, vol. 82. Elsevier, Amsterdam (2003)Google Scholar
- 8.van den Brand, M.G.J., Moreau, P.E., Vinju, J.J.: A generator of efficient strongly typed abstract syntax trees in Java. IEE Proceedings - Software (May 2005)Google Scholar
- 9.van den Brand, M.G.J., Ringeissen, C.: ASF+SDF parsing tools applied to ELAN. In: Third International Workshop on Rewriting Logic and Applications. ENTCS (2000)Google Scholar
- 11.Bravenboer, M., Visser, E.: Concrete syntax for objects. Domain-specific language embedding and assimilation without restrictions. In: Schmidt, D.C. (ed.) Proceedings of the 19th ACM SIGPLAN Conference on Object-Oriented Programing, Systems, Languages, and Applications (OOPSLA 2004), pp. 365–383. ACM Press, New York (2004)CrossRefGoogle Scholar
- 13.de Rauglaudre, D.: Camlp4 reference manual, INRIA (September 2003)Google Scholar
- 15.Eclipse Java Development Tools (JDT), website: http://www.eclipse.org/jdt/
- 16.Klint, P., Visser, E.: Using filters for the disambiguation of context-free grammars. In: Pighizzini, G., San Pietro, P. eds, Proc. ASMICS Workshop on Parsing Theory, Tech. Rep. 126, Università di Milano, pp. 1–20 (1994)Google Scholar
- 18.Vinju, J.J.: A type driven approach to concrete meta programming. Technical Report SEN-E0507, Centrum voor Wiskunde en Informatica (2005)Google Scholar
- 19.Visser, E.: Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam (September 1997)Google Scholar