Saturday, November 9, 2013

Translator – Arrays and Functions

A problem with recreating arrays and functions (user and define) is that the translator was not setting a code in these tokens.  Preliminary table entries were added for the codes needed.  These codes include an array, a define function with no parentheses, a define function with parentheses and a function.  There will eventually be codes for each data type, but these four codes are sufficient for now.

In the get operand routine, for the define function with and with no parentheses token types, the appropriate token code is assigned.  Since there is only a single code for each of these, the data type of the token is preserved because the table set token routine sets the data type of the token to the one in the table entry for the code.

The process parentheses token routine was modified to set the code of the token to the array code or the function code if the identifier starts with an 'F' character.  This routine also processes define functions with parentheses tokens, so the code is not set for these tokens.  Later in the routine when the RPN item is created, the attached count is no longer set to zero for array tokens.

The attached count of the RPN item can no longer be used to detect if there are attached tokens.  The attached array pointer will instead be used for this detection by checking if the pointer is set to null.  The RPN item text routine was updated to use the attached array pointer to detect attached tokens instead of the attached count.  This routine was also changed to use member variables directly instead of using the access functions.

[commit e1919952fa]

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