Article Preview
TopIntroduction
Automatic code generation on the basis of rigorous system models and formal specifications is one of the central objectives of software engineering, which leads to the improvement of software development productivity, efficiency, and quality (McDermid, 1991; Michael & Butler, 1996; Wang, 2007). However, automatic code generation is an intricate and difficult endeavor in software engineering. Many efforts were reported on simplified system specifications and simple target languages (RAISE, 1995; Univan & Chris, 2000). It is a great challenge to design and implement a comprehensive code generator that covers the entire range of software modeling needs including real-time device drives and machine-level event/time/interrupt-driven mechanisms.
The process metaphor for software system modeling, specification, and implementation was initially proposed by Hoare and others (Hoare, 1978; Milner, 1980) that perceived a software system as the composition of a set of interacting processes.
Various algebraic approaches to describe the behaviors of communicating and concurrent systems were developed known as process algebra (Hoare, 1978, 1985; Milner, 1980), which provide a set of formal notations and rules for describing algebraic relations of software behaviors. A set of denotational mathematics was recently developed (Wang, 2008a) for rigorously modeling both architectures and behaviors of software systems. Denotational mathematics is a category of expressive mathematical structures that deal with high-level mathematical entities beyond numbers and sets, such as abstract objects, complex relations, perceptual information, abstract concepts, knowledge, intelligent behaviors, behavioral processes, and systems (Wang, 2009a). The paradigms of de-notational mathematics are such as concept algebra (Wang, 2008b), Real-Time Process Algebra (RTPA) (Wang, 2008c), and system algebra (Wang et al., 2008).
RTPA is a form of de-notational mathematics for formally modeling and describing architectures and behaviors of software systems (Wang, 2002, 2008c, 2008d). Based on the RTPA methodology and models, software code may be seamlessly generated as shown in Fig. 1. In the scheme of RTPA-based code generation, the RTPA architectural model for a system is used to generate the structural framework and global/local variables of classes or objects; while the RTPA behavioral model is then transferred into object methods in a target programming language.
Figure 1. Program code generation based on RTPA
This paper develops a methodology and a tool that facilitate automatic C++ and Java code generation based on formal system models specified and refined in RTPA. First, RTPA is briefly introduced as a denotational mathematical methodology for software architecture and behavior modeling and manipulations. Second, the RTPA-based software code generator (RTPA-CG) is described on its design strategies, structures, and support environments. Third, the implementation of RTPA-CG is presented with its lexer, parser, type checker, and run-time library, as well as their integration. Last, applications of RTPA-CG are reported with case studies and experimental results.