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.
Classes:
-
Scope
–Organize the ASTx objects according to the scope.
-
ScopeNode
–Scope node organize the scope in different levels in the stack.
-
ScopeNodeBase
–ScopeNodeBase is the base used for the nodes (levels) in the scope.
-
SymbolTable
–Symbol Table for ASTx.
Scope
¶
Scope(scope_node_class: Type[ScopeNodeBase] = ScopeNode)
Organize the ASTx objects according to the scope.
Methods:
-
add
–Add a new node in the scope.
-
destroy
–Destroy the current scope.
-
get_first
–Get the first node in the scope.
-
get_last
–Get the latest node in the scope.
-
set_default_parent
–Set default parent for the current scope.
Source code in src/astx/symbol_table.py
59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
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
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
destroy
¶
destroy(node: ScopeNodeBase) -> None
Destroy the current scope.
Source code in src/astx/symbol_table.py
105 106 107 108 109 |
|
get_first
¶
get_first() -> ScopeNodeBase
Get the first node in the scope.
Source code in src/astx/symbol_table.py
95 96 97 98 |
|
get_last
¶
get_last() -> ScopeNodeBase
Get the latest node in the scope.
Source code in src/astx/symbol_table.py
100 101 102 103 |
|
set_default_parent
¶
set_default_parent(node: ScopeNodeBase) -> None
Set default parent for the current scope.
Source code in src/astx/symbol_table.py
111 112 113 |
|
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
30 31 32 33 34 35 36 37 38 |
|
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
30 31 32 33 34 35 36 37 38 |
|
SymbolTable
¶
SymbolTable()
Symbol Table for ASTx.
Methods:
-
define
–Define a new named expression inside the scoped stack.
-
lookup
–Get a named expression from the scope stack.
-
update
–Update the expression on the SymbolTable.
Source code in src/astx/symbol_table.py
123 124 |
|
define
¶
define(expr: NamedExpr) -> None
Define a new named expression inside the scoped stack.
Source code in src/astx/symbol_table.py
126 127 128 129 130 |
|
lookup
¶
lookup(name: str) -> NamedExpr
Get a named expression from the scope stack.
Source code in src/astx/symbol_table.py
144 145 146 147 148 149 150 151 |
|
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
132 133 134 135 136 137 138 139 140 141 142 |
|