def __init__(self, symbol_table: st.SymbolTable, name="BaseVisitor", identifier: Identifier = NaiveIdentifier()): super().__init__() self.log = colorlog.getLogger(self.__class__.__name__) self.visitor_name = name # The current symbol table self.symbol_table = symbol_table self.nl = "\n" # Manages the scopes that we are in. self.scope_stack = list() self.const = 'CONST_' self.identifier = identifier
def run_symbols(tree, symbol_table: SymbolTable) -> SymbolTable: symbol_visitor = SymbolTableVisitor(symbol_table, NaiveIdentifier()) symbol_visitor.visit(tree) return symbol_visitor.symbol_table
def run_globals( tree, symbol_table: SymbolTable = SymbolTable()) -> SymbolTable: header_visitor = HeaderVisitor(symbol_table, NaiveIdentifier()) header_visitor.visit(tree) return header_visitor.symbol_table