Counter Stack Not Empty: No need to check mode; push open parentheses token on hold stack and push a 0 on the counter stack (which prevents commas).
Command: Return an “unexpected parentheses in command” error. Statements like “(A=B)” and “(A+B)” are not valid.
Equal: Set mode to Expression. This is the start of the expression after an equal (assignment). This will handle statements like “A=(B=3)” and “A=(B)=3” where the expression starts after the open parentheses.
Comma: Return an “unexpected parentheses in assignment list” error. Statements like “A,(B),C=4” are not valid.
Expression: Same as if counter stack is not empty (push token and 0).When processing a closing parentheses for an open parentheses (not an array or function), the reference flag of the last token added to the output list needs to be cleared. A pointer to this token is on top of the done stack. If this token is an operator like in the expression “(A+B)” then clearing the reference flag has no effect, but in statements like “A=(B)=3” or “A=Function((B),C)” the reference flag of B is cleared.
The counter stack is not empty check also needs to be made when processing operators before checking the mode. In other words, if the counter is not empty, then it is assumed that the Translator is within an expression. This will handle statements like “A(B+C)=D” and “A(B=C)=D” correctly. So this check is needed at both the equal operator section and the no special operator section. Looks like everything is working correctly, so almost ready to release...
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.)