- Added new test
- Changed some comments git-svn-id: http://galileo.dmi.unict.it/svn/relational/trunk@263 014f5005-505e-4b48-8d0a-63407b615a7c
This commit is contained in:
parent
99692f7d70
commit
6e16a0d841
@ -17,15 +17,26 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# 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
|
||||
UNARY=1
|
||||
BINARY=2
|
||||
b_operators=('*','-','ᑌ','ᑎ','÷','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ')
|
||||
u_operators=('π','σ','ρ')
|
||||
b_operators=('*','-','ᑌ','ᑎ','÷','ᐅᐊ','ᐅLEFTᐊ','ᐅRIGHTᐊ','ᐅFULLᐊ') # List of binary 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):
|
||||
'''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
|
||||
|
||||
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 command.endswith(';'):
|
||||
|
1
test/subtraction2.query
Normal file
1
test/subtraction2.query
Normal file
@ -0,0 +1 @@
|
||||
σ age>15(people)-people
|
1
test/subtraction2.result
Normal file
1
test/subtraction2.result
Normal file
@ -0,0 +1 @@
|
||||
id,name,chief,age
|
Loading…
x
Reference in New Issue
Block a user