32
32
"""
33
33
This module contains parts of an abstract document language model for VHDL.
34
34
35
- Symbols derived from names.
35
+ Symbols are entity specific wrappers for names that reference VHDL language entities .
36
36
"""
37
- from enum import Flag , auto
38
- from typing import Any
37
+ from enum import Flag , auto
38
+ from typing import Any , Optional as Nullable
39
39
40
- from pyTooling .Decorators import export
40
+ from pyTooling .Decorators import export
41
+ from pyTooling .MetaClasses import ExtendedType
41
42
42
- from pyVHDLModel .Name import Name , AllName
43
+ from pyVHDLModel .Name import Name , AllName
43
44
44
45
45
46
@export
46
47
class PossibleReference (Flag ):
47
48
"""
48
- A ``PossibleReference`` is an enumeration. It represents possible targets for a reference in a :class:`~pyVHDLModel.Symbol`.
49
+ Is an enumeration, representing possible targets for a reference in a :class:`~pyVHDLModel.Symbol`.
49
50
"""
50
51
51
52
Unknown = 0
@@ -90,10 +91,14 @@ class PossibleReference(Flag):
90
91
91
92
92
93
@export
93
- class Symbol :
94
- _name : Name
95
- _possibleReferences : PossibleReference
96
- _reference : Any
94
+ class Symbol (metaclass = ExtendedType ):
95
+ """
96
+ Base-class for all symbol classes.
97
+ """
98
+
99
+ _name : Name #: The name to reference the langauge entity.
100
+ _possibleReferences : PossibleReference #: An enumeration to filter possible references.
101
+ _reference : Nullable [Any ] #: The resolved language entity, otherwise ``None``.
97
102
98
103
def __init__ (self , name : Name , possibleReferences : PossibleReference ):
99
104
self ._name = name
@@ -130,7 +135,18 @@ def __str__(self) -> str:
130
135
131
136
@export
132
137
class LibraryReferenceSymbol (Symbol ):
133
- """A library reference in a library clause."""
138
+ """
139
+ Represents a reference (name) to a library.
140
+
141
+ The internal name will be a :class:`~pyVHDLModel.Name.SimpleName`.
142
+
143
+ .. admonition:: Example
144
+
145
+ .. code-block:: VHDL
146
+
147
+ library ieee;
148
+ -- ^^^^
149
+ """
134
150
135
151
def __init__ (self , name : Name ):
136
152
super ().__init__ (name , PossibleReference .Library )
@@ -146,7 +162,18 @@ def Library(self, value: 'Library') -> None:
146
162
147
163
@export
148
164
class PackageReferenceSymbol (Symbol ):
149
- """A package reference in a use clause."""
165
+ """
166
+ Represents a reference (name) to a package.
167
+
168
+ The internal name will be a :class:`~pyVHDLModel.Name.SelectedName`.
169
+
170
+ .. admonition:: Example
171
+
172
+ .. code-block:: VHDL
173
+
174
+ use ieee.numeric_std;
175
+ -- ^^^^^^^^^^^^^^^^
176
+ """
150
177
151
178
def __init__ (self , name : Name ):
152
179
super ().__init__ (name , PossibleReference .Package )
@@ -162,7 +189,18 @@ def Package(self, value: 'Package') -> None:
162
189
163
190
@export
164
191
class PackageMemberReferenceSymbol (Symbol ):
165
- """A package member reference in a use clause."""
192
+ """
193
+ Represents a reference (name) to a package member.
194
+
195
+ The internal name will be a :class:`~pyVHDLModel.Name.SelectedName`.
196
+
197
+ .. admonition:: Example
198
+
199
+ .. code-block:: VHDL
200
+
201
+ use ieee.numeric_std.unsigned;
202
+ -- ^^^^^^^^^^^^^^^^^^^^^^^^^
203
+ """
166
204
167
205
def __init__ (self , name : Name ):
168
206
super ().__init__ (name , PossibleReference .PackageMember )
@@ -178,7 +216,18 @@ def Member(self, value: 'Package') -> None: # TODO: typehint
178
216
179
217
@export
180
218
class AllPackageMembersReferenceSymbol (Symbol ):
181
- """A package reference in a use clause."""
219
+ """
220
+ Represents a reference (name) to all package members.
221
+
222
+ The internal name will be a :class:`~pyVHDLModel.Name.AllName`.
223
+
224
+ .. admonition:: Example
225
+
226
+ .. code-block:: VHDL
227
+
228
+ use ieee.numeric_std.all;
229
+ -- ^^^^^^^^^^^^^^^^^^^^
230
+ """
182
231
183
232
def __init__ (self , name : AllName ):
184
233
super ().__init__ (name , PossibleReference .PackageMember )
0 commit comments