names module
Map variable names and string names to unique integers.
Used in the Logic Simulator project. Most of the modules in the project use this module either directly or indirectly.
- class names.Names
Bases:
object
Map variable names and string names to unique integers.
This class deals with storing grammatical keywords and user-defined words, and their corresponding name IDs, which are internal indexing integers. It provides functions for looking up either the name ID or the name string. It also keeps track of the number of error codes defined by other classes, and allocates new, unique error codes on demand.
- get_name_string(name_id: int) Optional[str]
Return the corresponding name string for name_id.
If the name_id is not an index in the names list, return None.
- get_name_type(name_id: int) Optional[Union[symbol_types.ReservedSymbolType, symbol_types.ExternalSymbolType]]
Return the corresponding type for name_id.
If the name_id is not an index in the names list, return None.
- lookup(name_string_list: list) list
Return a list of name IDs for each name string in name_string_list.
If the name string is not present in the names list, add it.
- query(name_string: str) Optional[int]
Return the corresponding name ID for name string.
If the name string is not present in the names list, return None.
- unique_error_codes(num_error_codes: int) list
Return a list of unique integer error codes.