Elsevier

Journal of Systems and Software

Volume 86, Issue 9, September 2013, Pages 2451-2464
Journal of Systems and Software

An object-oriented approach to language compositions for software language engineering

https://doi.org/10.1016/j.jss.2013.04.087Get rights and content

Highlights

  • Language composition has not obtained enough attention, is still not well-understood, and associated terminology is confusing.

  • OO techniques and concepts are powerful enough to implement all types of language compositions.

  • Several small examples of different types of language composition are shown using easy to understand DSLs.

Abstract

In this paper, it is shown that inheritance, a core concept from object-oriented programming, is a possible solution for realizing composition of computer languages. Language composability is a property of language descriptions, which can be further classified into informal (language syntax and semantics are hard-coded in compiler/interpreter) and formal language descriptions (syntax and semantics are formally specified with one of several formal methods for language definition). However, language composition is much easier to achieve with declarative formal language descriptions into which the notion of inheritance is introduced. Multiple attribute grammar inheritance, as implemented in the language implementation system LISA, can assist in realizing all of the different types of language compositions identified in Erdweg et al. (2012). Different examples are given throughout the paper using an easy to understand domain-specific language that describes simple robot movement.

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)

  • R.A.G. Loenzo et al.

    An object-oriented architecture for sensorless cutting force feedback for CNC milling process monitoring and control

    Advances in Engineering Software

    (2010)
  • M. Mernik et al.

    Incremental programming language development

    Computer Languages, Systems and Structures

    (2005)
  • A.R.C. Murthy et al.

    Object-oriented programming paradigm for damage tolerant evaluation of engineering structural components

    Advances in Engineering Software

    (2011)
  • J.M. Redondo et al.

    Efficient support of dynamic inheritance for class- and prototype-based languages

    The Journal of Systems and Software

    (2013)
  • X. Wu et al.

    Component-based LR parsing

    Computer Languages, Systems and Structures

    (2010)
  • M. Abadi et al.

    A Theory of Objects

    (1996)
  • A. Afroozeh et al.

    Island grammar-based parsing using GLL and Tom

  • A.V. Aho et al.

    Compilers: Principles, Techniques, and Tools

    (2007)
  • M. Aksit et al.

    Grammar Inheritance

    (1991)
  • E. Avdičaušević et al.

    AspectCOOL: an experiment in design and implementation of aspect-oriented language

    ACM SIGPLAN Notices

    (2001)
  • J. Bachrach et al.

    Java Syntactic Extender (JSE)

    ACM SIGPLAN Notices

    (2001)
  • E. Balland et al.

    Tom: piggybacking rewriting on java

  • C. Brabrand et al.

    Growing Languages with Metamorphic Syntax Macros

    ACM SIGPLAN Notices

    (2002)
  • M.G.J. van den Brand et al.

    Disambiguation Filters for Scannerless Generalized LR Parsers

  • M. Bravenboer et al.

    Concrete syntax for objects: domain-specific language embedding and assimilation without restrictions

  • B.R. Bryant et al.

    Challenges and directions in formalizing the semantics of modeling languages

    Computer Science and Information Systems

    (2011)
  • L. Cardelli et al.

    Extensible syntax with lexical scoping

    (1994)
  • J. Cervelle et al.

    A simple implementation of grammar libraries

    Computer Science and Information Systems

    (2008)
  • S. Chiba

    A metaobject protocol for C++

    ACM SIGPLAN Notices

    (1995)
  • P. Clements

    L. Northrop Software Product Lines: Practices and Patterns

    (2002)
  • K. Czarnecki et al.

    Generative Programming: Methods, Tools and Applications

    (2000)
  • M. Črepinšek et al.

    On automata and language based grammar metrics

    Computer Science and Information Systems

    (2010)
  • A. van Deursen et al.

    Domain-specific languages: an annotated bibliography

    ACM SIGPLAN Notices

    (2000)
  • S. Dmitriev

    Language Oriented Programming: The Next Programming Paradigm

    (2004)
  • M. Emerson et al.

    Techniques for metamodel composition

  • S. Erdweg et al.

    SugarJ: library-based syntactic language extensibility.

  • S. Erdweg et al.

    Language composition untangled

  • I. Fister et al.

    Implementation of EasyTime formal semantics using a LISA compiler generator

    Computer Science and Information Systems

    (2012)
  • I. Fister et al.

    EasyTime++: a case study on incremental domain-specific language development

    Information Technology and Control

    (2013)
  • M. Fowler

    Domain Specific Languages

    (2010)
  • J. Gosling et al.

    The Java language specification

    (1996)
  • J. Gray et al.

    Domain-specific modeling

  • J. Greenfield et al.

    Software Factories: Assembling Applications with Patterns, Models, Frameworks, and Tools

    (2004)
  • Cited by (49)

    • On the granularity of linguistic reuse

      2023, Journal of Systems and Software
    • Systematic composition of independent language features

      2019, Journal of Systems and Software
    View all citing articles on Scopus

    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.

    View full text