Sunday, September 22, 2013

Translator – Determine Code Size

The output assign codes routine contained two loops, the first to assign codes to tokens without codes, and the second to assign program word index values and determine the encoded size of the tokens.  Since the token codes are now assigned within the translator routines, the first loop was left to just looking for unimplemented token types.  This now can be accomplished in the second loop by simply checking if the token does not have a valid code.

When this routine was being modified, I realized that this routine along with the output append and output insert routines should be members of the RPN List class and not the Translator class since they only deal with the RPN list and do not use any of the translator member variables (with one exception).  Therefore, these functions were moved to the RPN List class.  The append and insert routines remain in the translator class as output list access functions for the command translate routines, however, the translator routines were changed to access the output list functions directly.

The  output assign codes routine was renamed to the set code size routine since that is basically what it does besides setting program word indexes (related) and checking for token types not yet supported (needed only during development).  The reset code size and increment code size access functions were removed since the code size member variable can be access directly.  This routine now returns a boolean value (false meaning an unimplemented token was found, which is returned).  An argument for the reference to the table instance to access the flags for codes was also required.

[commit d0e39b01f2]

No comments:

Post a Comment

All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)