From e2fd1c7ee759ac8870f21afe5fc4e36c8b808d25 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Mon, 20 Nov 2023 22:14:55 +0200 Subject: Do things --- src/ast_compiler.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/ast_compiler.py') diff --git a/src/ast_compiler.py b/src/ast_compiler.py index 4dfcf8e..f0d0c79 100644 --- a/src/ast_compiler.py +++ b/src/ast_compiler.py @@ -643,6 +643,20 @@ class Compiler(ast.NodeVisitor): case other: raise Exception(f"Unsupported assign targets: {other}") + def visit_AugAssign(self, node: ast.AugAssign): + op = node.op + lhs = node.target + rhs = node.value + + if type(lhs) != ast.Name: + raise Exception("AugAssign to non-Name lhs not yet supported!") + + # construct bin op and assignment + bin_op = ast.BinOp(left=lhs, op=op, right=rhs) + assign = ast.Assign(targets=[lhs], value=bin_op) + + self.visit(assign) + def visit_Import(self, node: ast.Import) -> Any: match node.names: case [ast.alias(name="atk16")]: -- cgit v1.3