4 * Copyright (C) 1989 Free Software Foundation, Inc.
5 * written by Douglas C. Schmidt (d.schmidt@vanderbilt.edu)
7 * This file is part of GNU GPERF.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
29 #include "List_Node.h"
31 #include "ace/Copy_Disabled.h"
34 * Describes a duplicate entry.
36 * This is used for generating code by the <Key_List>.
38 class Duplicate_Entry
: private ACE_Copy_Disabled
41 /// Hash value for this particular duplicate set.
44 /// Slot into the main keyword storage array.
47 /// Number of consecutive duplicates at this slot.
52 * Data and function member declarations for the keyword list class.
54 * The key word list is a useful abstraction that keeps track of
55 * various pieces of information that enable that fast generation of
56 * the Gen_Perf.hash function. A Key_List is a singly-linked list
59 class Key_List
: private ACE_Copy_Disabled
64 int keyword_list_length ();
65 int max_key_length ();
72 /// Points to the head of the linked list.
75 /// Total number of duplicate hash values.
79 // = Make hash table 10 times larger than # of keyword entries.
85 static int occurrence (List_Node
*ptr
);
86 static int already_determined (List_Node
*ptr
);
87 static void determined (List_Node
*ptr
);
89 // @@ All of the following methods should be factored out and
90 // replaced by the use of the Strategy/Bridge pattern so that we can
91 // easily add new languages.
92 void output_min_max ();
93 void output_switch (int use_keyword_table
= 0);
94 void output_keyword_table ();
95 void output_keylength_table ();
96 void output_hash_function ();
97 void output_lookup_function ();
98 int output_binary_search_function();
99 int output_linear_search_function ();
100 int output_lookup_array ();
101 void output_strcasecmp ();
105 char *save_include_src ();
106 char *special_input (char delimiter
);
107 List_Node
*merge (List_Node
*list1
, List_Node
*list2
);
108 List_Node
*merge_sort (List_Node
*head
);
109 int count_duplicates (List_Node
*link
, const char *type
);
110 void update_lookup_array (int lookup_array
[],
113 Duplicate_Entry
*dup_ptr
,
115 /// Pointer to the type for word list.
118 // Pointer to return type for lookup function.
121 /// Shorthand for user-defined struct tag type.
124 /// C source code to be included verbatim.
127 /// Maximum length of the longest keyword.
130 /// Minimum length of the shortest keyword.
133 /// Minimum hash value for all keywords.
136 /// Maximum hash value for all keywords.
139 /// True if sorting by occurrence.
142 /// True if sorting by hash value.
145 /// True if sorting by key value.
148 /// True if any additional C code is included.
151 /// Length of head's Key_List, not counting duplicates.
154 /// Total number of keys, counting duplicates.
157 /// Default type for generated code.
158 static const char *const default_array_type
;
160 /// in_word_set return type, by default.
161 static const char *const default_return_type
;
163 /// How wide the printed field width must be to contain the maximum
165 static int field_width
;
167 /// Sets the slot location for all keysig characters that are now
169 static int determined_
[ACE_STANDARD_CHARACTER_SET_SIZE
];
172 #endif /* KEY_LIST_H */