| 1 |
(* NameKey.def provides a dynamic binary tree name to key. |
| 2 |
|
| 3 |
Copyright (C) 2001-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 |
Title : NameKey.def |
| 26 |
Author : Gaius Mulley |
| 27 |
System : UNIX (GNU Modula-2) |
| 28 |
Date : Mon Apr 23 17:20:48 2001 |
| 29 |
Last edit : Mon Apr 23 17:20:48 2001 |
| 30 |
Description: NameKey provides a totally dynamic binary tree name to key |
| 31 |
interface for the Modula-2 compiler. |
| 32 |
*) |
| 33 |
|
| 34 |
FROM SYSTEM IMPORT ADDRESS ; |
| 35 |
|
| 36 |
EXPORT QUALIFIED Name, NulName, |
| 37 |
MakeKey, GetKey, LengthKey, IsKey, WriteKey, |
| 38 |
IsSameExcludingCase, KeyToCharStar, makekey, |
| 39 |
CharKey ; |
| 40 |
|
| 41 |
|
| 42 |
CONST |
| 43 |
NulName = 0 ; (* No legal name. *) |
| 44 |
(* NulName is not present in the Tree *) |
| 45 |
|
| 46 |
TYPE |
| 47 |
Name = CARDINAL ; |
| 48 |
|
| 49 |
|
| 50 |
(* |
| 51 |
MakeKey - returns the Key of the symbol, a. If a is not in the |
| 52 |
name table then it is added, otherwise the Key of a is returned |
| 53 |
directly. Note that the name table has no scope - it merely |
| 54 |
presents a more convienient way of expressing strings. By a Key. |
| 55 |
These keys last for the duration of compilation. |
| 56 |
*) |
| 57 |
|
| 58 |
PROCEDURE MakeKey (a: ARRAY OF CHAR) : Name ; |
| 59 |
|
| 60 |
|
| 61 |
(* |
| 62 |
makekey - returns the Key of the symbol, a. If a is not in the |
| 63 |
name table then it is added, otherwise the Key of a is returned |
| 64 |
directly. Note that the name table has no scope - it merely |
| 65 |
presents a more convienient way of expressing strings. By a Key. |
| 66 |
These keys last for the duration of compilation. |
| 67 |
*) |
| 68 |
|
| 69 |
PROCEDURE makekey (a: ADDRESS) : Name ; |
| 70 |
|
| 71 |
|
| 72 |
(* |
| 73 |
GetKey - returns the name, a, of the key, key. |
| 74 |
*) |
| 75 |
|
| 76 |
PROCEDURE GetKey (key: Name; VAR a: ARRAY OF CHAR) ; |
| 77 |
|
| 78 |
|
| 79 |
(* |
| 80 |
LengthKey - returns the StrLen of a Key. |
| 81 |
*) |
| 82 |
|
| 83 |
PROCEDURE LengthKey (Key: Name) : CARDINAL ; |
| 84 |
|
| 85 |
|
| 86 |
(* |
| 87 |
IsKey - returns TRUE if string, a, is currently a key. |
| 88 |
*) |
| 89 |
|
| 90 |
PROCEDURE IsKey (a: ARRAY OF CHAR) : BOOLEAN ; |
| 91 |
|
| 92 |
|
| 93 |
(* |
| 94 |
WriteKey - Display the symbol represented by Key. |
| 95 |
*) |
| 96 |
|
| 97 |
PROCEDURE WriteKey (key: Name) ; |
| 98 |
|
| 99 |
|
| 100 |
(* |
| 101 |
IsSameExcludingCase - returns TRUE if key1 and key2 are |
| 102 |
the same. It is case insensitive. |
| 103 |
*) |
| 104 |
|
| 105 |
PROCEDURE IsSameExcludingCase (key1, key2: Name) : BOOLEAN ; |
| 106 |
|
| 107 |
|
| 108 |
(* |
| 109 |
KeyToCharStar - returns the C char * string equivalent for, key. |
| 110 |
*) |
| 111 |
|
| 112 |
PROCEDURE KeyToCharStar (key: Name) : ADDRESS ; |
| 113 |
|
| 114 |
|
| 115 |
(* |
| 116 |
CharKey - returns the key[i] character. |
| 117 |
*) |
| 118 |
|
| 119 |
PROCEDURE CharKey (key: Name; i: CARDINAL) : CHAR ; |
| 120 |
|
| 121 |
|
| 122 |
END NameKey. |