symbol_table
¶
Symbol Table module for ASTx.
The SymbolTable
class offered here allows the definition
of scopes, so the variable or function would be available in
specifics scopes.
Scope
¶
Scope(scope_node_class: Type[ScopeNodeBase] = ScopeNode)
Organize the ASTx objects according to the scope.
Source code in src/astx/symbol_table.py
55 56 57 58 59 60 61 62 63 64 65 66 67 |
|
add
¶
add(name: str, parent: Optional[ScopeNodeBase] = None, change_current: bool = True) -> ScopeNodeBase
Add a new node in the scope.
Source code in src/astx/symbol_table.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
|
destroy
¶
destroy(node: ScopeNodeBase) -> None
Destroy the current scope.
Source code in src/astx/symbol_table.py
101 102 103 104 105 |
|
get_first
¶
get_first() -> ScopeNodeBase
Get the first node in the scope.
Source code in src/astx/symbol_table.py
91 92 93 94 |
|
get_last
¶
get_last() -> ScopeNodeBase
Get the latest node in the scope.
Source code in src/astx/symbol_table.py
96 97 98 99 |
|
set_default_parent
¶
set_default_parent(node: ScopeNodeBase) -> None
Set default parent for the current scope.
Source code in src/astx/symbol_table.py
107 108 109 |
|
ScopeNode
¶
ScopeNode(name: str, parent: Optional[ScopeNodeBase] = None)
Bases: ScopeNodeBase
Scope node organize the scope in different levels in the stack.
Source code in src/astx/symbol_table.py
28 29 30 31 32 33 34 35 36 |
|
ScopeNodeBase
¶
ScopeNodeBase(name: str, parent: Optional[ScopeNodeBase] = None)
ScopeNodeBase is the base used for the nodes (levels) in the scope.
Source code in src/astx/symbol_table.py
28 29 30 31 32 33 34 35 36 |
|
SymbolTable
¶
SymbolTable()
Symbol Table for ASTx.
Source code in src/astx/symbol_table.py
118 119 |
|
define
¶
define(expr: NamedExpr) -> None
Define a new named expression inside the scoped stack.
Source code in src/astx/symbol_table.py
121 122 123 124 125 |
|
lookup
¶
lookup(name: str) -> NamedExpr
Get a named expression from the scope stack.
Source code in src/astx/symbol_table.py
139 140 141 142 143 144 145 146 |
|
update
¶
update(expr: NamedExpr) -> None
Update the expression on the SymbolTable.
It is useful mainly for updating the comment of the expression.
Source code in src/astx/symbol_table.py
127 128 129 130 131 132 133 134 135 136 137 |
|