Saturday, August 24, 2013

Old Translator Removal – Process Final Operand

For the old translator, the process final operand routine handled the processing of the final operand of operators, internal functions, tokens with parentheses (arrays or functions) and internal codes (for example assign type, print type, and input assign type).  The handling of internal functions and tokens with parentheses are now handled elsewhere by their respective get routines.  So for the new translator, this routine is only called for operators and internal codes.

The code for handling tokens with parentheses, which included the attaching of the operands from the done stack, was removed.  It turned out that is was no longer necessary to check for a reference token, which was used to determine if the item to be added to the RPN output list should also be pushed to the done stack.  Since no internal codes need to be pushed to the done stack, it now only pushes operator tokens to the done stack.  The PRINT translate routine was modified to only drop the done stack top item for the print only functions (TAB and SPC).

The process final operand routine was simplified after removing the unused code.  The process done stack top routine (formally the find code routine, see post from August 17) is stilled called, which returns the first and last operands of the item was on the done stack top (the item is popped before returning).  Afterward, the first operand is deleted if it is an open parentheses.  For an operator token, the first operand is set to the operator token for a unary operator or the first operand of a binary operator, and the last operand is set from last operand of the item that was on done stack top.  For an internal code, the last operand from the done stack top item is deleted if it is a closing parentheses.

[commit ca3b513ac9]

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