You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
option -g: show start-end range when possible
This commit is contained in:
@@ -73,6 +73,11 @@ class PythonParser(GenericASTBuilder):
|
|||||||
"""Customized format and print for our kind of tokens
|
"""Customized format and print for our kind of tokens
|
||||||
which gets called in debugging grammar reduce rules
|
which gets called in debugging grammar reduce rules
|
||||||
"""
|
"""
|
||||||
|
def fix(c):
|
||||||
|
s = str(c)
|
||||||
|
i = s.find('_')
|
||||||
|
return s if i == -1 else s[:i]
|
||||||
|
|
||||||
prefix = ''
|
prefix = ''
|
||||||
if parent and tokens:
|
if parent and tokens:
|
||||||
p_token = tokens[parent]
|
p_token = tokens[parent]
|
||||||
@@ -81,8 +86,11 @@ class PythonParser(GenericASTBuilder):
|
|||||||
else:
|
else:
|
||||||
prefix = ' '
|
prefix = ' '
|
||||||
if hasattr(p_token, 'offset'):
|
if hasattr(p_token, 'offset'):
|
||||||
prefix += "%3s " % str(p_token.offset)
|
prefix += "%3s" % fix(p_token.offset)
|
||||||
prefix += " "
|
if len(rule[1]) > 1:
|
||||||
|
prefix += '-%-3s ' % fix(tokens[i-1].offset)
|
||||||
|
else:
|
||||||
|
prefix += ' '
|
||||||
else:
|
else:
|
||||||
prefix = ' '
|
prefix = ' '
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user