From 7dbc285db494680ace45db68b2e6ab50d88e7bf0 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 9 Jan 2003 13:07:54 +0000 Subject: [PATCH] More comments, fix last patch. --- ChangeLog | 4 ++++ src/output.cc | 32 ++++++-------------------------- src/output.h | 13 +++++++++++++ 3 files changed, 23 insertions(+), 26 deletions(-) diff --git a/ChangeLog b/ChangeLog index b387548..d29acee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2002-11-03 Bruno Haible + * 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): New declarations. (Search::try_asso_value): Renamed from Search::affects_prev. diff --git a/src/output.cc b/src/output.cc index 5cea4e3..bee03bb 100644 --- a/src/output.cc +++ b/src/output.cc @@ -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. */ diff --git a/src/output.h b/src/output.h index 06667b5..74006cc 100644 --- a/src/output.h +++ b/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. */