Sunday, August 25, 2013

New Translator – Code Reorganization

Now that the old translator routines have now been completely removed, it is time to reorganize the main translator source file to put the functions in a more logical top to bottom calling order. But first several of the routines were renamed:

translate2()          → translate()
processOperator2()    → processOperator2()
getInternalFunction() → processInternalFunction()
getParenToken()       → processParenToken()

The second two functions were renamed because these functions are support functions to the getOperand() function like the processCommand() function is a support function to the getCommands(). Also, these functions were made private since they will not be called from outside the translator class (from the command translate functions). Comments on the some of the functions were also reworded, corrected and cleaned up. This concludes the implementation of the new translator scheme.

Looking at some code statistics, about 1330 lines of code were added during the implementation of the new translator routines, but about 257 of these lines were due to the additional token leak and extra delete detection routines, so the new translator routines account for about a net of 1073 lines. After the old translator routines were removed, the code was about 2509 lines less. So the new translator is about 43% the size of the old translator. The simpler design will be easier to maintain and utilize, so the change was worthwhile.