- Can parse expressions with division operator
git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@239 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
215386350d
commit
814594e825
@ -22,10 +22,10 @@
|
|||||||
RELATION=0
|
RELATION=0
|
||||||
UNARY=1
|
UNARY=1
|
||||||
BINARY=2
|
BINARY=2
|
||||||
b_operators=('*','-','ᑌ','ᑎ','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ')
|
b_operators=('*','-','ᑌ','ᑎ','÷','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ')
|
||||||
u_operators=('π','σ','ρ')
|
u_operators=('π','σ','ρ')
|
||||||
|
|
||||||
op_functions={'*':'product','-':'difference','ᑌ':'union','ᑎ':'intersection','ᐅᐊ':'join','ᐅLEFTᐊ':'outer_left','ᐅRIGHTᐊ':'outer_right','ᐅFULLᐊ':'outer','π':'projection','σ':'selection','ρ':'rename'}
|
op_functions={'*':'product','-':'difference','ᑌ':'union','ᑎ':'intersection','÷':'division','ᐅᐊ':'join','ᐅLEFTᐊ':'outer_left','ᐅRIGHTᐊ':'outer_right','ᐅFULLᐊ':'outer','π':'projection','σ':'selection','ρ':'rename'}
|
||||||
|
|
||||||
class node (object):
|
class node (object):
|
||||||
'''This class is a node of a relational expression. Leaves are relations and internal nodes are operations.
|
'''This class is a node of a relational expression. Leaves are relations and internal nodes are operations.
|
||||||
@ -257,7 +257,10 @@ def tokenize(expression):
|
|||||||
elif expression.startswith("ᑎ") or expression.startswith("ᑌ"): #Binary short 3 bytes
|
elif expression.startswith("ᑎ") or expression.startswith("ᑌ"): #Binary short 3 bytes
|
||||||
items.append(expression[0:3]) #Adding operator in the top of the list
|
items.append(expression[0:3]) #Adding operator in the top of the list
|
||||||
expression=expression[3:].strip() #Removing operator from the expression
|
expression=expression[3:].strip() #Removing operator from the expression
|
||||||
|
state=4
|
||||||
|
elif expression.startswith("÷"): #Binary short 2 bytes
|
||||||
|
items.append(expression[0:2]) #Adding operator in the top of the list
|
||||||
|
expression=expression[2:].strip() #Removing operator from the expression
|
||||||
state=4
|
state=4
|
||||||
elif expression.startswith("ᐅ"): #Binary long
|
elif expression.startswith("ᐅ"): #Binary long
|
||||||
i=expression.find("ᐊ")
|
i=expression.find("ᐊ")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user