astx.symbol_table
astx.symbol_table
Source: packages/astx/src/astx/symbol_table.py
title: Symbol Table module for ASTx.
summary: |-
The `SymbolTable` class offered here allows the definition
of scopes, so the variable or function would be available in
specifics scopes.Classes
ScopeNodeBase
title: ScopeNodeBase is the base used for the nodes (levels) in the scope.
attributes:
name:
type: str
parent:
type: Optional[ScopeNodeBase]
default_parent:
type: Optional[ScopeNodeBase]
named_expr:
type: dict[str, NamedExpr]ScopeNode(ScopeNodeBase)
title: Scope node organize the scope in different levels in the stack.
attributes:
name:
type: str
parent:
type: Optional[ScopeNodeBase]
default_parent:
type: Optional[ScopeNodeBase]
named_expr:
type: dict[str, NamedExpr]Scope
title: Organize the ASTx objects according to the scope.
attributes:
nodes:
type: dict[int, ScopeNodeBase]
current:
type: Optional[ScopeNodeBase]
previous:
type: Optional[ScopeNodeBase]
scope_node_class:
type: type[ScopeNodeBase]Methods
add(self, name: str, parent: Optional[ScopeNodeBase]=None, change_current: bool=True) -> ScopeNodeBase
title: Add a new node in the scope.
parameters:
name:
type: str
parent:
type: Optional[ScopeNodeBase]
change_current:
type: bool
returns:
type: ScopeNodeBaseget_first(self) -> ScopeNodeBase
title: Get the first node in the scope.
returns:
type: ScopeNodeBaseget_last(self) -> ScopeNodeBase
title: Get the latest node in the scope.
returns:
type: ScopeNodeBasedestroy(self, node: ScopeNodeBase) -> None
title: Destroy the current scope.
parameters:
node:
type: ScopeNodeBaseset_default_parent(self, node: ScopeNodeBase) -> None
title: Set default parent for the current scope.
parameters:
node:
type: ScopeNodeBaseSymbolTable
title: Symbol Table for ASTx.
attributes:
scopes:
type: ScopeMethods
define(self, expr: NamedExpr) -> None
title: Define a new named expression inside the scoped stack.
parameters:
expr:
type: NamedExprupdate(self, expr: NamedExpr) -> None
title: Update the expression on the SymbolTable.
summary: |-
It is useful mainly for updating the comment of the expression.
parameters:
expr:
type: NamedExprlookup(self, name: str) -> NamedExpr
title: Get a named expression from the scope stack.
parameters:
name:
type: str
returns:
type: NamedExpr