Browse Source

Fix Propagate Positions

tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.6.6
night199uk 6 years ago
parent
commit
1f5abfc937
2 changed files with 3 additions and 4 deletions
  1. +1
    -3
      lark/parse_tree_builder.py
  2. +2
    -1
      lark/tree.py

+ 1
- 3
lark/parse_tree_builder.py View File

@@ -25,9 +25,7 @@ class PropagatePositions:
def __call__(self, children):
res = self.node_builder(children)

if isinstance(res, Tree) and getattr(res.meta, 'empty', True):
res.meta.empty = True

if isinstance(res, Tree):
for c in children:
if isinstance(c, Tree) and c.children and not c.meta.empty:
res.meta.line = c.meta.line


+ 2
- 1
lark/tree.py View File

@@ -8,7 +8,8 @@ from copy import deepcopy

###{standalone
class Meta:
pass
def __init__(self):
self.empty = True

class Tree(object):
def __init__(self, data, children, meta=None):


Loading…
Cancel
Save