Programming Language Translation Jamie McAtamney
Introduction Purpose: to write a fully functional translator C to Java Hasn’t been done before Java has some advantages over C Scope: as wide as possible All the “basics” Will attempt to translate modules Might not get to graphics
Background Lack of similar research Jazillian pay-per-program translation company Terekhov & Verhoef’s article on translation difficulties Sources of inspiration
Methodology Approach Read up on differences between C and Java Make everything modular Add modules for different translations Have “translate()” methods to coordinate everything Cover most common aspects first, not just simplest
Methodology Translation algorithm Tokenization Keyword search-replace Keywords and punctuation Keyword search-replace Ex: char* → String Context-sensitive search Ex: printf(“\n”); → System.out.println();
Methodology Timeline Currently on tokenization Problems writing in C Step 1: Whole-line translation Step 2: Primitive types Step 3: Input/output Step 4: Structs → Classes Step 5: Modules Step 6: ???
Methodology Testing & Analysis Reading in old C programs More structure than functionality testing Mostly debugging so far
Methodology Problems: C tokenizer didn’t work Translator moved C → Java Limited test base Few basic structures Not always direct analogs
Progress Preliminary Results Program works Full-line translation works Search-replace will work; not yet implemented Still working on it at this point
Progress Analysis Too early to draw conclusions No visuals No “degrees” of success No major changes in initial plan/hypothesis No great new insights/ideas yet Everything’s on track