now using isinstance instead of that ugly thing
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@133 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
e528a4babf
commit
256cd3e4ca
@ -33,10 +33,10 @@ class node (object):
|
||||
|
||||
def __init__(self,expression):
|
||||
'''Generates the tree from the tokenized expression'''
|
||||
while len(expression)==1 and expression[0].__class__==[].__class__: #We have a list, removing
|
||||
while len(expression)==1 and isinstance(expression[0],list): #We have a list, removing
|
||||
expression=expression[0]
|
||||
|
||||
if len(expression)==1 and expression[0].__class__=="".__class__: #We have a string!
|
||||
if len(expression)==1 and isinstance(expression[0],str): #We have a string (relation name)
|
||||
print "Relation: ",expression[0]
|
||||
self.kind=RELATION
|
||||
self.name=expression[0]
|
||||
@ -168,6 +168,11 @@ def tree(expression):
|
||||
#isinstance(k,list)
|
||||
return node(tokenize(expression))
|
||||
|
||||
def optimize(expression):
|
||||
n=tree(expression) #Gets the tree
|
||||
|
||||
return n.__str__()
|
||||
|
||||
if __name__=="__main__":
|
||||
#n=node(u"((a ᑌ b) - c ᑌ d) - b")
|
||||
#n=node(u"((((((((((((2)))))))))))) - (3 * 5) - 2")
|
||||
|
Loading…
x
Reference in New Issue
Block a user