Saturday, September 21, 2013

Translator – Assigning Variable Codes

In the get operand routine, the cases that fell through to the next case were replaced with the actual code needed each the case (in some cases, checks were performed that had already been done or were not necessary).  For now, the identifier with no parentheses token type is assumed to be a variable.  Eventually, the function dictionary will be checked to see if the identifier is a function before assuming it is a variable.  The token is assigned a variable code, or a variable reference code if a reference was requested.

Previously when a reference was requested, the reference flag of the token was set.  This is no longer necessary since nothing down stream needs to check the reference flag (except the debug output code).  The reference flag was added to the variable reference code table entries so that the debug output code knows to output the reference indicator for this token type.

To validate that identifiers with no parentheses are being assigned a code by the end of translation, the token text routine was modified to output a question mark in front of a these tokens if no code has been assigned.  When the with index flag argument is set (during encoder test output), these tokens output the code and operand (the string of the token) instead of just the string since these tokens will be encoded as two program words (the variable instruction and its index).  Also, variable token codes are no longer assigned a code in the output assign codes routine called at the end of translation.

To make the variable output work correctly for both translator and encoder test output, the token type in the table entries for the six variable codes were changed from the internal function with no parentheses type to the no parentheses type.  This will make these no these tokens go through the no parentheses token type case in the token text routine.  This is inconsequential since the token type disappears once the tokens are encoded.

[commit db6795346f] [commit a1f413b2e1]

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