def __init__(self, parent, expr): super(Identifier, self).__init__(parent) self.identifier = context.Identifier(self, expr) if parent.get_scope().resolve(self.identifier) is None: raise Exception('{id} was not defined'.format(id=self.identifier))
def __init__(self, parent, name, T): super(Argument, self).__init__(parent) self.identifier = context.Identifier(self, name) # Make variable visible in the function self.identifier.add_to_scope() self.T = var_types.Type(self, T)
def __init__(self, parent, stmt, terminator=';'): super(Definition, self).__init__(parent) self.terminator = terminator self.identifier = context.Identifier(self, stmt.children[0]) # Make variable visible in current scope self.identifier.add_to_scope() self.T = var_types.Type(self, stmt.children[1])
def __init__(self, parent, name): super(Module, self).__init__(parent) # Create sub-scope self.get_ctx().sub_scope() self.identifier = context.Identifier(self, name) # Make module visible inside program self.identifier.add_to_parent_scope() self.functions = [] self.classes = []
def __init__(self, parent, name, T, body): super(Function, self).__init__(parent) # Create sub-scope self.get_ctx().sub_scope() self.identifier = context.Identifier(self, name) # Make the function visible in the scope of the parent self.identifier.add_to_parent_scope() self.parse_type(T) self.parse_body(body)