Tuesday, February 1, 2011

Translator – Correcting More Token Leaks

There were a few more token leaks that needed to corrected, one with the first and last operand changes and rest with the PRINT command. Details of the rest of the token leaks found and corrected are after the continue. All tokens leaks have now been corrected, time to handle array assignments...

When processing the final operand for operators and internal functions, the setting of the first and last operands was handled for non-sub-string internal functions and operators. For non-reference sub-string functions, the sub-string function doesn't get pushed to the done stack, but the first operand on the done stack (the operand of the sub-string function) is set to the sub-string function and the last operand is set to the closing parentheses.

However, reference sub-string functions are pushed to the done stack, but the first and last operands were never set and so were left set to the last argument's first and last operands. The first operand should have been cleared (to be the sub-string function like other internal functions) and the last operand should have been set to the closing parentheses token passed in. Also, no operands should be attached to the sub-string function (it is already known to be a string variable).

In the print command handler, at the end of the statement, the print token is only added to the output to cause the cursor to be moved to the next line (the statement does not end with a semicolon, comma or print function, which keep the cursor on the same line). In this case, the print token was not used but it was not being deleted.

When processing the final operand for print functions (SPC and TAB), which don't get pushed to the done stack, the closing parentheses token of the function was not being deleted.

In the semicolon token handler, when the semicolon sub-code was set, the semicolon token was not being deleted.

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.)