diff options
Diffstat (limited to 'Tools')
-rw-r--r-- | Tools/parser/unparse.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/Tools/parser/unparse.py b/Tools/parser/unparse.py index 0c1cc5f..c828577 100644 --- a/Tools/parser/unparse.py +++ b/Tools/parser/unparse.py @@ -138,6 +138,14 @@ class Unparser: self.fill("nonlocal ") interleave(lambda: self.write(", "), self.write, t.names) + def _Await(self, t): + self.write("(") + self.write("await") + if t.value: + self.write(" ") + self.dispatch(t.value) + self.write(")") + def _Yield(self, t): self.write("(") self.write("yield") @@ -218,11 +226,18 @@ class Unparser: self.leave() def _FunctionDef(self, t): + self.__FunctionDef_helper(t, "def") + + def _AsyncFunctionDef(self, t): + self.__FunctionDef_helper(t, "async def") + + def __FunctionDef_helper(self, t, fill_suffix): self.write("\n") for deco in t.decorator_list: self.fill("@") self.dispatch(deco) - self.fill("def "+t.name + "(") + def_str = fill_suffix+" "+t.name + "(" + self.fill(def_str) self.dispatch(t.args) self.write(")") if t.returns: @@ -233,7 +248,13 @@ class Unparser: self.leave() def _For(self, t): - self.fill("for ") + self.__For_helper("for ", t) + + def _AsyncFor(self, t): + self.__For_helper("async for ", t) + + def __For_helper(self, fill, t): + self.fill(fill) self.dispatch(t.target) self.write(" in ") self.dispatch(t.iter) @@ -287,6 +308,13 @@ class Unparser: self.dispatch(t.body) self.leave() + def _AsyncWith(self, t): + self.fill("async with ") + interleave(lambda: self.write(", "), self.dispatch, t.items) + self.enter() + self.dispatch(t.body) + self.leave() + # expr def _Bytes(self, t): self.write(repr(t.s)) |