Skip to content

Commit db7a26d

Browse files
committed
option -g: show start-end range when possible
1 parent 9216645 commit db7a26d

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

uncompyle6/parser.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ def debug_reduce(self, rule, tokens, parent, i):
7373
"""Customized format and print for our kind of tokens
7474
which gets called in debugging grammar reduce rules
7575
"""
76+
def fix(c):
77+
s = str(c)
78+
i = s.find('_')
79+
return s if i == -1 else s[:i]
80+
7681
prefix = ''
7782
if parent and tokens:
7883
p_token = tokens[parent]
@@ -81,8 +86,11 @@ def debug_reduce(self, rule, tokens, parent, i):
8186
else:
8287
prefix = ' '
8388
if hasattr(p_token, 'offset'):
84-
prefix += "%3s " % str(p_token.offset)
85-
prefix += " "
89+
prefix += "%3s" % fix(p_token.offset)
90+
if len(rule[1]) > 1:
91+
prefix += '-%-3s ' % fix(tokens[i-1].offset)
92+
else:
93+
prefix += ' '
8694
else:
8795
prefix = ' '
8896

0 commit comments

Comments
 (0)