Advertisement

MetaBorg in Action: Examples of Domain-Specific Language Embedding and Assimilation Using Stratego/XT

  • Martin Bravenboer
  • René de Groot
  • Eelco Visser
Part of the Lecture Notes in Computer Science book series (LNCS, volume 4143)

Abstract

General-purpose programming languages provide limited facilities for expressing domain-specific concepts in a natural manner. All domain concepts need to be captured using the same generic syntactic and semantic constructs. Generative programming methods and program transformation techniques can be used to overcome this lack of abstraction in general-purpose languages.

In this tutorial we describe the MetaBorg method for embedding domain-specific languages, tailored syntactically and semantically to the application domain at hand, in a general-purpose language. MetaBorg is based on Stratego/XT, a language and toolset for the implementation of program transformation systems, which is used for the definition of syntactic embeddings and assimilation of the embedded constructs into the surrounding code.

We illustrate MetaBorg with three examples. JavaSwul is a custom designed language for implementing graphical user-interfaces, which provides high-level abstractions for component composition and event-handling. JavaRegex is a new embedding of regular expression matching and string rewriting. JavaJava is an embedding of Java in Java for generating Java code. For these cases we show how Java programs in these domains become dramatically more readable, and we give an impression of the implementation of the language embeddings.

Keywords

Regular Expression Menu Item Type Checker Abstract Syntax Tree Host Language 
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.

Preview

Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.

References

  1. 1.
    Baker, J., Hsieh, W.: Maya: multiple-dispatch syntax extension in java. In: PLDI 2002: Proceedings of the ACM SIGPLAN 2002 Conference on Programming language design and implementation, pp. 270–281. ACM Press, New York (2002)CrossRefGoogle Scholar
  2. 2.
    Batory, D., Lofaso, B., Smaragdakis, Y.: JTS: tools for implementing domain-specific languages. In: Proceedings Fifth International Conference on Software Reuse (ICSR 1998), pp. 143–153. IEEE Computer Society, Los Alamitos (1998)CrossRefGoogle Scholar
  3. 3.
    Brabrand, C., Schwartzbach, M.I.: Growing languages with metamorphic syntax macros. In: Proceedings of the 2002 ACM SIGPLAN Workshop on Partial Evaluation and Semantics-based Program Manipulation (PEPM 2002), pp. 31–40. ACM Press, New York (2002)CrossRefGoogle Scholar
  4. 4.
    van den Brand, M.G.J., Scheerder, J., Vinju, J.J., Visser, E.: Disambiguation filters for scannerless generalized LR parsers. In: Horspool, R.N. (ed.) CC 2002. LNCS, vol. 2304, pp. 143–158. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  5. 5.
    Bravenboer, M., Vermaas, R., Vinju, J.J., Visser, E.: Generalized type-based disambiguation of meta programs with concrete object syntax. In: Glück, R., Lowry, M. (eds.) GPCE 2005. LNCS, vol. 3676, pp. 157–172. Springer, Heidelberg (2005)CrossRefGoogle Scholar
  6. 6.
    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), Vancouver, Canada, pp. 365–383. ACM Press, New York (2004)CrossRefGoogle Scholar
  7. 7.
    Gould, C., Su, Z., Devanbu, P.: JDBC checker: A static analysis tool for SQL/JDBC applications. In: ICSE 2004: Proceedings of the 26th International Conference on Software Engineering, pp. 697–698. IEEE Computer Society, Los Alamitos (2004)CrossRefGoogle Scholar
  8. 8.
    Leavenworth, B.M.: Syntax macros and extended translation. Communications of the ACM 9(11), 790–793 (1966)MATHCrossRefGoogle Scholar
  9. 9.
    Su, Z., Wassermann, G.: The essence of command injection attacks in web applications. In: POPL 2006: Conference record of the 33rd ACM SIGPLAN-SIGACT symposium on Principles of programming languages, pp. 372–382. ACM Press, New York (2006)CrossRefGoogle Scholar
  10. 10.
    Vinju, J.J.: Analysis and Transformation of Source Code by Parsing and Rewriting. PhD thesis, University of Amsterdam (November 2005)Google Scholar
  11. 11.
    Visser, E.: Syntax Definition for Language Prototyping. PhD thesis, University of Amsterdam (September 1997)Google Scholar
  12. 12.
    Visser, E.: Meta-programming with concrete object syntax. In: Batory, D., Consel, C., Taha, W. (eds.) GPCE 2002. LNCS, vol. 2487, pp. 299–315. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  13. 13.
    Visser, E.: Program transformation with Stratego/XT: Rules, strategies, tools, and systems in StrategoXT-0.9. In: Lengauer, C., Batory, D., Consel, C., Odersky, M., et al. (eds.) Domain-Specific Program Generation. LNCS, vol. 3016, pp. 216–238. Springer, Heidelberg (2004)CrossRefGoogle Scholar
  14. 14.
    Zook, D., Huang, S.S., Smaragdakis, Y.: Generating AspectJ programs with Meta-AspectJ. In: Karsai, G., Visser, E. (eds.) GPCE 2004. LNCS, vol. 3286, pp. 1–18. Springer, Heidelberg (2004)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2006

Authors and Affiliations

  • Martin Bravenboer
    • 1
  • René de Groot
    • 1
  • Eelco Visser
    • 1
  1. 1.Department of Information and Computing SciencesUniversiteit UtrechtUtrechtThe Netherlands

Personalised recommendations