Saturday, February 13, 2010

Table Class - Searching

The Table class needs a few functions for searching. It will also contain initialization for some table related variables and several access functions (the table entries themselves will be kept private). The actual data for the table will be put into a structured array initializer outside the class.

Each of the search functions will return the index of the table entry of the item found. The index can then be used with the access functions. To speed up searching of the Table, the entries in the table will be grouped together by type. There will be 3 major search functions:
  • Search for an immediate command including argument form
  • Search for a string of a given length of a given type
  • Search for a two word command
For the search for a string, there will be four types:
  • Plain Words – Commands, Word Operators, and Internal Functions that don't have a parentheses
  • Data Type Words – Internal Functions that have a data type symbol but no parentheses (currently none are planned initially, but examples are DATE$ and TIME$)
  • Parentheses – Internal Functions that have parentheses including those that may have a data type symbol, for example MID$(...)
  • Symbol – Symbol character Operators (one or two characters) and other symbols, for example colon statement separator and single-quote remark
The immediate command search returns the command arguments in a structure within the string field of the token. This required a String constructor be added for a generic (void) pointer along with a length. With this constructor is new access function get_data(), which returns the void pointer.