AUTOMATIC ALGORITHM SPECIFICATION TO SOURCE CODE TRANSLATION SUVAM MUKHERJEE Department of Computer Science and Engineering, Institute of Engineering and Management, Y-12, Block EP, Sector V Salt Lake, Kolkata 700091, India. TAMAL CHAKRABARTI Assistant Professor Department of Computer Science and Engineering, Institute of Engineering and Management, Y-12, Block EP, Sector V Salt Lake, Kolkata 700091, India. Abstract Computers have become all-pervasive, and are being used in a variety of areas like Microbiology, Astronomy, Social Sciences and many others. In almost all these areas, algorithmic solutions to problems are common. However, most programming languages have certain idiosyncrasies. This is why people who don’t have a good background in computer programming have difficulty in writing good, efficient programs. Moreover, there are many programming languages which allow coding in a variety of paradigms. Though it is easy for someone trained in Computer Science to convert a program from one language to another, it is less so for people in other fields. In this paper, we describe a translation program that can create a piece of executable code, given the code’s algorithmic specification. This program allows the user to specify his/her code using an easy-to-understand, simple-to-write and more or less immutable pseudo code specification. The program will then check the pseudo code for errors, and convert it to a specified language (be it C, Java, or any other language). The program may easily be extended to accommodate different languages. Our program allows the user to focus on just the algorithm, and not on issues related to implementation. Keywords: Pseudo code implementation; Code Generation; Regular Expressions; Pattern Matching; Hash Tables; XML to C, Java; 1. Introduction Of late, Algorithms have been applied in diverse areas like Microbiology, Astronomy, Social Sciences and many others. Today, more and more problems are lending themselves to algorithmic solutions. In Numerical Methods, we have algorithms for solving equations by iteration [7], solving simultaneous algebraic equations [7], doing interpolation [1], performing differentiation and integration [1] and so forth. In Graph Theory, we have algorithms like building minimum spanning trees using Kruskal’s algorithm [4]. Graphs are used in a variety of web based applications like Facebook and MySpace, and many of the operations in these applications are nothing but implementations of graph theoretic algorithms. Many algorithms are being devised to tackle biological problems like aligning DNA sequences [2]. Algorithms, however, need to be implemented; and this is where a problem lies. People who don’t have a good background in computer programming have difficulty in writing good, efficient programs. Moreover, there are many programming languages which allow coding in a variety of paradigms. So it is not easy for someone not trained in Computer Science to convert a program from one language to another. This paper describes an innovative translation process that can create a piece of executable code, given the code’s algorithmic specification. The specification of the algorithm is done in XML. In the specification, the user need not bother about any implementation details. This allows users to write their algorithms without having to write the computer programs that would implement the algorithms. Although the imperative programming language ALGOL became one of the standard ways in which to describe algorithms, our formal framework for writing pseudo codes is much more intuitive and provides a higher level of abstraction. This has been illustrated later in the paper by taking a simple example. Moreover, there have been translation programs designed for ALGOL, like the MARST [5], Whetstone KDF9 ALGOL Translator [8] and the ALGOL 60 Translator for X1 [3]. However, none of these attempt to allow translation from the pseudo code specification to any other language. This is what our translation process achieves. Our implementation of the translator, called ALGOSmart, can presently translate pseudo code specification written in XML into C and Suvam Mukherjee et al. / Indian Journal of Computer Science and Engineering (IJCSE) ISSN : 0976-5166 Vol. 2 No. 2 Apr-May 2011 146