Z$ = A$(1) + B$(2) > C$(3)The range of tokens would be A$( to C$( and reporting only up to C$( would not be correct since the 3 and ) tokens should be included. Therefore the closing parentheses of an array or function should be assigned the last token for an array or function token. This implies that closing parentheses tokens cannot not be immediately deleted.
When the array or function token is popped from the done stack, if the last token is a closing parentheses, then it will be deleted, unless it is being assigned as the last operand to an operator token as would happen in the statement above, the closing parentheses to C$( would be assigned to the >$ token as its last token. When the error gets reported, the range would be from the A$( token and the final ) token of the C$(.
There is no issue with regular parentheses expression as these are valid in any expression, therefore, if the statement above included parentheses around the expression, the error would be reported as (in other words, the parentheses are valid, but not the expression inside):
Z$ = (A$(1) + B$(2) > C$(3))This attachment of closing parentheses to tokens will take place in the closing parentheses token handler and will only apply to arrays and functions, not simple parentheses expressions. Also worth noting is that tokens (arrays and functions) will only have a last token assigned, the first token will be blank. In this case the token itself will be considered the first token. Finally, sub-string functions add another wrinkle to this scheme...
^^^^^^^^^^^^^^^^^^^^^-- expected string expression
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.)