Home

Awesome

J2Ada

Alire

Introduction

J2Ada translates a Java valid source code in Ada source code. In this first version, a large part of Java syntax is translated. But, up to now, both specification and body parts of the generated Ada code become valid with few manual modifcations.

Creation of translation program

Source codes of J2Ada program

(From J2Ada on GitHub).

Creation of the sequencer of Java interpretation

The sequencer unit in Ada is already created: javaseq.adb and javaseq.ads. If necessary the sequencer may be modified in the file javaseq.auto containing Java syntax and regenerated with the Automate sequencer compiler.

Download the sequencer compiler from Automate on GiHub.

Compile the program genauto then use it to generate the Ada units:

$ gnatmake genauto
$ ./genauto <javaseq.in

Compilation of J2Ada translator

$ gnatmake j2ada

Usage

The programs have been compiled and tested with GNAT GPL 2008 on Mac OS X 10.4. Translation example of essai.java in essai.adb and essai.ads:

$ ./j2ada
Entrer les informations suivantes :

Nom du fichier source : essai.java
Lecture de essai.java ...
Temps passé :  108 millisecondes.
Nom de l'unité Ada : (essai.ads) : 
Nom de l'unité Ada : (essai.adb) : 
$ gnatmake -gnatc essai.adb
gcc -c -gnatc essai.adb
essai.adb:32:01: declarations must come before "begin"
essai.adb:55:01: declarations must come before "begin"
essai.adb:93:01: declarations must come before "begin"
essai.adb:96:04: loop or block statement must follow label
essai.adb:98:04: loop or block statement must follow label
essai.adb:100:04: loop or block statement must follow label
essai.adb:105:04: loop or block statement must follow label
essai.adb:107:04: loop or block statement must follow label
gnatmake: "essai.adb" compilation error

The residual first errors are inherent of object declarations mixed with Java Code. A comment -- Help J2Ada : put it before begin has been added to do the right modification. The source code essai.ads uses Java libraries provided from those of JGNAT (see also on Blady):

The display at each stage of the translation is activated by positioning at True the Debug constant in j2ada.adb.

Copyright and license of J2Ada source codes

All files are provided under terms of:

(c) Pascal Pignard 2008-2010 (http://blady.pagesperso-orange.fr)
CeCILL V2 (http://www.cecill.info)

See also attachments: Licence_CeCILL_V2-en.txt and Licence_CeCILL_V2-fr.txt.

Using Alire

In your working folder, do:

% alr get j2ada
% cd j2ada_*
% alr run

History

Pascal Pignard, August-December 2008, April 2010.