]>
Commit | Line | Data |
---|---|---|
1eee94d3 GM |
1 | /* do not edit automatically generated by mc from SymbolKey. */ |
2 | /* SymbolKey.def binary tree operations for storing symbols. | |
3 | ||
83ffe9cd | 4 | Copyright (C) 2001-2023 Free Software Foundation, Inc. |
1eee94d3 GM |
5 | Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>. |
6 | ||
7 | This file is part of GNU Modula-2. | |
8 | ||
9 | GNU Modula-2 is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
11 | the Free Software Foundation; either version 3, or (at your option) | |
12 | any later version. | |
13 | ||
14 | GNU Modula-2 is distributed in the hope that it will be useful, but | |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
17 | General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
20 | along with GNU Modula-2; see the file COPYING3. If not see | |
21 | <http://www.gnu.org/licenses/>. */ | |
22 | ||
23 | ||
24 | #if !defined (_SymbolKey_H) | |
25 | # define _SymbolKey_H | |
26 | ||
27 | #include "config.h" | |
28 | #include "system.h" | |
29 | # ifdef __cplusplus | |
30 | extern "C" { | |
31 | # endif | |
32 | # if !defined (PROC_D) | |
33 | # define PROC_D | |
34 | typedef void (*PROC_t) (void); | |
35 | typedef struct { PROC_t proc; } PROC; | |
36 | # endif | |
37 | ||
38 | # include "GSYSTEM.h" | |
39 | # include "GNameKey.h" | |
40 | ||
41 | # if defined (_SymbolKey_C) | |
42 | # define EXTERN | |
43 | # else | |
44 | # define EXTERN extern | |
45 | # endif | |
46 | ||
47 | # define SymbolKey_NulKey 0 | |
48 | #if !defined (SymbolKey_SymbolTree_D) | |
49 | # define SymbolKey_SymbolTree_D | |
50 | typedef void *SymbolKey_SymbolTree; | |
51 | #endif | |
52 | ||
53 | typedef struct SymbolKey_IsSymbol_p SymbolKey_IsSymbol; | |
54 | ||
55 | typedef struct SymbolKey_PerformOperation_p SymbolKey_PerformOperation; | |
56 | ||
57 | typedef unsigned int (*SymbolKey_IsSymbol_t) (unsigned int); | |
58 | struct SymbolKey_IsSymbol_p { SymbolKey_IsSymbol_t proc; }; | |
59 | ||
60 | typedef void (*SymbolKey_PerformOperation_t) (unsigned int); | |
61 | struct SymbolKey_PerformOperation_p { SymbolKey_PerformOperation_t proc; }; | |
62 | ||
63 | ||
64 | /* | |
65 | InitTree - Initializes a SymbolTree pointed to by t. | |
66 | */ | |
67 | ||
68 | EXTERN void SymbolKey_InitTree (SymbolKey_SymbolTree *t); | |
69 | ||
70 | /* | |
71 | KillTree - Destroys the SymbolTree pointed to by t. | |
72 | */ | |
73 | ||
74 | EXTERN void SymbolKey_KillTree (SymbolKey_SymbolTree *t); | |
75 | ||
76 | /* | |
77 | GetSymKey - Searches the SymbolTree t for an entry NameKey. If | |
78 | found then the SymKey is returned. NulKey = not found. | |
79 | */ | |
80 | ||
81 | EXTERN unsigned int SymbolKey_GetSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey); | |
82 | ||
83 | /* | |
84 | PutSymKey - Puts an symbol entry NameKey in the SymbolTree t. | |
85 | SymKey is the value stored with NameKey. | |
86 | */ | |
87 | ||
88 | EXTERN void SymbolKey_PutSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey, unsigned int SymKey); | |
89 | ||
90 | /* | |
91 | DelSymKey - Deletes a symbol entry NameKey in the SymbolTree t. | |
92 | */ | |
93 | ||
94 | EXTERN void SymbolKey_DelSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey); | |
95 | ||
96 | /* | |
97 | IsEmptyTree - returns true if SymbolTree, t, is empty. | |
98 | */ | |
99 | ||
100 | EXTERN unsigned int SymbolKey_IsEmptyTree (SymbolKey_SymbolTree t); | |
101 | ||
102 | /* | |
103 | DoesTreeContainAny - returns true if SymbolTree, t, contains any | |
104 | symbols which in turn return true when procedure, | |
105 | P, is called with a symbol as its parameter. | |
106 | */ | |
107 | ||
108 | EXTERN unsigned int SymbolKey_DoesTreeContainAny (SymbolKey_SymbolTree t, SymbolKey_IsSymbol P); | |
109 | ||
110 | /* | |
111 | ForeachNodeDo - for each node in SymbolTree, t, a procedure, P, | |
112 | is called with the node symbol as its parameter. | |
113 | It traverse the tree in order. | |
114 | */ | |
115 | ||
116 | EXTERN void SymbolKey_ForeachNodeDo (SymbolKey_SymbolTree t, SymbolKey_PerformOperation P); | |
117 | ||
118 | /* | |
119 | ContainsSymKey - return TRUE if tree, t, contains an entry for, NameKey. | |
120 | */ | |
121 | ||
122 | EXTERN unsigned int SymbolKey_ContainsSymKey (SymbolKey_SymbolTree t, NameKey_Name NameKey); | |
123 | ||
124 | /* | |
125 | NoOfNodes - returns the number of nodes in the tree t. | |
126 | */ | |
127 | ||
128 | EXTERN unsigned int SymbolKey_NoOfNodes (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition); | |
129 | ||
130 | /* | |
131 | ForeachNodeConditionDo - traverse the tree t and for any node which satisfied | |
132 | condition call P. | |
133 | */ | |
134 | ||
135 | EXTERN void SymbolKey_ForeachNodeConditionDo (SymbolKey_SymbolTree t, SymbolKey_IsSymbol condition, SymbolKey_PerformOperation P); | |
136 | # ifdef __cplusplus | |
137 | } | |
138 | # endif | |
139 | ||
140 | # undef EXTERN | |
141 | #endif |