Saturday, December 27, 2014

Table – More Alternate Codes

Since it will be ideal to reduce the number of unique code type enumerators needed, several uses of the current code enumerators was eliminated.  Most of these were accomplished by assigning the codes needed as alternate codes to commands that need them in the Alternate Info initializer list and obtaining the codes using the alternate map:
AssignLet (alternate 0)
Input BeginInput (alternate 0)
Input Begin StringInput Prompt (alternate 0)
Input AssignInput (alternate 1)
Input AssignInput Prompt (alternate 1)
Print DoublePrint (alternate 0)
PrintSemicolon (alternate 0)
Variable ReferenceVariable (alternate 1)
Since the command code is available in the translate function needing them (LET, INPUT, or PRINT) , it can be used to find the alternate code needed.  The Print code is assigned as an alternate to the Semicolon code for recreation (see below).  For a PRINT statement ending with a semicolon, no PRINT command code is stored in the program code so the semicolon recreate needs to also recreate the PRINT keyword.

The Input code enumerator was used in the common INPUT translate routine to determine if the routine was called for the INPUT or INPUT PROMPT command.  This test was changed to checking if the second name of the command token code is empty, which is empty for INPUT and not empty for INPUT PROMPT.

The Constant String code enumerator was used in the token equality operator function to determine if token string comparison should be case sensitive (for REM, REM operator and string constants) or case insensitive (variables, arrays, etc.).  This test was changed to checking if the token type is a constant and the data type is a string.

The Print code enumerator was used in the print recreate function instead of using the name from the table entry.  This was done because the print semicolon recreate function called this function after appending a semicolon.  If the table entry was used, a semicolon would have been output for the command instead of PRINT.  The function was changed to create a temporary RPN item with a temporary token with the Print code, but not the code enumerator using the alternate code.  This set of statements is convoluted, but will be far simpler once the new table model is implemented.

Unrelated to removing the use of code enumerators, it was noticed that the print comma recreate and print semicolon recreate functions were using the strings for a comma and semicolon directly but technically should have been using the name from the table entry.  Both of these were changed to use the table entry name.

[branch table commit b6850c7c7f]

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