Friday, December 5, 2014

Pre-Table – Standard String Members

The string members of the table entries were changed to standard strings including the return value of the their access functions.  This includes these members and their uses:
name - the main keyword name of the code; blank for an internal code
name2 - the second keyword name of a two-word command; blank for a one-word commands; also used as the debug name for other codes like operators and internal functions
option - the debug name for codes that support the option sub-code (to reduce the number of sub-codes, this single sub-code has a different meanings for different codes, for example Question for the input begin string code, LET for assignment codes, and Keep for the intermediate sub-string assignment codes)
Besides the access functions for these members, there is also a debug name access function that returns the debug name for a code.  The purpose of this name is to represent each code with a unique name.  For example, there are several add codes depending on the data types of the operands, which includes the +, +%1, +%2, +%, and +$ strings.  For all but the primary add code (taking double operands), these strings were put into the name2 member.  When the name2 was empty, the name member would be returned for the debug name.

This mechanism was modified where the name2 member now contains only the second part of the debug name.  So, for the add operators, all contain + for their name member, and the name2 members contain the "", %1, %2, %, and $ strings.  The debug name function now always combines these two strings.  This also works for internal codes that have a blank name member.

However, the resulting debug names for internal functions are now a little different.  For example, the ASC, MID$, and STR$ functions previously had debug names (first line below where the 2 and 3 represent the number of arguments and the % represents an integer argument) become (where the name2 members are shortened to "", 2, 3, %):
ASC( ASC2( MID2$( MID3$( STR$( STR%$(
ASC( ASC(2 MID$(2 MID$(3 STR$( STR$(%
For the non-sub-string assignments, their name member is set to = and their name2 member contain the name of their code (Assign, Assign%, Assign$, etc.).  The = is necessary so that the assignment statements are recreated correctly.  The result of combining these two names are the strings =Assign, =Assign%, =Assign$ etc.  This was left as is instead of trying to code around it since this only affects test output.

Obviously the change in debug names affected the expected outputs of many of the tests.  These were updated accordingly.  Since standard strings cannot be initialized to a null pointer, all blank strings in the table were changed to the "" empty string.

[branch table commit 4f13d11a05]