Saturday, November 22, 2014

Translator Exceptions – Operands

The get operand function used to get an operand was modified to throw errors.  The command routines either returned an error or a Done status, so once they were modified to throw errors, there was no need to return anything.  In addition to errors, the get operand function returned a Good status representing successfully getting an operand or a Done status representing  no operand token (an operator or command).

The return value of the get operand function was changed to a boolean where true represents successfully getting an operand and false representing no operand.  When a reference operand is requested this function will not return a false status, it will just throw an error.  So for the process internal function, LET translate, and INPUT translate routines, it is not necessary to test the return value since these only request reference operands.

There were three locations in the get operand function where errors were returned that popped the token on top of the hold stack before returning.  This was intended to prevent memory leaks.  This wasn't necessary since the translator cleans up the stack when the translator goes out of scope, so these pop calls were removed.

One of the errors for define function identifiers with parentheses tokens added the length of the token to the column to point the error to the parentheses of the token.  The token class add length to column access function was used for this.  Instead of using this access function (the only caller), the token length is added to the column when the token error instance is created and thrown.  This access function was removed.

[branch misc-cpp-stl commit 640255514d]

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.)