Skip to main content

Compositional Language Engineering Using Generated, Extensible, Static Type-Safe Visitors

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNPSE,volume 9764))

Abstract

Language workbenches usually produce infrastructure to represent models as abstract syntax trees (AST) and employ processing infrastructure largely based on visitors. The visitor pattern suffers from the expression problem regarding extensibility and reuse. Current approaches either forsake static type safety, require features unavailable in popular object-oriented languages (e.g., open classes), or rely on procedural abstraction and thereby give up the object-oriented data encapsulation (the AST) itself. Our approach to visitors exploits knowledge about the AST and generation of statically type-safe external visitor interfaces that support extensibility in two dimensions: (1) defining new operations by implementing the interface and (2) extending the underlying data structure, usually without requiring adaptation of existing implemented visitors. We present a concept of visitor development for language engineering that enables an adaptable traversal and provides hook points for implementing concrete visitors. This approach is applicable to single DSLs and to language composition. It thus enables a transparent, easy to use, and static type-safe solution for the typical use cases of language processing.

This is a preview of subscription content, log in via an institution.

Buying options

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    http://www.tiobe.com/index.php/tiobe_index.

  2. 2.

    MontiCore is open source (https://github.com/MontiCore/monticore) and running visitor examples as described in this paper are available online

    (http://www.se-rwth.de/materials/mcvisitors/).

  3. 3.

    For a production P and a separator s the expression (P || "s")* denotes an arbitrary count of P separated by s. There is no s at the end.

  4. 4.

    Default implementations are available since Java 8.

  5. 5.

    http://download.eclipse.org/modeling/tmf/xtext/javadoc/2.9/org/eclipse/xtext/nodemodel/BidiTreeIterator.html.

  6. 6.

    https://eclipse.org/xtend/documentation/202_xtend_classes_members.html.

References

  1. Bettini, L.: Implementing Domain-Specific Languages with Xtext and Xtend. Packt Publishing, Birmingham (2013)

    Google Scholar 

  2. Carlisle, M.C., Sward, R.E.: An Automatic “Visitor” Generator for Ada. Ada Letters (2002)

    Google Scholar 

  3. Clifton, C., Leavens, G.T., Chambers, C., Millstein, T.: MultiJava: modular open classes and symmetric multiple dispatch for Java. In: Proceedings of the 15th ACM SIGPLAN Conference on Object-oriented Programming, Systems, Languages, and Applications (2000)

    Google Scholar 

  4. Erdweg, S., et al.: The state of the art in language workbenches. In: Erwig, M., Paige, R.F., Van Wyk, E. (eds.) SLE 2013. LNCS, vol. 8225, pp. 197–217. Springer, Heidelberg (2013)

    Chapter  Google Scholar 

  5. Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and Mixins. In: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (1998)

    Google Scholar 

  6. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: Elements of Reusable Object-oriented Software. Addison-Wesley Professional, Boston (1995)

    MATH  Google Scholar 

  7. Gouseti, M., Peters, C., van der Storm, T.: Extensible Language Implementation with Object Algebras (Short Paper). SIGPLAN Not. (2014)

    Google Scholar 

  8. Haber, A., Look, M., Mir Seyed Nazari, P., Navarro Perez, A., Rumpe, B., Völkel, S., Wortmann, A.: Composition of heterogeneous modeling languages. In: Desfray, P., Filipe, J., Hammoudi, S., Pires, L.F. (eds.) MODELSWARD 2015. CCIS, vol. 580, pp. 45–66. Springer, Heidelberg (2015)

    Chapter  Google Scholar 

  9. Hölldobler, K., Nazari, P.M.S., Rumpe, B.: Adaptable symbol table management by meta modeling and generation of symbol table infrastructures. In: Proceedings of the Workshop on Domain-Specific Modeling (2015)

    Google Scholar 

  10. Krahn, H., Rumpe, B., Völkel, S.: MontiCore: a framework for compositional development of domain specific languages. Int. J. Softw. Tools Technol. Transf. (STTT) 12(5), 353–372 (2010)

    Article  Google Scholar 

  11. Martin, R.C., Riehle, D., Buschmann, F. (eds.): Pattern Languages of Program Design 3. Addison-Wesley Longman Publishing Co., Inc., Boston (1997)

    Google Scholar 

  12. Merkle, B.: Textual modeling tools: overview and comparison of language workbenches. In: Proceedings of the ACM International Conference Companion on Object Oriented Programming Systems Languages and Applications Companion (2010)

    Google Scholar 

  13. Oliveira, B.C.S.: Genericity, Extensibility and Type-Safety in the Visitor Pattern. Oxford University, Oxford (2007)

    Google Scholar 

  14. Oliveira, B.C.D.S., Cook, W.R.: Extensibility for the masses: practical extensibility with object algebras. In: Proceedings of the 26th European Conference on Object-Oriented Programming (2012)

    Google Scholar 

  15. Oliveira, B.C.D.S., Wang, M., Gibbons, J.: The visitor pattern as a reusable, generic, type-safe component. In: SIGPLAN Notices (2008)

    Google Scholar 

  16. Palsberg, J., Jay, C.B.: The essence of the visitor pattern. In: Proceedings of the 22Nd International Computer Software and Applications Conference (1998)

    Google Scholar 

  17. Rendel, T., Brachthäuser, J.I., Ostermann, K.: From object algebras to attribute grammars. In: SIGPLAN Notices (2014)

    Google Scholar 

  18. Visser, J.: Visitor combination and traversal control. In: SIGPLAN Notices (2001)

    Google Scholar 

  19. Vlter, M., Benz, S., Dietrich, C., Engelmann, B., Helander, M., Kats, L.C.L., Visser, E., Wachsmuth, G.: DSL Engineering - Designing, Implementing and Using Domain-Specific Languages (2013). dslbook.org

  20. Torgersen, M.: The expression problem revisited. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)

    Chapter  Google Scholar 

  21. Zhang, H., Chu, Z., Oliveira, B.C.D.S., Storm, T.V.D.: Scrap Your boilerplate with object algebras. In: SIGPLAN Notices (2015)

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Robert Heim .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2016 Springer International Publishing Switzerland

About this paper

Cite this paper

Heim, R., Mir Seyed Nazari, P., Rumpe, B., Wortmann, A. (2016). Compositional Language Engineering Using Generated, Extensible, Static Type-Safe Visitors. In: Wąsowski, A., Lönn, H. (eds) Modelling Foundations and Applications. ECMFA 2016. Lecture Notes in Computer Science(), vol 9764. Springer, Cham. https://doi.org/10.1007/978-3-319-42061-5_5

Download citation

  • DOI: https://doi.org/10.1007/978-3-319-42061-5_5

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-319-42060-8

  • Online ISBN: 978-3-319-42061-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics