Programming Language Translation Jamie McAtamney
Introduction Purpose: to write a fully functional translator C to Java Hasn’t been done before Java some advantages over C: Easier to write Java (idiot-proof) More portable Scope: as wide as possible Currently have all the “basics” Need to do struct translation, pointers, graphics
Background Similar research Jazillian pay-per-program translation company Terekhov & Verhoef’s paper on translation difficulties Lili Qiu's paper on procedural vs. object-oriented languages
Methodology Approach Everything is modular Have modules for different translations Have “translate()” methods to coordinate everything Have separate programs to handle appearance of code Aspects of C closest to Java translated first Saved memory manipulation for last
Methodology Translation algorithm Formatting Tokenization Remove programming idiosyncrasies Tokenization Keywords and punctuation Keyword search-replace Ex: char* → String Context-sensitive search Ex: printf(“\n”); → System.out.println();
Methodology Finished Timeline In Progress Coming “Soon” Coming Maybe Primitive types Arrays Method headers Input/output Preprocessor directives Two-pass translator Timeline In Progress Package methods Coming “Soon” Structs → Classes Pointers Graphics Coming Maybe Computer-to-computer communication
Methodology Testing & Analysis Testing old C programs Have a few “fake” programs to test particular modules Script to do testing Added another translator to traverse Java program a second time
Methodology Problems: Can't move “backwards” for writing to Java file Solved with two-pass translator Some C methods “overloaded” in Java Ex: PrintStream append() and print()
Progress Results Thus Far Program is error-free All implemented areas fully translated Translator outputs compilable and runnable program
Progress Analysis Where to go from here Ahead of schedule Didn't expect to get to structs and pointers before end of 3rd quarter Didn't expect output of compilable and runnable program until 3rd quarter Graphics will be much easier than I originally thought Where to go from here Will try Java to C if I finish by beginning of 4th quarter