Thursday, January 15, 2015

Token – Set Table Entry

The code member of the token class will be replaced a table entry pointer.  This means that the access functions for the code need to be changed.  It is easy to change a table entry pointer to a code or a code to a table entry pointer since the code is currently just an index of the table entry.  There was already a table entry access function, which for now calls the static table entry access function that just returns the pointer to the entry in the table entry array.

Once the code member is replaced, the table access function will simply return the table entry pointer member.  The set code access function was replaced with a matching set table entry access function and callers were updated accordingly.  The name of the getter should be named table entry but use of this function is going to be largely replaced with additional pass-through table access functions in the token class (like already exists with the type, data type, has flag, precedence and last operand functions).  This will wait until the table entry pointer member is added.

There was also the token constructor that took a code enumerator.  Uses of this constructor was replaced with the token constructor taking a table entry pointer (where default values were added for the column and length arguments).  Most calls to the former constructor had a table entry pointer and was obtaining the code from it, so the call to the code table access function was simply removed from these.

The program word class was also using the code enumeration type for setting codes and returning codes.  This required C-style type casts (though C++ static casts could have been used) to change to and from unsigned 16-bit integers.  The code and token types will be replaced with a code type and a code index.  Code indexes will only be used in the program code.  The code enumeration in the program word access functions was changed to unsigned integers and their callers updated accordingly.

[branch table commit 0dc88434d2]

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