An object-oriented approach to language compositions for software language engineering
Introduction
Software Language Engineering (SLE) (Kleppe, 2008) is a young engineering discipline with the aim of establishing a systematic and rigorous approach to the development, use, and maintenance of computer languages, which comprises specification, modeling and programming languages. Although in this paper emphasis is given to grammar-based domain-specific languages (DSLs) (Hudak, 1996, van Deursen et al., 2000, Mernik et al., 2005, Fowler, 2010, Kosar et al., 2010, Mernik, 2013, Kolomvatsos et al., 2012), SLE is equally focused on metamodel-based DSLs (Gray et al., 2007, Sprinkle et al., 2009) and general-purpose languages (GPLs) (e.g., Java, Gosling et al., 1996). A special focus of SLE, which is also a topic of this paper, is that a formal description is used to design and implement a language (e.g., generating a compiler), as well as to generate various language-based tools (e.g., editor, debugger) (Henriques et al., 2005). Any language description, formal or informal, should be amenable for refinement and composition. Unfortunately, this is usually not the case, making DSLs harder to adopt to frequent changes (Mernik and Žumer, 2005). To be able to design and implement DSLs more easily, modular, extensible, and reusable language descriptions are needed. It is even possible for some of the descriptions to be inferred from DSL programs (Hrnčič et al., 2011, Hrnčič et al., 2012). A language engineer may want to include new language features incrementally as the computer language evolves. Moreover, a language engineer may like to build a computer language simply by reusing different language description modules (language components, language fragments), such as modules for expressions, declarations, as well as to reuse and extend previous language descriptions. Thus, language description composition is a high level goal that still needs much work in the area of SLE.
In the recent paper (Erdweg et al., 2012) it has been pointed out that language composition has not obtained enough attention, is still not well-understood, and associated terminology is confusing. All of these points suggest that research in this area is not yet mature. Language composability has been identified in Erdweg et al. (2012) not as a property of languages themselves, but as a property of language description (e.g., how language specifications, formal or informal, can be composed together). To enable language composition, a language description has to be reused as is; that is, any changes to a language description are not allowed, but language descriptions can be extended or additional glue code can be written. This is similar to the Open/Closed Principle in Object-Oriented Design (Meyer, 1997). The following types of language composition have been distinguished in Erdweg et al. (2012): language extension (which subsumes also language restriction), language unification, self-extension, and extension composition.
In the case of general software development, the use of object-oriented techniques and concepts (Abadi and Cardelli, 1996), such as encapsulation and inheritance, greatly improves incremental software development and reusability. Object-oriented techniques and concepts already have been integrated into language descriptions (Mernik et al., 2000, Hedin and Magnusson, 2003, Mernik and Žumer, 2005) to enable new features to be implemented. The main objective of this paper is to show that object-oriented techniques and concepts are powerful enough to implement all types of language compositions identified in Erdweg et al. (2012). For practical purposes, different types of language compositions are explained using a simple and easy to understand Robot DSL (Mernik and Žumer, 2005). In this case study, a compiler generator tool called LISA (Henriques et al., 2005, Mernik and Žumer, 2005) will be used. In addition to the Robot DSL, more complex examples can be found in Mernik and Žumer (2005) and Fister et al., 2012, Fister et al., 2013. The usefulness of object-oriented design/architecture/programming has been shown in many other engineering disciplines (e.g., Lejeune et al., 2012, Loenzo et al., 2010, Murthy et al., 2011). In this paper, the usefulness of object-oriented approach is shown as applied to SLE. As previously stated, in this paper the emphasis is on DSLs. Firstly, it is easier to show various language compositions on small DSLs rather than on GPLs, which are usually much larger than DSLs with respect to the size of syntax and semantic specifications (Črepinšek et al., 2010). Secondly, DSLs are an emerging popular area of research in the field of software engineering. For example, DSLs are one of the most important parts in Generative Programming (Czarnecki and Eisenecker, 2000), Product Lines (Clements, 2002), Software Factories (Greenfield and Short, 2004), and Model-Driven Engineering (Schmidt, 2006, Gray et al., 2007, Sprinkle et al., 2009). The common denominator of the aforementioned development methodologies is the involvement of the end-user in the development of software. DSLs provide end-users with the ability to program/model their solutions. Moreover, with the current achievements in DSL research, the vision of language-oriented software development (Ward, 1995, Dmitriev, 2004) is a step closer to realization. The idea of language-oriented software development is to first develop various DSLs and then use them together to develop an application. To achieve the vision of language-oriented software development, it is necessary to improve the ability to compose languages.
The paper is organized as follows: Section 2 briefly describes LISA – Language Implementation System using Attribute Grammars, which is used as a language description system for language composition. Various types of language compositions are explained on the simple Robot DSL, which is also introduced in this section. In Section 3, different types of language compositions are mentioned briefly and concrete examples are presented and discussed. Related work is described in Section 4, followed by the conclusions in Section 5.
Section snippets
LISA and Robot DSL
The challenge in formal language description is to support modularity and abstraction in a manner that allows incremental changes to be made as easily as possible. To achieve this goal, inheritance (Taivalsaari, 1996, Redondo and Ortin, 2013) can be very effective since it is a language mechanism that allows new definitions to be based on existing ones. A new specification can inherit the properties of its ancestors, and may introduce new properties that extend or modify the inherited
Types of language composition
The following types of language composition have been distinguished in Erdweg et al. (2012): language extension (which subsumes also language restriction), language unification, self-extension, and extension composition. In the following section, each type of language composition is described briefly and explained using a simple DSL.
Related work
A new and more suitable taxonomy for language composition has been proposed only recently in Erdweg et al. (2012), where the following types of language composition have been identified: language extension, language unification, self-extension and extension composition. Section 3 demonstrated how different language compositions can be realized using LISA (see Table 1). Moreover, it was also reported in Erdweg et al. (2012) that existing terminology is confusing. The rationale for such a claim
Conclusion
To achieve the vision of language-oriented software development (Ward, 1995, Dmitriev, 2004), there is a need for language descriptions, whether informal or formal, to be composed. Language composition is an active research area in the field of Software Language Engineering. To promote this research even further, new terminology and a taxonomy for language composition has been recently proposed in Erdweg et al. (2012). The following types of language compositions have been identified in Erdweg
Marjan Mernik received his M.Sc., and Ph.D. degrees in Computer Science from the University of Maribor in 1994 and 1998 respectively. He is currently a professor at the University of Maribor, Faculty of Electrical Engineering and Computer Science. He is also a visiting professor at the University of Alabama in Birmingham, Department of Computer and Information Sciences, and at the University of Novi Sad, Faculty of Technical Sciences. His research interests include programming languages,
References (86)
- et al.
Is my model right? Let me ask the expert
The Journal of Systems and Software
(2011) - et al.
Stratego/XT 0.17. A language and toolset for program transformation
Science of Computer Programming
(2008) - et al.
Preventing injection attacks with syntax embeddings
Science of Computer Programming
(2010) - et al.
TXL: a rapid prototyping system for programming language dialects
Computer Languages
(1991) - et al.
Incremental concrete syntax for embedded languages with support for separate compilation
Science of Computer Programming
(2013) - et al.
JastAdd: an aspect-oriented compiler construction system
Science of Computer Programming
(2003) - et al.
A memetic grammar inference algorithm for language learning
Applied Soft Computing
(2012) - et al.
Debugging applications created by a domain specific language: the IPAC case
The Journal of Systems and Software
(2012) - et al.
A preliminary study on various implementation approaches of domain-specific language
Information and Software Technology
(2008) - et al.
Object-oriented design to automate a high order non-linear solver based on asymptotic numerical method
Advances in Engineering Software
(2012)
An object-oriented architecture for sensorless cutting force feedback for CNC milling process monitoring and control
Advances in Engineering Software
Incremental programming language development
Computer Languages, Systems and Structures
Object-oriented programming paradigm for damage tolerant evaluation of engineering structural components
Advances in Engineering Software
Efficient support of dynamic inheritance for class- and prototype-based languages
The Journal of Systems and Software
Component-based LR parsing
Computer Languages, Systems and Structures
A Theory of Objects
Island grammar-based parsing using GLL and Tom
Compilers: Principles, Techniques, and Tools
Grammar Inheritance
AspectCOOL: an experiment in design and implementation of aspect-oriented language
ACM SIGPLAN Notices
Java Syntactic Extender (JSE)
ACM SIGPLAN Notices
Tom: piggybacking rewriting on java
Growing Languages with Metamorphic Syntax Macros
ACM SIGPLAN Notices
Disambiguation Filters for Scannerless Generalized LR Parsers
Concrete syntax for objects: domain-specific language embedding and assimilation without restrictions
Challenges and directions in formalizing the semantics of modeling languages
Computer Science and Information Systems
Extensible syntax with lexical scoping
A simple implementation of grammar libraries
Computer Science and Information Systems
A metaobject protocol for C++
ACM SIGPLAN Notices
L. Northrop Software Product Lines: Practices and Patterns
Generative Programming: Methods, Tools and Applications
On automata and language based grammar metrics
Computer Science and Information Systems
Domain-specific languages: an annotated bibliography
ACM SIGPLAN Notices
Language Oriented Programming: The Next Programming Paradigm
Techniques for metamodel composition
SugarJ: library-based syntactic language extensibility.
Language composition untangled
Implementation of EasyTime formal semantics using a LISA compiler generator
Computer Science and Information Systems
EasyTime++: a case study on incremental domain-specific language development
Information Technology and Control
Domain Specific Languages
The Java language specification
Domain-specific modeling
Software Factories: Assembling Applications with Patterns, Models, Frameworks, and Tools
Cited by (49)
Composition operators for modeling languages: A literature review
2023, Journal of Computer LanguagesOn the granularity of linguistic reuse
2023, Journal of Systems and SoftwareAutomatic compiler/interpreter generation from programs for Domain-Specific Languages: Code bloat problem and performance improvement
2022, Journal of Computer LanguagesInferring Absolutely Non-Circular Attribute Grammars with a Memetic Algorithm
2021, Applied Soft ComputingSystematic composition of independent language features
2019, Journal of Systems and SoftwareSoftware language engineering in the large: towards composing and deriving languages
2018, Computer Languages, Systems and Structures
Marjan Mernik received his M.Sc., and Ph.D. degrees in Computer Science from the University of Maribor in 1994 and 1998 respectively. He is currently a professor at the University of Maribor, Faculty of Electrical Engineering and Computer Science. He is also a visiting professor at the University of Alabama in Birmingham, Department of Computer and Information Sciences, and at the University of Novi Sad, Faculty of Technical Sciences. His research interests include programming languages, compilers, domain-specific (modeling) languages, grammar-based systems, grammatical inference, and evolutionary computations. He is a member of the IEEE, ACM and EAPLS.