mirror of
https://git.savannah.gnu.org/git/gperf.git
synced 2025-12-02 21:19:24 +00:00
More comments, fix last patch.
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
2002-11-03 Bruno Haible <bruno@clisp.org>
|
2002-11-03 Bruno Haible <bruno@clisp.org>
|
||||||
|
|
||||||
|
* src/output.cc (Output_Enum): Prepend an underscore to field names.
|
||||||
|
(Output_Expr1): Likewise.
|
||||||
|
(Output::output_hash_function): Simplify the special case for "-k 1,$".
|
||||||
|
|
||||||
* src/search.h (Search::init_asso_values, Search::find_asso_values):
|
* src/search.h (Search::init_asso_values, Search::find_asso_values):
|
||||||
New declarations.
|
New declarations.
|
||||||
(Search::try_asso_value): Renamed from Search::affects_prev.
|
(Search::try_asso_value): Renamed from Search::affects_prev.
|
||||||
|
|||||||
@@ -73,18 +73,12 @@ static const char *char_to_index;
|
|||||||
- The list is ordered by increasing _hash_value. This has been achieved
|
- The list is ordered by increasing _hash_value. This has been achieved
|
||||||
by Search::sort().
|
by Search::sort().
|
||||||
- Duplicates, i.e. keywords with the same _selchars set, are chained
|
- Duplicates, i.e. keywords with the same _selchars set, are chained
|
||||||
through the _duplicate_link pointer. This chain goes in the same
|
through the _duplicate_link pointer. Only one representative per
|
||||||
direction as the list order, i.e. from earlier list positions to
|
duplicate equivalence class remains on the linear keyword list.
|
||||||
later list positions. This property has been achieved by
|
- Still, accidental duplicates, i.e. keywords for which the _asso_values[]
|
||||||
Search::prepare() and has been preserved through Search::reorder()
|
search couldn't achieve different hash values, can occur on the linear
|
||||||
and Search::sort() (because the sorting criteria cannot distinguish
|
keyword list. After Search::sort(), we know that they form blocks of
|
||||||
keywords with the same _selchars, and Search::merge_sort() is a stable
|
consecutive list elements.
|
||||||
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.
|
|
||||||
*/
|
*/
|
||||||
Output::Output (KeywordExt_List *head, const char *array_type,
|
Output::Output (KeywordExt_List *head, const char *array_type,
|
||||||
const char *return_type, const char *struct_tag,
|
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
|
/* Computes the minimum and maximum hash values, and stores them
|
||||||
in _min_hash_value and _max_hash_value. */
|
in _min_hash_value and _max_hash_value. */
|
||||||
|
|
||||||
|
|||||||
13
src/output.h
13
src/output.h
@@ -48,7 +48,10 @@ public:
|
|||||||
int alpha_size,
|
int alpha_size,
|
||||||
const int *occurrences,
|
const int *occurrences,
|
||||||
const int *asso_values);
|
const int *asso_values);
|
||||||
|
|
||||||
|
/* Generates the hash function and the key word recognizer function. */
|
||||||
void output ();
|
void output ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* Computes the minimum and maximum hash values, and stores them
|
/* Computes the minimum and maximum hash values, and stores them
|
||||||
@@ -69,10 +72,20 @@ private:
|
|||||||
comparison code in generated function 'in_word_set'. */
|
comparison code in generated function 'in_word_set'. */
|
||||||
void output_keylength_table ();
|
void output_keylength_table ();
|
||||||
|
|
||||||
|
/* Prints out the array containing the keywords for the hash function. */
|
||||||
void output_keyword_table ();
|
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 ();
|
void output_lookup_array ();
|
||||||
|
|
||||||
|
/* Generate all the tables needed for the lookup function. */
|
||||||
void output_lookup_tables ();
|
void output_lookup_tables ();
|
||||||
|
|
||||||
|
/* Generates C code to perform the keyword lookup. */
|
||||||
void output_lookup_function_body (const struct Output_Compare&);
|
void output_lookup_function_body (const struct Output_Compare&);
|
||||||
|
|
||||||
|
/* Generates C code for the lookup function. */
|
||||||
void output_lookup_function ();
|
void output_lookup_function ();
|
||||||
|
|
||||||
/* Linked list of keywords. */
|
/* Linked list of keywords. */
|
||||||
|
|||||||
Reference in New Issue
Block a user