fparser Reference Guide
0.0.14
|
Public Member Functions | |
def | __init__ (self, name, parent=None, checking_enabled=False) |
def | __str__ (self) |
def | add_data_symbol (self, name, primitive_type) |
def | add_use_symbols (self, name, only_list=None, rename_list=None) |
def | lookup (self, name) |
def | name (self) |
def | parent (self) |
def | parent (self, value) |
def | add_child (self, child) |
def | del_child (self, name) |
def | children (self) |
def | root (self) |
Public Attributes | |
parent | |
Static Public Attributes | |
Symbol | |
Class implementing a single symbol table. Since this functionality is not yet fully mature, checks that new symbols don't clash with existing symbols are disabled by default. Once #201 is complete it is planned to switch this so that the checks are instead enabled by default. :param str name: the name of this scope. Will be the name of the \ associated module or routine. :param parent: the symbol table within which this one is nested (if any). :type parent: :py:class:`fparser.two.symbol_table.SymbolTable.Symbol` :param bool checking_enabled: whether or not validity checks are \ performed for symbols added to the table.
Definition at line 493 of file symbol_table.py.
def fparser.two.symbol_table.SymbolTable.add_child | ( | self, | |
child | |||
) |
Adds a child symbol table (scoping region nested within this one). :param child: the nested symbol table. :type child: :py:class:`fparser.two.symbol_table.SymbolTable` :raises TypeError: if the supplied child is not a SymbolTable.
Definition at line 680 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._children.
def fparser.two.symbol_table.SymbolTable.add_data_symbol | ( | self, | |
name, | |||
primitive_type | |||
) |
Creates a new Symbol with the specified properties and adds it to the symbol table. The supplied name is converted to lower case. TODO #201 add support for other symbol properties (kind, shape and visibility). :param str name: the name of the symbol. :param str primitive_type: the primitive type of the symbol. :raises TypeError: if any of the supplied parameters are of the \ wrong type. :raises SymbolTableError: if the symbol table already contains an entry with the supplied name.
Definition at line 542 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._checking_enabled, fparser.two.symbol_table.SymbolTable._data_symbols, and fparser.two.symbol_table.SymbolTable._modules.
def fparser.two.symbol_table.SymbolTable.add_use_symbols | ( | self, | |
name, | |||
only_list = None , |
|||
rename_list = None |
|||
) |
Creates an entry in the table for the USE of a module with the supplied name. If no `only_list` is supplied then this USE represents a wildcard import of all public symbols in the named module. If the USE statement has an ONLY clause but without any named symbols then `only_list` should be an empty list. A USE can also have one or more rename entries *without* an only list. :param str name: the name of the module being imported via a USE. Not \ case sensitive. :param only_list: if there is an 'only:' clause on the USE statement \ then this contains a list of tuples, each holding the local name \ of the symbol and its name in the module from which it is \ imported. These names are case insensitive. :type only_list: Optional[List[Tuple[str, str | NoneType]]] :param rename_list: a list of symbols that are renamed from the scope \ being imported. Each entry is a tuple containing the name in the \ local scope and the corresponding name in the module from which it\ is imported. These names are case insensitive. :type rename_list: Optional[List[Tuple[str, str]]]
Definition at line 591 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._modules.
def fparser.two.symbol_table.SymbolTable.children | ( | self | ) |
:returns: the child (nested) symbol tables, if any. :rtype: list of :py:class:`fparser.two.symbol_table.SymbolTable`
Definition at line 717 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._children.
def fparser.two.symbol_table.SymbolTable.del_child | ( | self, | |
name | |||
) |
Removes the named symbol table. :param str name: the name of the child symbol table to delete (not \ case sensitive). :raises KeyError: if the named table is not a child of this one.
Definition at line 696 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._children.
def fparser.two.symbol_table.SymbolTable.lookup | ( | self, | |
name | |||
) |
Lookup the symbol with the supplied name. :param str name: the name of the symbol to lookup (not case sensitive). :returns: the named symbol. :rtype: :py:class:`fparser.two.symbol_table.SymbolTable.Symbol` :raises KeyError: if the named symbol cannot be found in this or any \ parent scope.
Definition at line 624 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._data_symbols, fparser.common.base_classes.Variable.parent, fparser.two.symbol_table.SymbolTable.parent, and fparser.common.base_classes.Statement.parent.
def fparser.two.symbol_table.SymbolTable.name | ( | self | ) |
:returns: the name of this symbol table (scoping region). :rtype: str
Definition at line 646 of file symbol_table.py.
References fparser.two.symbol_table.ModuleUse._name, and fparser.two.symbol_table.SymbolTable._name.
def fparser.two.symbol_table.SymbolTable.parent | ( | self | ) |
:returns: the parent symbol table (scoping region) that contains \ this one (if any). :rtype: :py:class:`fparser.two.symbol_table.SymbolTable` or NoneType
Definition at line 654 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._parent.
def fparser.two.symbol_table.SymbolTable.parent | ( | self, | |
value | |||
) |
Set the parent scope for this symbol table. :param value: the parent symbol table. :type value: :py:class:`fparser.two.symbol_table.SymbolTable` :raises TypeError: if the supplied value is not None or a SymbolTable.
Definition at line 663 of file symbol_table.py.
References fparser.two.symbol_table.SymbolTable._parent.
def fparser.two.symbol_table.SymbolTable.root | ( | self | ) |
:returns: the top-level symbol table that contains the current \ scoping region (symbol table). :rtype: :py:class:`fparser.two.symbol_table.SymbolTable`
Definition at line 725 of file symbol_table.py.