Avoid proliferation of parenthesis

The str() function of the parse tree now emits expressions
with much less parenthesis.

This should allow optimized queries to be more readable.
This commit is contained in:
Salvo 'LtWorf' Tomaselli 2016-04-09 11:11:25 +02:00
parent e4e3eae8ce
commit 6bc219c635

View File

@ -277,11 +277,8 @@ class Node (object):
elif (self.kind == UNARY):
return self.name + " " + self.prop + " (" + self.child.__str__() + ")"
elif (self.kind == BINARY):
if self.left.kind == RELATION:
le = self.left.__str__()
else:
le = "(" + self.left.__str__() + ")"
if self.right.kind == RELATION:
le = self.left.__str__()
if self.right.kind != BINARY:
re = self.right.__str__()
else:
re = "(" + self.right.__str__() + ")"