Debian Codegraph @

gcc/m2/mc/symbolKey.def

raw
1 (* symbolKey.def provides binary tree operations for storing symbols.
2
3 Copyright (C) 2015-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GNU Modula-2; see the file COPYING3. If not see
20 <http://www.gnu.org/licenses/>. *)
21
22 DEFINITION MODULE symbolKey ;
23
24 (* Provides binary tree operations for storing symbols.
25 Used by the decl module to provide scoping of symbols. *)
26
27 FROM SYSTEM IMPORT ADDRESS ;
28 FROM nameKey IMPORT Name ;
29
30
31 CONST
32 NulKey = NIL ;
33
34 TYPE
35 symbolTree ;
36
37 isSymbol = PROCEDURE (ADDRESS) : BOOLEAN ;
38 performOperation = PROCEDURE (ADDRESS) ;
39
40
41 (*
42 initTree - initializes a symbolTree pointed to by t.
43 *)
44
45 PROCEDURE initTree () : symbolTree ;
46
47
48 (*
49 killTree - destroys the symbolTree pointed to by t.
50 *)
51
52 PROCEDURE killTree (VAR t: symbolTree) ;
53
54
55 (*
56 getSymKey - searches the symbolTree t for an entry name. If
57 found then the key is returned otherwise NulKey
58 is returned.
59 *)
60
61 PROCEDURE getSymKey (t: symbolTree; name: Name) : ADDRESS ;
62
63
64 (*
65 putSymKey - puts an symbol entry, name, in the symbolTree t.
66 SymKey is the value stored with name.
67 *)
68
69 PROCEDURE putSymKey (t: symbolTree; name: Name; key: ADDRESS) ;
70
71
72 (*
73 delSymKey - deletes a symbol entry name in the symbolTree, t.
74 *)
75
76 PROCEDURE delSymKey (t: symbolTree; name: Name) ;
77
78
79 (*
80 isEmptyTree - returns true if symbolTree, t, is empty.
81 *)
82
83 PROCEDURE isEmptyTree (t: symbolTree) : BOOLEAN ;
84
85
86 (*
87 doesTreeContainAny - returns true if symbolTree, t, contains any
88 symbols which in turn return true when procedure,
89 p, is called with a symbol as its parameter.
90 *)
91
92 PROCEDURE doesTreeContainAny (t: symbolTree; p: isSymbol) : BOOLEAN ;
93
94
95 (*
96 foreachNodeDo - for each node in symbolTree, t, a procedure, p,
97 is called with the node symbol as its parameter.
98 It traverse the tree in order.
99 *)
100
101 PROCEDURE foreachNodeDo (t: symbolTree; p: performOperation) ;
102
103
104 END symbolKey.