- Added new test

- Changed some comments


git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@263 014f5005-505e-4b48-8d0a-63407b615a7c
master
LtWorf 2010-10-26 13:54:34 +07:00
parent 99692f7d70
commit 6e16a0d841
4 changed files with 20 additions and 4 deletions

@ -17,15 +17,26 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
# author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it> # author Salvo "LtWorf" Tomaselli <tiposchi@tiscali.it>
#
#
#
# This module implements a parser for relational algebra, and can be used
# to convert expressions into python expressions and to get the parse-tree
# of the expression.
#
# The input must be provided in UTF-8
#
# Language definition here:
# https://galileo.dmi.unict.it/wiki/relational/doku.php?id=language
RELATION=0 RELATION=0
UNARY=1 UNARY=1
BINARY=2 BINARY=2
b_operators=('*','-','','','÷','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ') b_operators=('*','-','','','÷','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ') # List of binary operators
u_operators=('π','σ','ρ') u_operators=('π','σ','ρ') # List of unary operators
op_functions={'*':'product','-':'difference','':'union','':'intersection','÷':'division','ᐅᐊ':'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'} # Associates operator with python method
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.

@ -216,7 +216,10 @@ def replacements(query):
return query return query
def exec_query(command): def exec_query(command):
'''This function executes a query and prints the result on the screen''' '''This function executes a query and prints the result on the screen
if the command terminates with ";" the result will not be printed
'''
#If it terminates with ; doesn't print the result #If it terminates with ; doesn't print the result
if command.endswith(';'): if command.endswith(';'):

@ -0,0 +1 @@
σ age>15(people)-people

@ -0,0 +1 @@
id,name,chief,age