关键字的定义:
struct Keyword
{
/* Constructor. */
Keyword (const char *allchars, int allchars_length,
const char *rest);
/* Data members defined immediately by the input file. */
/* The keyword as a string, possibly containing NUL bytes. */
const char *const _allchars;
int const _allchars_length;
/* Additional stuff seen on the same line of the input file. */
const char *const _rest;
/* Line number of this keyword in the input file. */
unsigned int _lineno;
};
关键字的继承类:
struct KeywordExt : public Keyword
{
/* Constructor. */
KeywordExt (const char *allchars, int allchars_length,
const char *rest);
/* Data members depending on the keyposition list. */
/* The selected characters that participate for the hash function,
selected according to the keyposition list, as a canonically reordered
multiset. */
const unsigned int * _selchars;
int _selchars_length;
/* Chained list of keywords having the same _selchars and
- if !option[NOLENGTH] - also the same _allchars_length.
Note that these duplicates are not members of the main keyword list. */
KeywordExt * _duplicate_link;
/* Methods depending on the keyposition list. */
/* Initializes selchars and selchars_length, without reordering. */
void init_selchars_tuple (const Positions& positions, const unsigned int *alpha_unify);
/* Initializes selchars and selchars_length, with reordering. */
void init_selchars_multiset (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
/* Deletes selchars. */
void delete_selchars ();
/* Data members used by the algorithm. */
int _hash_value; /* Hash value for the keyword. */
/* Data members used by the output routines. */
int _final_index;
private:
unsigned int * init_selchars_low (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
};
创建关键字实例的类:
class Keyword_Factory
{
public:
/* Constructor. */
Keyword_Factory ();
/* Destructor. */
virtual ~Keyword_Factory ();
/* Creates a new Keyword. */
virtual /*abstract*/ Keyword *
create_keyword (const char *allchars, int allchars_length,
const char *rest) = 0;
};