And speaking of QBasic, out of curiosity of how it handles invalid commas in function arguments for comparison to IBCP, QBasic detects the wrong number of arguments at the first comma that shouldn't be there (the “expected )” error occurs pointing to the comma) or the closing parentheses when there should be another argument (the “expected ,” error occurs pointer to the closing parentheses. IBCP doesn't catch the error until the closing parentheses (and points to the function name with the “wrong number of arguments” error). The QBasic behavior is better.
This behavior was not difficult to replicate. The count stack (that keeps track of operands, i.e. commas) was modified to hold a count stack item, which contains the current number of operands (commas) counter and a new expected number of arguments that is set if the token is an internal function. The comma token handler then checks if too many arguments have been entered if the expected number of arguments is set.
To make this work with internal functions that have multiple number of arguments (MID$, INSTR and ASC), the entries in the table needed to be rearranged where the code with the more number of arguments moved first, so that the number of expected operands was set high enough not the have an error reported before getting to the closing parentheses.
One more bug needs to be fixed, a statement like “Z=A+” reports the “BUG: expected operand on done stack” error. Bug errors are programming errors that should not occur. The statement “Z=(A+” does correctly report the “operand or closing parentheses expected” error. This appears to be the final bug...
Subscribe to:
Post Comments (Atom)
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.)