1 /* This may look like C code, but it is really -*- C++ -*- */
5 Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
6 Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
7 and Bruno Haible <bruno@clisp.org>.
9 This file is part of GNU GPERF.
11 GNU GPERF is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2, or (at your option)
16 GNU GPERF is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with this program; see the file COPYING.
23 If not, write to the Free Software Foundation, Inc.,
24 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
29 /* Class defined in "positions.h". */
32 /* An instance of this class is a keyword, as specified in the input file. */
37 Keyword (const char *allchars, int allchars_length,
40 /* Data members defined immediately by the input file. */
41 /* The keyword as a string, possibly containing NUL bytes. */
42 const char *const _allchars;
43 int const _allchars_length;
44 /* Additional stuff seen on the same line of the input file. */
45 const char *const _rest;
46 /* Line number of this keyword in the input file. */
50 /* A keyword, in the context of a given keyposition list. */
52 struct KeywordExt : public Keyword
55 KeywordExt (const char *allchars, int allchars_length,
58 /* Data members depending on the keyposition list. */
59 /* The selected characters that participate for the hash function,
60 selected according to the keyposition list, as a canonically reordered
62 const unsigned int * _selchars;
64 /* Chained list of keywords having the same _selchars and
65 - if !option[NOLENGTH] - also the same _allchars_length.
66 Note that these duplicates are not members of the main keyword list. */
67 KeywordExt * _duplicate_link;
69 /* Methods depending on the keyposition list. */
70 /* Initializes selchars and selchars_length, without reordering. */
71 void init_selchars_tuple (const Positions& positions, const unsigned int *alpha_unify);
72 /* Initializes selchars and selchars_length, with reordering. */
73 void init_selchars_multiset (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
74 /* Deletes selchars. */
75 void delete_selchars ();
77 /* Data members used by the algorithm. */
78 int _hash_value; /* Hash value for the keyword. */
80 /* Data members used by the output routines. */
84 unsigned int * init_selchars_low (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
87 /* An abstract factory for creating Keyword instances.
88 This factory is used to make the Input class independent of the concrete
97 virtual ~Keyword_Factory ();
99 /* Creates a new Keyword. */
100 virtual /*abstract*/ Keyword *
101 create_keyword (const char *allchars, int allchars_length,
102 const char *rest) = 0;
105 /* A statically allocated empty string. */
106 extern char empty_string[1];
110 #define INLINE inline
111 #include "keyword.icc"