view anagram/agcore/dict.h @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993 Parsifal Software. All Rights Reserved.
 * See the file COPYING for license and usage terms.
 *
 * dict.h - old dictionary module
 */

#ifndef DICT_H
#define DICT_H

struct string_dict {
  unsigned *ndx;                        /* index array */
  unsigned  nsx;                        /* number of strings */
  unsigned  nxs;                        /* number of indices allocated */
  char *text;                           /* text */
  unsigned  ntc;                        /* number of text characters */
  unsigned  nts;                        /* length of test storage */
  //unsigned short *ht;                 /* pointer to hash table */
  unsigned *ht;                         /* pointer to hash table */
  unsigned  nhs;                        /* number of hash table slots */
  unsigned *st;                         /* sort table */
  unsigned  nss;                        /* number of entries sorted */
  unsigned *pt;                         /* permutation table */
  unsigned ignore_case : 1;             /* ignore case flag */
};

struct list_dict {
  unsigned *ndx;                        /* index array */
  unsigned  nsx;                        /* number of lists */
  unsigned  nxs;                        /* number of indices allocated */
  int  *text;                           /* text */
  unsigned  ntc;                        /* number of text characters */
  unsigned  nts;                        /* length of test storage */
  //unsigned short *ht;                 /* pointer to hash table */
  unsigned *ht;                         /* pointer to hash table */
  unsigned  nhs;                        /* number of hash table slots */
  unsigned *st;                         /* sort table */
  unsigned  nss;                        /* number of entries sorted */
  unsigned *pt;                         /* permutation table */
};

struct tuple_dict {
  unsigned *ndx;                        /* index array */
  unsigned  nsx;                        /* number of lists */
  unsigned  nxs;                        /* number of indices allocated */
  int  *text;                           /* text */
  unsigned  ntc;                        /* number of text characters */
  unsigned  nts;                        /* length of test storage */
  //unsigned short *ht;                 /* pointer to hash table */
  unsigned *ht;                         /* pointer to hash table */
  unsigned  nhs;                        /* number of hash table slots */
  unsigned *st;                         /* sort table */
  unsigned  nss;                        /* number of entries sorted */
  unsigned *pt;                         /* permutation table */
  unsigned  tw;                         /* tuple width */
};

#define dict_str(d,n) ((d)->text+(d)->ndx[n])

int           add_list_dict(const int *s, int n, list_dict *d);
int           add_string_dict(const char *s, string_dict *d);
int           add_tuple_dict_new(tuple_dict *d, ...);
list_dict    *delete_list_dict(list_dict *da);
string_dict  *delete_string_dict(string_dict *da);
tuple_dict   *delete_tuple_dict(tuple_dict *da);
void          empty_tuple_dict(tuple_dict *);
void          extract_tuple_dict(tuple_dict *d, unsigned k, ...);
int           identify_string(const char *, string_dict *d);
int           insert_tuple_dict(tuple_dict *d, ...);
int           list_in_dict(int*, int, list_dict *);
list_dict    *reset_list_dict(list_dict *d);
tuple_dict   *reset_tuple_dict(tuple_dict *d);
list_dict    *null_list_dict(void);
string_dict  *null_str_dict(void);
tuple_dict   *null_tuple_dict(int tw);

//string_dict *restore_string_dict(char *text, int ntc, int ne, int ic,
//				   int byte_swap_required);
//void         sort_string_dict(string_dict *d);

#endif /* DICT_H */