Example #1
0
    def expand_unit(self, unit: Node, **kwargs):

        assert (isinstance(unit, Node))
        context_root_bindings = Record(
            default_expander=self,
            expander=self,
            macros=default_macro_table(),
            id_macros=default_id_macro_table(),
            special_forms=default_special_forms_table())
        context_root_bindings.update(kwargs)
        EC = ExpansionContext(**context_root_bindings.__dict__)
        #unit.cg_context = EC
        for element in unit:
            EC.expand(element)

        return EC
Example #2
0
def expand_macros(code: Node):
    default_expander = DefaultExpander()
    c = ExpansionContext(default_expander=default_expander)
    for item in code:
        c.expand(item)