1 /* do not edit automatically generated by mc from symbolKey. */
2 /* symbolKey.def provides binary tree operations for storing symbols.
4 Copyright (C) 2015-2025 Free Software Foundation, Inc.
5 Contributed by Gaius Mulley <gaius@glam.ac.uk>.
7 This file is part of GNU Modula-2.
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)
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.
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/>. */
24 #if !defined (_symbolKey_H)
33 # if !defined (PROC_D)
35 typedef void (*PROC_t
) (void);
36 typedef struct { PROC_t proc
; } PROC
;
39 #if defined(__cplusplus)
44 # include "GnameKey.h"
46 # if defined (_symbolKey_C)
49 # define EXTERN extern
52 # define symbolKey_NulKey NULL
53 #if !defined (symbolKey_symbolTree_D)
54 # define symbolKey_symbolTree_D
55 typedef void *symbolKey_symbolTree
;
58 typedef struct symbolKey_isSymbol_p symbolKey_isSymbol
;
60 typedef struct symbolKey_performOperation_p symbolKey_performOperation
;
62 typedef bool (*symbolKey_isSymbol_t
) (void *);
63 struct symbolKey_isSymbol_p
{ symbolKey_isSymbol_t proc
; };
65 typedef void (*symbolKey_performOperation_t
) (void *);
66 struct symbolKey_performOperation_p
{ symbolKey_performOperation_t proc
; };
70 initTree - initializes a symbolTree pointed to by t.
73 EXTERN symbolKey_symbolTree
symbolKey_initTree (void);
76 killTree - destroys the symbolTree pointed to by t.
79 EXTERN
void symbolKey_killTree (symbolKey_symbolTree
*t
);
82 getSymKey - searches the symbolTree t for an entry name. If
83 found then the key is returned otherwise NulKey
87 EXTERN
void * symbolKey_getSymKey (symbolKey_symbolTree t
, nameKey_Name name
);
90 putSymKey - puts an symbol entry, name, in the symbolTree t.
91 SymKey is the value stored with name.
94 EXTERN
void symbolKey_putSymKey (symbolKey_symbolTree t
, nameKey_Name name
, void * key
);
97 delSymKey - deletes a symbol entry name in the symbolTree, t.
100 EXTERN
void symbolKey_delSymKey (symbolKey_symbolTree t
, nameKey_Name name
);
103 isEmptyTree - returns true if symbolTree, t, is empty.
106 EXTERN
bool symbolKey_isEmptyTree (symbolKey_symbolTree t
);
109 doesTreeContainAny - returns true if symbolTree, t, contains any
110 symbols which in turn return true when procedure,
111 p, is called with a symbol as its parameter.
114 EXTERN
bool symbolKey_doesTreeContainAny (symbolKey_symbolTree t
, symbolKey_isSymbol p
);
117 foreachNodeDo - for each node in symbolTree, t, a procedure, p,
118 is called with the node symbol as its parameter.
119 It traverse the tree in order.
122 EXTERN
void symbolKey_foreachNodeDo (symbolKey_symbolTree t
, symbolKey_performOperation p
);