- Can convert the expressions into python code objects as well

- Can test that the code objects work as expected too.
This commit is contained in:
Salvo 'LtWorf' Tomaselli
2013-02-10 14:11:26 +01:00
parent 436958f40e
commit 2e0cbf94a7
2 changed files with 14 additions and 7 deletions

View File

@@ -144,9 +144,14 @@ class node (object):
return
raise ParserException(u"Unable to parse tokens")
pass
def toCode(self):
'''This method converts the tree into a python code object'''
code = self.toPython()
return compile(code,'<relational_expression>','eval')
def toPython(self):
'''This method converts the expression into python code, which will require the
relation module to be executed.'''
'''This method converts the expression into a python code string, which
will require the relation module to be executed.'''
if self.name in b_operators:
return '%s.%s(%s)' % (self.left.toPython(),op_functions[self.name],self.right.toPython())
elif self.name in u_operators: