diff --git a/relational/parser.py b/relational/parser.py index 09620d0..04319a1 100644 --- a/relational/parser.py +++ b/relational/parser.py @@ -17,15 +17,26 @@ # along with this program. If not, see . # # author Salvo "LtWorf" Tomaselli +# +# +# +# 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. diff --git a/relational_readline/linegui.py b/relational_readline/linegui.py index 9258a37..4b054bb 100644 --- a/relational_readline/linegui.py +++ b/relational_readline/linegui.py @@ -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(';'): diff --git a/test/subtraction2.query b/test/subtraction2.query new file mode 100644 index 0000000..89c5b14 --- /dev/null +++ b/test/subtraction2.query @@ -0,0 +1 @@ +σ age>15(people)-people diff --git a/test/subtraction2.result b/test/subtraction2.result new file mode 100644 index 0000000..9d637aa --- /dev/null +++ b/test/subtraction2.result @@ -0,0 +1 @@ +id,name,chief,age