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.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Similar content being viewed by others
Notes
- 1.
- 2.
MontiCore is open source (https://github.com/MontiCore/monticore) and running visitor examples as described in this paper are available online
- 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.
Default implementations are available since Java 8.
- 5.
- 6.
References
Bettini, L.: Implementing Domain-Specific Languages with Xtext and Xtend. Packt Publishing, Birmingham (2013)
Carlisle, M.C., Sward, R.E.: An Automatic “Visitor” Generator for Ada. Ada Letters (2002)
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)
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)
Flatt, M., Krishnamurthi, S., Felleisen, M.: Classes and Mixins. In: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (1998)
Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: Elements of Reusable Object-oriented Software. Addison-Wesley Professional, Boston (1995)
Gouseti, M., Peters, C., van der Storm, T.: Extensible Language Implementation with Object Algebras (Short Paper). SIGPLAN Not. (2014)
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)
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)
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)
Martin, R.C., Riehle, D., Buschmann, F. (eds.): Pattern Languages of Program Design 3. Addison-Wesley Longman Publishing Co., Inc., Boston (1997)
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)
Oliveira, B.C.S.: Genericity, Extensibility and Type-Safety in the Visitor Pattern. Oxford University, Oxford (2007)
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)
Oliveira, B.C.D.S., Wang, M., Gibbons, J.: The visitor pattern as a reusable, generic, type-safe component. In: SIGPLAN Notices (2008)
Palsberg, J., Jay, C.B.: The essence of the visitor pattern. In: Proceedings of the 22Nd International Computer Software and Applications Conference (1998)
Rendel, T., Brachth�user, J.I., Ostermann, K.: From object algebras to attribute grammars. In: SIGPLAN Notices (2014)
Visser, J.: Visitor combination and traversal control. In: SIGPLAN Notices (2001)
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
Torgersen, M.: The expression problem revisited. In: Odersky, M. (ed.) ECOOP 2004. LNCS, vol. 3086, pp. 123–146. Springer, Heidelberg (2004)
Zhang, H., Chu, Z., Oliveira, B.C.D.S., Storm, T.V.D.: Scrap Your boilerplate with object algebras. In: SIGPLAN Notices (2015)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights 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)