summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Sotoudeh <matthew@masot.net>2024-04-18 11:11:13 -0700
committerMatthew Sotoudeh <matthew@masot.net>2024-04-18 11:11:13 -0700
commit52b44fe1653f7621b65b838be2ecb3d3827cb84c (patch)
tree3d44d9dbcb37c6d78b2cd5da11469d0e3ea9dc15
parent6378e436a0a21d90526532f4646904da051ff8c9 (diff)
allow flat printingHEADmaster
-rw-r--r--earlpy/earlpy.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/earlpy/earlpy.py b/earlpy/earlpy.py
index 5a1cb52..63e15e9 100644
--- a/earlpy/earlpy.py
+++ b/earlpy/earlpy.py
@@ -367,13 +367,14 @@ class Node:
def file_name(self):
return self.contents[-1].file_name()
- def pprint(self):
+ def pprint(self, flat=False):
def pprint(other):
if isinstance(other, Node):
- return other.pprint()
- return other.pprint()
+ return other.pprint(flat)
+ return other.pprint(flat)
if len(self.contents) == 1:
return pprint(self.contents[0])
+ if flat: return ' '.join(map(pprint, self.contents))
return '(' + ' '.join(map(pprint, self.contents)) + ')'
def print_tree(self, depth=0):
@@ -428,7 +429,7 @@ class Token:
self.line_number = line_number
self.file_name_ = file_name
- def pprint(self):
+ def pprint(self, flat=None):
return self.string
def line_numbers(self):
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback