Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

CHAPTER 9. IMPLEMENTATION OF THE TRANSFORMER 9.2 Exploiting the RSL2Java Tool The idea behind basing the implementation of the transformer on the RSL2Java tool is to be able to reuse some of the more or less tedious work done in [Hja04] in order to focus on the more interesting parts of the transformer. The way to exploit the RSL2Java tool is described in the following using tombstone diagrams as described in [WB00]. First an RSL specification of the transformation from an RSL AST of an applicative specification, named RSLA AST, into an RSL AST of an imperative RSL specification, named RSLI AST, is written within RSL1. Then this specification is translated into Java using the RSL2Java tool, see Figure 9.1. The resulting Java program is combined with an extended version of the RSL2Java tool front end and a revised version of the RSL AST to RSL unparser provided by the RSL2Java tool, Figure 9.2. The result is a Java program, which can do the desired transformation from applicative RSL specifications into imperative RSL specifications, see Figure 9.3 on the next page. RSL A transformer specification RSL A AST RSL I AST RSL 1 RSL 1 Java RSL2Java tool RSL AST transformer RSL A AST RSL I AST Java Java Figure 9.1: Translating the specification of the transformer extended front end RSL AST transformer new back end RSL AST RSL AST RSL AST RSL AST A A I I Java Java Java Figure 9.2: Combining the 3 parts 98 RSL I

RSL A transformer Java 9.3. DEVELOPMENT PROCESS RSL I Figure 9.3: The resulting transformer 9.3 Development Process Besides having to write the RSL specification of the transformation, some changes must be applied to the RSL2Java tool, since it only works for RSL1. The transformer has to be able to translate a different subset RSLA of RSL into yet another RSL subset RSLI. The relationships between the three subsets are illustrated in Figure 9.4. RSL I RSL A RSL 1 Figure 9.4: The different subsets of RSL In the following I will describe the different steps in the process of developing the transformer by changing the RSL2Java tool. 9.3.1 Front End The front end, which is developed using the ANTLR tool, [Par], must be extended and in some cases altered in order to be able to parse RSLA. This means extending and altering the grammar file rsltorslast.g from which the lexer and parser are generated and then generate the actual lexer and parser. 99

CHAPTER 9. IMPLEMENTATION OF THE TRANSFORMER<br />

9.2 Exploiting the RSL2Java Tool<br />

The idea behind basing the implementation <strong>of</strong> the transformer on the RSL2Java<br />

tool is to be able to reuse some <strong>of</strong> the more or less tedious work done in<br />

[Hja04] in order to focus on the more interesting parts <strong>of</strong> the transformer.<br />

The way to exploit the RSL2Java tool is described in the following using<br />

tombstone diagrams as described in [WB00].<br />

First an RSL specification <strong>of</strong> the transformation from an RSL AST <strong>of</strong><br />

an applicative specification, named RSLA AST, <strong>into</strong> an RSL AST <strong>of</strong> an<br />

imperative RSL specification, named RSLI AST, is written within RSL1.<br />

Then this specification is translated <strong>into</strong> Java using the RSL2Java tool, see<br />

Figure 9.1. The resulting Java program is combined with an extended version<br />

<strong>of</strong> the RSL2Java tool front end and a revised version <strong>of</strong> the RSL AST to RSL<br />

unparser provided by the RSL2Java tool, Figure 9.2. The result is a Java<br />

program, which can do the desired transformation from applicative RSL<br />

specifications <strong>into</strong> imperative RSL specifications, see Figure 9.3 on the next<br />

page.<br />

RSL A<br />

transformer specification<br />

RSL A AST RSL I AST<br />

RSL 1<br />

RSL 1<br />

Java<br />

RSL2Java<br />

tool<br />

RSL AST transformer<br />

RSL A AST RSL I AST<br />

Java<br />

Java<br />

Figure 9.1: Translating the specification <strong>of</strong> the transformer<br />

extended front end RSL AST transformer new back end<br />

RSL AST RSL AST RSL AST RSL AST<br />

A A I I<br />

Java Java Java<br />

Figure 9.2: Combining the 3 parts<br />

98<br />

RSL I

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!