When a program line is sent from the edit box to the program model, it will be translated to an RPN list. This RPN list will then be encoded into program code and stored. For now, the RPN list will be stored. However, a program line may contain an error. Program line errors will need to be displayed in the edit box and temporarily in the program view widget.
Previously, the translator held the error token (that points to the error on the line) and the error message. If there was a translation error, the RPN output list was cleared and the RPN list instance was deleted. The caller would then obtain the error token and message instead of the retrieving the RPN list. Since a program consists of many lines, several lines could contain errors. There errors need to be kept with the program line and not in the translator instance (which only holds one error; the most recent).
Since the program model will be storing the RPN lists of the program lines, the error token and error message was moved from the Translator class to the RPN List class along with their accessor functions. The RPN List instance is no longer deleted upon an error since it will be holding the error token and message, though the actual list is still cleared.
The translator's functions set input (given an input line, which was translated, and returned translation status) and output (returned the RPN output list upon successful translation) were replaced with a new translate function. This function is essentially the set input function except it now returns the RPN output list (which may contain an error). For safety, this function resets the RPN list output member pointer before returning - the caller takes possession of the RPN list instance. A new has error function was added to the RPN List used by the caller to check the translation status.
[commit 27cd073e43]
Sunday, March 31, 2013
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.)