--tree++ shows template rule when it is used

This commit is contained in:
rocky
2018-05-13 14:21:46 -04:00
parent c087bd785e
commit 4c74bf1d9d
3 changed files with 71 additions and 9 deletions

View File

@@ -32,7 +32,7 @@ def maybe_show_asm(showasm, tokens):
stream.write('\n')
def maybe_show_tree(show_tree, ast):
def maybe_show_tree(walker, ast):
"""
Show the ast based on the showast flag (or file object), writing to the
appropriate stream depending on the type of the flag.
@@ -42,9 +42,15 @@ def maybe_show_tree(show_tree, ast):
like object, into which the ast will be written).
:param ast: The ast to show.
"""
if show_tree:
stream = show_tree if hasattr(show_tree, 'write') else sys.stdout
stream.write(str(ast))
if walker.showast:
if hasattr(walker.showast, 'write'):
stream = walker.showast
else:
stream = sys.stdout
if walker.showast == 'Full':
walker.str_with_template(ast)
else:
stream.write(str(ast))
stream.write('\n')