Sunday, September 21, 2014

RPN List – Error Messages

If a line being translated contains an error, the error column and length members of the RPN list were set to the error.  Previously the translator also set the error message member to the error message.  Continuing with the change from error messages to error status codes, this error message was changed to an error status code.  The translator was modified to set the error status instead of the error message.  The receivers of an RPN list, the program model and tester classes, were modified to take the error status code from the RPN list and get the error message for the status code.

[branch err-msgs commit c9bad9f36b]

Parser – Error Messages

Previously the parser returned detected parse errors by setting the token type to an error and setting the string member (normally used to hold the string of the token) to the error message.  Since these messages need to be translated, the parser required the Qt translate functions.  The parser was modified to use status error codes instead of messages.

The token does not have a status member, and only the parser would need to use it for errors.  Instead, an error status member was added to the parser class with an access function.  If token has an error, the caller obtains the status error code by calling the access function.  The set error access functions of the token class were also moved to the parser class, since only the parser class uses them.  These were modified to set the parser error status code instead of setting the token string to an error message.

The parser error messages were changed to status codes and appropriate enumerators were added to the status enumeration, and the messages were added to the switch statement in the static token error message function.  The result is that the parser class is no longer dependent on the Qt translate functions.

The two users of the parser class, the translator and the tester classes, now retrieve the error status from the parser when the token has an error and this error status is used to get the error message.  Previously they obtained the error message from the token where the parser put it.

[branch err-msgs commit 84c52f0e9b]