From 0935543280b31559817ef27e0dfc3827cc7a1ef2 Mon Sep 17 00:00:00 2001 From: Erez Shinan Date: Tue, 13 Nov 2018 14:46:50 +0200 Subject: [PATCH] Fix issue with propagate_positions --- lark/parse_tree_builder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lark/parse_tree_builder.py b/lark/parse_tree_builder.py index 31b7214..040c564 100644 --- a/lark/parse_tree_builder.py +++ b/lark/parse_tree_builder.py @@ -28,7 +28,7 @@ class PropagatePositions: def __call__(self, children): res = self.node_builder(children) - if isinstance(res, Tree): + if isinstance(res, Tree) and getattr(res.meta, 'empty', True): res.meta.empty = True for c in children: @@ -144,9 +144,9 @@ class ParseTreeBuilder: expand_single_child = options.expand1 if options else False wrapper_chain = filter(None, [ - self.propagate_positions and PropagatePositions, (expand_single_child and not rule.alias) and ExpandSingleChild, maybe_create_child_filter(rule.expansion, keep_all_tokens), + self.propagate_positions and PropagatePositions, self.ambiguous and maybe_create_ambiguous_expander(self.tree_class, rule.expansion, keep_all_tokens), ])