comparison anagram/agcore/dict.h @ 0:13d2b8934445

Import AnaGram (near-)release tree into Mercurial.
author David A. Holland
date Sat, 22 Dec 2007 17:52:45 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:13d2b8934445
1 /*
2 * AnaGram, A System for Syntax Directed Programming
3 * Copyright 1993 Parsifal Software. All Rights Reserved.
4 * See the file COPYING for license and usage terms.
5 *
6 * dict.h - old dictionary module
7 */
8
9 #ifndef DICT_H
10 #define DICT_H
11
12 struct string_dict {
13 unsigned *ndx; /* index array */
14 unsigned nsx; /* number of strings */
15 unsigned nxs; /* number of indices allocated */
16 char *text; /* text */
17 unsigned ntc; /* number of text characters */
18 unsigned nts; /* length of test storage */
19 //unsigned short *ht; /* pointer to hash table */
20 unsigned *ht; /* pointer to hash table */
21 unsigned nhs; /* number of hash table slots */
22 unsigned *st; /* sort table */
23 unsigned nss; /* number of entries sorted */
24 unsigned *pt; /* permutation table */
25 unsigned ignore_case : 1; /* ignore case flag */
26 };
27
28 struct list_dict {
29 unsigned *ndx; /* index array */
30 unsigned nsx; /* number of lists */
31 unsigned nxs; /* number of indices allocated */
32 int *text; /* text */
33 unsigned ntc; /* number of text characters */
34 unsigned nts; /* length of test storage */
35 //unsigned short *ht; /* pointer to hash table */
36 unsigned *ht; /* pointer to hash table */
37 unsigned nhs; /* number of hash table slots */
38 unsigned *st; /* sort table */
39 unsigned nss; /* number of entries sorted */
40 unsigned *pt; /* permutation table */
41 };
42
43 struct tuple_dict {
44 unsigned *ndx; /* index array */
45 unsigned nsx; /* number of lists */
46 unsigned nxs; /* number of indices allocated */
47 int *text; /* text */
48 unsigned ntc; /* number of text characters */
49 unsigned nts; /* length of test storage */
50 //unsigned short *ht; /* pointer to hash table */
51 unsigned *ht; /* pointer to hash table */
52 unsigned nhs; /* number of hash table slots */
53 unsigned *st; /* sort table */
54 unsigned nss; /* number of entries sorted */
55 unsigned *pt; /* permutation table */
56 unsigned tw; /* tuple width */
57 };
58
59 #define dict_str(d,n) ((d)->text+(d)->ndx[n])
60
61 int add_list_dict(const int *s, int n, list_dict *d);
62 int add_string_dict(const char *s, string_dict *d);
63 int add_tuple_dict_new(tuple_dict *d, ...);
64 list_dict *delete_list_dict(list_dict *da);
65 string_dict *delete_string_dict(string_dict *da);
66 tuple_dict *delete_tuple_dict(tuple_dict *da);
67 void empty_tuple_dict(tuple_dict *);
68 void extract_tuple_dict(tuple_dict *d, unsigned k, ...);
69 int identify_string(const char *, string_dict *d);
70 int insert_tuple_dict(tuple_dict *d, ...);
71 int list_in_dict(int*, int, list_dict *);
72 list_dict *reset_list_dict(list_dict *d);
73 tuple_dict *reset_tuple_dict(tuple_dict *d);
74 list_dict *null_list_dict(void);
75 string_dict *null_str_dict(void);
76 tuple_dict *null_tuple_dict(int tw);
77
78 //string_dict *restore_string_dict(char *text, int ntc, int ne, int ic,
79 // int byte_swap_required);
80 //void sort_string_dict(string_dict *d);
81
82 #endif /* DICT_H */