| 1 |
(* nameKey.def provides a dynamic binary tree name to key. |
| 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 nameKey ; |
| 23 |
|
| 24 |
|
| 25 |
FROM SYSTEM IMPORT ADDRESS ; |
| 26 |
|
| 27 |
|
| 28 |
CONST |
| 29 |
NulName = 0 ; (* No legal name. *) |
| 30 |
(* NulName is not present in the Tree *) |
| 31 |
|
| 32 |
TYPE |
| 33 |
Name = CARDINAL ; |
| 34 |
|
| 35 |
|
| 36 |
(* |
| 37 |
makeKey - returns the Key of the symbol, a. If a is not in the |
| 38 |
name table then it is added, otherwise the Key of a is returned |
| 39 |
directly. Note that the name table has no scope - it merely |
| 40 |
presents a more convienient way of expressing strings. By a Key. |
| 41 |
These keys last for the duration of compilation. |
| 42 |
*) |
| 43 |
|
| 44 |
PROCEDURE makeKey (a: ARRAY OF CHAR) : Name ; |
| 45 |
|
| 46 |
|
| 47 |
(* |
| 48 |
makekey - returns the Key of the symbol, a. If a is not in the |
| 49 |
name table then it is added, otherwise the Key of a is returned |
| 50 |
directly. Note that the name table has no scope - it merely |
| 51 |
presents a more convienient way of expressing strings. By a Key. |
| 52 |
These keys last for the duration of compilation. |
| 53 |
*) |
| 54 |
|
| 55 |
PROCEDURE makekey (a: ADDRESS) : Name ; |
| 56 |
|
| 57 |
|
| 58 |
(* |
| 59 |
getKey - returns the name, a, of the key, key. |
| 60 |
*) |
| 61 |
|
| 62 |
PROCEDURE getKey (key: Name; VAR a: ARRAY OF CHAR) ; |
| 63 |
|
| 64 |
|
| 65 |
(* |
| 66 |
lengthKey - returns the length of a Key. |
| 67 |
*) |
| 68 |
|
| 69 |
PROCEDURE lengthKey (key: Name) : CARDINAL ; |
| 70 |
|
| 71 |
|
| 72 |
(* |
| 73 |
isKey - returns TRUE if string, a, is currently a key. |
| 74 |
*) |
| 75 |
|
| 76 |
PROCEDURE isKey (a: ARRAY OF CHAR) : BOOLEAN ; |
| 77 |
|
| 78 |
|
| 79 |
(* |
| 80 |
writeKey - Display the symbol represented by Key. |
| 81 |
*) |
| 82 |
|
| 83 |
PROCEDURE writeKey (key: Name) ; |
| 84 |
|
| 85 |
|
| 86 |
(* |
| 87 |
isSameExcludingCase - returns TRUE if key1 and key2 are |
| 88 |
the same. It is case insensitive. |
| 89 |
*) |
| 90 |
|
| 91 |
PROCEDURE isSameExcludingCase (key1, key2: Name) : BOOLEAN ; |
| 92 |
|
| 93 |
|
| 94 |
(* |
| 95 |
keyToCharStar - returns the C char * string equivalent for, key. |
| 96 |
*) |
| 97 |
|
| 98 |
PROCEDURE keyToCharStar (key: Name) : ADDRESS ; |
| 99 |
|
| 100 |
|
| 101 |
END nameKey. |