diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2023-11-20 22:14:55 +0200 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2023-11-20 22:14:55 +0200 |
| commit | e2fd1c7ee759ac8870f21afe5fc4e36c8b808d25 (patch) | |
| tree | d9041314fa29d4acfc72440be9192207ba08c964 /src/ast_compiler.py | |
| parent | 14d8401c721fae8367fa24db20af4e344faafdd4 (diff) | |
Do things
Diffstat (limited to 'src/ast_compiler.py')
| -rw-r--r-- | src/ast_compiler.py | 14 |
1 files changed, 14 insertions, 0 deletions
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")]: |
