The Translator class has a single purpose, to task a BASIC input string and create an RPN list representation of the BASIC code. This is similar to the Parser, Tester, and Recreator classes, which were already changed to be function operator classes. This started with renaming the translate function to operator().
Like the recreator where a temporary instance is used, the translator can be used in the same way except that the input string is passed to the constructor so that it can be used to instance the parser (which lives throughout the translation). The parser no longer needs to be instanced at the beginning and reset before returning in the function operator function. Since only a temporary instance is needed to translate, the translator member pointers in the tester and program model classes were removed.
The clean up function was called when the translator returned an error, which deleted the hold and done stack items, cleared the RPN output list and reset the pending parentheses token pointer. Now at the end of a translation, including when an error is detected, the temporary translator instance goes out of scope, all all these actions occur automatically except for the clearing of the output list (since it is moved to the caller upon return). This clean up function was removed. For an error, the output list is cleared.
[branch misc-cpp-stl commit b597b5b0a7]
Sunday, November 16, 2014
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.)