From 814594e825365299641701a6008b76db9ca44ffa Mon Sep 17 00:00:00 2001 From: LtWorf Date: Fri, 2 Jul 2010 13:58:16 +0000 Subject: [PATCH] - Can parse expressions with division operator git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@239 014f5005-505e-4b48-8d0a-63407b615a7c --- relational/parser.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/relational/parser.py b/relational/parser.py index 0f38f04..085767d 100644 --- a/relational/parser.py +++ b/relational/parser.py @@ -22,10 +22,10 @@ RELATION=0 UNARY=1 BINARY=2 -b_operators=('*','-','ᑌ','ᑎ','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ') +b_operators=('*','-','ᑌ','ᑎ','÷','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ') 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): '''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 items.append(expression[0:3]) #Adding operator in the top of the list 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 elif expression.startswith("ᐅ"): #Binary long i=expression.find("ᐊ")