mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 13:09:22 +00:00
More comments, fix last patch.
This commit is contained in:
@@ -73,18 +73,12 @@ static const char *char_to_index;
|
||||
- The list is ordered by increasing _hash_value. This has been achieved
|
||||
by Search::sort().
|
||||
- Duplicates, i.e. keywords with the same _selchars set, are chained
|
||||
through the _duplicate_link pointer. This chain goes in the same
|
||||
direction as the list order, i.e. from earlier list positions to
|
||||
later list positions. This property has been achieved by
|
||||
Search::prepare() and has been preserved through Search::reorder()
|
||||
and Search::sort() (because the sorting criteria cannot distinguish
|
||||
keywords with the same _selchars, and Search::merge_sort() is a stable
|
||||
sorting algorithm).
|
||||
- Therefore, since duplicates have the same _hash_value, duplicates
|
||||
have been sorted together by Search::sort(), and form blocks of
|
||||
consecutive list elements. The _duplicate_link of every element
|
||||
of a duplicate block (except the last element) points to the next
|
||||
element in this block.
|
||||
through the _duplicate_link pointer. Only one representative per
|
||||
duplicate equivalence class remains on the linear keyword list.
|
||||
- Still, accidental duplicates, i.e. keywords for which the _asso_values[]
|
||||
search couldn't achieve different hash values, can occur on the linear
|
||||
keyword list. After Search::sort(), we know that they form blocks of
|
||||
consecutive list elements.
|
||||
*/
|
||||
Output::Output (KeywordExt_List *head, const char *array_type,
|
||||
const char *return_type, const char *struct_tag,
|
||||
@@ -103,20 +97,6 @@ Output::Output (KeywordExt_List *head, const char *array_type,
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Recognizing duplicates. */
|
||||
|
||||
/* Returns true for a duplicate keyword, excluding the first element of a
|
||||
duplicate block. */
|
||||
inline bool
|
||||
is_redundant_duplicate (KeywordExt_List *elem)
|
||||
{
|
||||
/* Compare the hash values of this element and the next one. */
|
||||
return (elem->rest() != NULL
|
||||
&& elem->first()->_hash_value == elem->rest()->first()->_hash_value);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
/* Computes the minimum and maximum hash values, and stores them
|
||||
in _min_hash_value and _max_hash_value. */
|
||||
|
||||
|
||||
13
src/output.h
13
src/output.h
@@ -48,7 +48,10 @@ public:
|
||||
int alpha_size,
|
||||
const int *occurrences,
|
||||
const int *asso_values);
|
||||
|
||||
/* Generates the hash function and the key word recognizer function. */
|
||||
void output ();
|
||||
|
||||
private:
|
||||
|
||||
/* Computes the minimum and maximum hash values, and stores them
|
||||
@@ -69,10 +72,20 @@ private:
|
||||
comparison code in generated function 'in_word_set'. */
|
||||
void output_keylength_table ();
|
||||
|
||||
/* Prints out the array containing the keywords for the hash function. */
|
||||
void output_keyword_table ();
|
||||
|
||||
/* Generates the large, sparse table that maps hash values into
|
||||
the smaller, contiguous range of the keyword table. */
|
||||
void output_lookup_array ();
|
||||
|
||||
/* Generate all the tables needed for the lookup function. */
|
||||
void output_lookup_tables ();
|
||||
|
||||
/* Generates C code to perform the keyword lookup. */
|
||||
void output_lookup_function_body (const struct Output_Compare&);
|
||||
|
||||
/* Generates C code for the lookup function. */
|
||||
void output_lookup_function ();
|
||||
|
||||
/* Linked list of keywords. */
|
||||
|
||||
Reference in New Issue
Block a user