Browse Source

Merge pull request #69 from NighttimeDriver50000/master

Fixed TypeError on pretty-printing tuples in tree
tags/gm/2021-09-23T00Z/github.com--lark-parser-lark/0.5.3
Erez Shinan 6 years ago
committed by GitHub
parent
commit
a3904187c6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      lark/tree.py

+ 2
- 2
lark/tree.py View File

@@ -21,14 +21,14 @@ class Tree(object):

def _pretty(self, level, indent_str):
if len(self.children) == 1 and not isinstance(self.children[0], Tree):
return [ indent_str*level, self._pretty_label(), '\t', '%s' % self.children[0], '\n']
return [ indent_str*level, self._pretty_label(), '\t', '%s' % (self.children[0],), '\n']

l = [ indent_str*level, self._pretty_label(), '\n' ]
for n in self.children:
if isinstance(n, Tree):
l += n._pretty(level+1, indent_str)
else:
l += [ indent_str*(level+1), '%s' % n, '\n' ]
l += [ indent_str*(level+1), '%s' % (n,), '\n' ]

return l



Loading…
Cancel
Save