Compiler plugins can handle nested languages: AST-level expansion of LINQ queries for java

  • Authors:
  • Miguel Garcia

  • Affiliations:
  • Institute for Software Systems, Hamburg University of Technology, Germany

  • Venue:
  • ICOODB'09 Proceedings of the Second international conference on Object databases
  • Year:
  • 2009

Quantified Score

Hi-index 0.00

Visualization

Abstract

The integration of database and programming languages is made difficult by the different data models and type systems prevalent in each field. Functional-object query languages contribute to bridge this gap by letting software developers write declarative queries without imposing any specific execution strategy. Although some query optimizers support this paradigm, Java provides no means to embed queries in a seamless and typesafe manner. Interestingly, the benefits of such grammar extension (compile-time type inference and checking, user-friendly syntax) can alternatively be achieved with a compiler plugin as discussed in this paper for the LINQ query language and two Java compilers (from Sun and Eclipse). A prototype confirms the benefits of the approach by automating at compile-time (a) the parsing of LINQ queries nested in Java, (b) their analysis for well-formedness, and (c) their rewriting into statements to build Abstract Syntax Trees (ASTs). The technique is also applicable to other languages (JPQL, XQuery) which are handled nowadays by a Java compiler as uninterpreted strings, being thus prone to runtime exceptions due to breaches of static semantics.