Blame src/keyword.h

Packit b27855
/* This may look like C code, but it is really -*- C++ -*- */
Packit b27855
Packit b27855
/* Keyword data.
Packit b27855
Packit b27855
   Copyright (C) 1989-1998, 2000, 2002 Free Software Foundation, Inc.
Packit b27855
   Written by Douglas C. Schmidt <schmidt@ics.uci.edu>
Packit b27855
   and Bruno Haible <bruno@clisp.org>.
Packit b27855
Packit b27855
   This file is part of GNU GPERF.
Packit b27855
Packit b27855
   This program is free software: you can redistribute it and/or modify
Packit b27855
   it under the terms of the GNU General Public License as published by
Packit b27855
   the Free Software Foundation; either version 3 of the License, or
Packit b27855
   (at your option) any later version.
Packit b27855
Packit b27855
   This program is distributed in the hope that it will be useful,
Packit b27855
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b27855
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b27855
   GNU General Public License for more details.
Packit b27855
Packit b27855
   You should have received a copy of the GNU General Public License
Packit b27855
   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
Packit b27855
Packit b27855
#ifndef keyword_h
Packit b27855
#define keyword_h 1
Packit b27855
Packit b27855
/* Class defined in "positions.h".  */
Packit b27855
class Positions;
Packit b27855
Packit b27855
/* An instance of this class is a keyword, as specified in the input file.  */
Packit b27855
Packit b27855
struct Keyword
Packit b27855
{
Packit b27855
  /* Constructor.  */
Packit b27855
                        Keyword (const char *allchars, int allchars_length,
Packit b27855
                                 const char *rest);
Packit b27855
Packit b27855
  /* Data members defined immediately by the input file.  */
Packit b27855
  /* The keyword as a string, possibly containing NUL bytes.  */
Packit b27855
  const char *const     _allchars;
Packit b27855
  int const             _allchars_length;
Packit b27855
  /* Additional stuff seen on the same line of the input file.  */
Packit b27855
  const char *const     _rest;
Packit b27855
  /* Line number of this keyword in the input file.  */
Packit b27855
  unsigned int          _lineno;
Packit b27855
};
Packit b27855
Packit b27855
/* A keyword, in the context of a given keyposition list.  */
Packit b27855
Packit b27855
struct KeywordExt : public Keyword
Packit b27855
{
Packit b27855
  /* Constructor.  */
Packit b27855
                        KeywordExt (const char *allchars, int allchars_length,
Packit b27855
                                    const char *rest);
Packit b27855
Packit b27855
  /* Data members depending on the keyposition list.  */
Packit b27855
  /* The selected characters that participate for the hash function,
Packit b27855
     selected according to the keyposition list, as a canonically reordered
Packit b27855
     multiset.  */
Packit b27855
  const unsigned int *  _selchars;
Packit b27855
  int                   _selchars_length;
Packit b27855
  /* Chained list of keywords having the same _selchars and
Packit b27855
     - if !option[NOLENGTH] - also the same _allchars_length.
Packit b27855
     Note that these duplicates are not members of the main keyword list.  */
Packit b27855
  KeywordExt *          _duplicate_link;
Packit b27855
Packit b27855
  /* Methods depending on the keyposition list.  */
Packit b27855
  /* Initializes selchars and selchars_length, without reordering.  */
Packit b27855
  void                  init_selchars_tuple (const Positions& positions, const unsigned int *alpha_unify);
Packit b27855
  /* Initializes selchars and selchars_length, with reordering.  */
Packit b27855
  void                  init_selchars_multiset (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
Packit b27855
  /* Deletes selchars.  */
Packit b27855
  void                  delete_selchars ();
Packit b27855
Packit b27855
  /* Data members used by the algorithm.  */
Packit b27855
  int                   _hash_value; /* Hash value for the keyword.  */
Packit b27855
Packit b27855
  /* Data members used by the output routines.  */
Packit b27855
  int                   _final_index;
Packit b27855
Packit b27855
private:
Packit b27855
  unsigned int *        init_selchars_low (const Positions& positions, const unsigned int *alpha_unify, const unsigned int *alpha_inc);
Packit b27855
};
Packit b27855
Packit b27855
/* An abstract factory for creating Keyword instances.
Packit b27855
   This factory is used to make the Input class independent of the concrete
Packit b27855
   class KeywordExt.  */
Packit b27855
Packit b27855
class Keyword_Factory
Packit b27855
{
Packit b27855
public:
Packit b27855
  /* Constructor.  */
Packit b27855
                        Keyword_Factory ();
Packit b27855
  /* Destructor.  */
Packit b27855
  virtual               ~Keyword_Factory ();
Packit b27855
Packit b27855
  /* Creates a new Keyword.  */
Packit b27855
  virtual /*abstract*/ Keyword *
Packit b27855
                        create_keyword (const char *allchars, int allchars_length,
Packit b27855
                                        const char *rest) = 0;
Packit b27855
};
Packit b27855
Packit b27855
/* A statically allocated empty string.  */
Packit b27855
extern char empty_string[1];
Packit b27855
Packit b27855
#ifdef __OPTIMIZE__
Packit b27855
Packit b27855
#define INLINE inline
Packit b27855
#include "keyword.icc"
Packit b27855
#undef INLINE
Packit b27855
Packit b27855
#endif
Packit b27855
Packit b27855
#endif