In order to eliminate the auto-generated code enumeration, unnecessary code enumerators will be removed. Table bracketing entries were used to break the table into search groups. There were three of these groups, which included plain words (including two-word commands), words with parentheses, and symbols.
When the table was initialized, the start and end of each group was determined and stored in the range member indexed by the search type enumerator. This enumeration was not changed to a C++11 enumeration class because its enumerators were used as indexes. When a caller wanted to search the table for a name, it passed one of these search types and the search looked only within that range (by sequentially iterating over the entries).
The new name lookup mechanism uses a standard unordered map where the key will be the name of the code and value will be a pointer to a table entry. For two-word codes, the two words are combined with a space separator between words. The key hash and key equal function operators defined in the dictionary class were moved to the utility header file and renamed to case optional. These are used for this map, defined as a static member, so that searches are case insensitive.
The search functions were renamed find to mirror the standard library names and were made static. The primary find function calls the map find function with the string argument. If the string was found then the code index is calculated by subtracting the base table entry pointer from the table entry pointer, otherwise the Invalid code is returned. After the new table is fully implemented, the table entry pointer itself will be returned or the default table entry pointer. The find function for two words combines the words with a space separator and calls the primary find function.
The add function was added to add an entry to the table, which now just consists of adding to the name to entry pointer map. This function is called at the beginning of the entry iteration loop in the table constructor and throws an exception (a string) if an error is found (a two-word code is already in the map). Eventually this code will be put into or called from the base table constructor.
The search type enumeration was removed along with the bracketing table entries (include their code enumerators) and the range member used to hold the indexes of the bracketing entries. The End Plain Word bracketing code was used by the unary operator recreate function to determine if a space should be added after the operator it is a name and not a symbol. This check was changed to checking if the last character of the operator name is a letter. There was also a match function that was no longer used and was removed.
[branch table commit f5f563cad2]
Thursday, December 11, 2014
Subscribe to:
Post Comments (Atom)
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.)