macropy
macropy copied to clipboard
Use pattern matching internally
A lot of our transformers could use pattern matching. It would make our code nicer.
Trying to pattern match on AST nodes causes the pattern matcher to barf because they don't have normal __init__
methods; is there a way to force keyword-only matching to bypass this?
I just pushed a small change which makes positional matching as needed using generators. This should fix things.
and...tests
This:
with switch(tree):
if Str(s=s):
return q%Parser.Raw(ast%tree), stop
TypeError: <slot wrapper '__init__' of '_ast.AST' objects> is not a Python function
Is still blowing up on me. Do you want to try refactoring our macros to use pattern matching? I feel like you'll have a better shot at getting stuff working, since I suspect it will require substantial fixes to the pattern matcher to get it to work.
ok. yeah ugh that's annoying.