摘要 |
A C-to-Java programming language translator that requires no human intervention, translates literally to preserve both procedure and function in the resulting code, and is independent of the purpose of the source code. The program reads in text from a C file, tokenizes each line for C keywords and punctuation, translates most keywords and expressions, and outputs the result to a Java file. The program is modular so that it is capable of running on multiple operating systems and hardware. The invention implements several methods of translation, including whole-line translation, search/replace translation, context-sensitive translation, idiomatic translation, and second-pass translation. The second-pass translation handles those instances when correct translation of a particular line depends on information in another line. The program of the invention translates a struct into a Java inner class, complete with multiple constructors and private variables, and it translates pointers into their reference equivalents. |