diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2020-02-23 22:14:49 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2020-02-23 22:15:41 -0300 |
commit | 6f4df5d08e147f74f91bf7ce2f882dca1390c721 (patch) | |
tree | 7f748df5f3e341736db39977b9d3e1c3d196d054 /abdl | |
parent | a1b8ddf536259a04362804dbc0cf368c1fead5a2 (diff) |
Fix tagged key subtrees not working correctly
Diffstat (limited to 'abdl')
-rw-r--r-- | abdl/_vm.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/abdl/_vm.py b/abdl/_vm.py index f8b8c80..41f28eb 100644 --- a/abdl/_vm.py +++ b/abdl/_vm.py @@ -88,18 +88,24 @@ class KeySubtree(PatternElement): self.key = toks[0] self.skippable = toks[1] == '?' + def on_in_key(self, frame, path, defs): + return self.on_not_in_key(frame, path, defs) + def on_not_in_key(self, frame, path, defs): path[-1].subtree = True - filtered_iterator = self.filter(path[-1].iterator, defs) + filtered_iterator = self.filter(path[-1].iterator, defs, name=path[-1].name) del path[-1].iterator path[-1].iterator = filtered_iterator del filtered_iterator path[-1].empty = False return True - def filter(self, iter_, defs): + def filter(self, iter_, defs, name): for x in iter_: for y in match_helper(self.key, defs, x[0]): + if name: + # FIXME this "name" thing is a bit suboptimal + y.setdefault(name, x) yield (y, x[1]) def collect_params(self, res: list): |