home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / gnu / gperf.lzh / GPERF / KEY-LIST.H < prev    next >
C/C++ Source or Header  |  1993-07-30  |  5KB  |  95 lines

  1. /* This may look like C code, but it is really -*- C++ -*- */
  2.  
  3. /* Data and function member declarations for the keyword list class.
  4.  
  5.    Copyright (C) 1989 Free Software Foundation, Inc.
  6.    written by Douglas C. Schmidt (schmidt@ics.uci.edu)
  7.  
  8. This file is part of GNU GPERF.
  9.  
  10. GNU GPERF is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 1, or (at your option)
  13. any later version.
  14.  
  15. GNU GPERF is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with GNU GPERF; see the file COPYING.  If not, write to
  22. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  23.  
  24. /* The key word list is a useful abstraction that keeps track of
  25.    various pieces of information that enable that fast generation
  26.    of the Gen_Perf.hash function.  A Key_List is a singly-linked
  27.    list of List_Nodes. */
  28.  
  29. #pragma once
  30. #include "list-node.h"
  31. #include "std-err.h"
  32. #include "vectors.h"
  33. #include "read-line.h"
  34.  
  35. class Key_List : private Std_Err, private Read_Line, public Vectors
  36. {
  37. private:
  38.   const int   MAX_INT = ~unsigned (0) >> 1;          /* Most positive integer value. */
  39.   const int   MIN_INT = ~unsigned (0) ^ MAX_INT;     /* Most negative integer value. */
  40.   const int   MAX_SIGNED_CHAR    = 127;              /* Maximum value a signed char can take. */
  41.   const int   MAX_UNSIGNED_CHAR  = 255;              /* Maximum value an unsigned char can take. */
  42.   const int   MAX_UNSIGNED_SHORT = 65535;            /* Maximum value an unsigned short can take. */
  43.   const int   MAX_SIGNED_SHORT   = 32767;            /* Maximum value a signed short can take. */
  44.   const int   MIN_SIGNED_SHORT   = -32768;           /* Minimum value a signed short can take. */
  45.   const int   TABLE_MULTIPLE     = 10;               /* Make the hash table 8 times larger than the number of keyword entries. */
  46.   char       *const default_array_type  = "char *";  /* Default type for generated code. */
  47.   char       *const default_return_type = "char *";  /* in_word_set return type, by default. */
  48.   char       *array_type;                            /* Pointer to the type for word list. */
  49.   char       *return_type;                           /* Pointer to return type for lookup function. */
  50.   char       *struct_tag;                            /* Shorthand for user-defined struct tag type. */
  51.   char       *include_src;                           /* C source code to be included verbatim. */
  52.   int         max_key_len;                           /* Maximum length of the longest keyword. */
  53.   int         min_key_len;                           /* Minimum length of the shortest keyword. */
  54.   int         min_hash_value;                        /* Minimum hash value for all keywords. */
  55.   int         max_hash_value;                        /* Maximum hash value for all keywords. */
  56.   int         occurrence_sort;                       /* True if sorting by occurrence. */
  57.   int         hash_sort;                             /* True if sorting by hash value. */
  58.   int         additional_code;                       /* True if any additional C code is included. */
  59.   int         list_len;                              /* Length of head's Key_List, not counting duplicates. */
  60.   int         total_keys;                            /* Total number of keys, counting duplicates. */
  61.   static int  determined[ALPHA_SIZE];                /* Used in function reorder, below. */
  62.   static int  get_occurrence (List_Node *ptr);
  63.   static int  strcspn (const char *s, const char *reject);
  64.   static int  already_determined (List_Node *ptr);
  65.   static void set_determined (List_Node *ptr);
  66.   void        output_min_max (void);
  67.   void        output_switch (void);
  68.   void        output_keyword_table (void);
  69.   void        output_keylength_table (void);
  70.   void        output_hash_function (void);
  71.   void        output_lookup_function (void);
  72.   void        output_lookup_array (void);
  73.   void        set_output_types (void);
  74.   void        dump (void); 
  75.   char       *get_array_type (void);
  76.   char       *save_include_src (void);
  77.   char       *get_special_input (char delimiter);
  78.   List_Node  *merge (List_Node *list1, List_Node *list2);
  79.   List_Node  *merge_sort (List_Node *head);
  80.  
  81. protected:
  82.   List_Node  *head;                                  /* Points to the head of the linked list. */
  83.   int         total_duplicates;                      /* Total number of duplicate hash values. */
  84.  
  85. public:
  86.               Key_List   (void);
  87.              ~Key_List  (void);
  88.   int         keyword_list_length (void);
  89.   int         max_key_length (void);
  90.   void        reorder (void);
  91.   void        sort (void);
  92.   void        read_keys (void);
  93.   void        output (void);
  94. };
  95.