From 8cb08ad030d33e6c4b19a082b823a42387b31dd4 Mon Sep 17 00:00:00 2001 From: Salvo 'LtWorf' Tomaselli Date: Sun, 31 May 2015 19:01:03 +0200 Subject: [PATCH] Change relational language to use math symbols The symbols previously used were a Canadian script, and were looking good enough, but they might not be installed in every machine. Besides, all this is to workaround a Qt5 bug that prevents from rendering those symbols at times. --- CHANGELOG | 6 ++++- relational/parser.py | 23 +++++++------------ test/c_programmers.query | 2 +- test/fixed_len_name.query | 2 +- test/intersection1.query | 2 +- test/intersection2.query | 2 +- test/max_rating_in_age_range.query | 2 +- ...ople_join_select_args_on_both_tables.query | 2 +- .../phones_of_people_with_personal_room.query | 2 +- test/php.query | 2 +- test/redoundant_union_select.query | 2 +- test/select_join_opt.query | 2 +- test/skill_of_best_person.query | 2 +- test/union1.query | 2 +- test/union2.query | 2 +- test/union3.query | 2 +- test/union4.query | 2 +- test/union_and_select.query | 2 +- test/union_or_select.query | 2 +- 19 files changed, 30 insertions(+), 33 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 807c9d0..c2920b6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,8 +1,12 @@ -1.3 +2.0 - Fix bug in relational-cli that made it crash when an exception was raised - Point to new website - Drop support for PySide - Switch to Python3 and drop support for Python2 +- Switch to Qt5 +- Radical change of language. The UNICODE symbols used previously were meant for a + Canadian Aborigenal script. Now switched them to use UNICODE math symbols. +- Since the language is changing, take the chance to use better symbols for JOIN 1.2 - Better tokenizer, gives more indicative errors diff --git a/relational/parser.py b/relational/parser.py index 85c7100..f0f37ab 100644 --- a/relational/parser.py +++ b/relational/parser.py @@ -50,13 +50,13 @@ BINARY = 2 PRODUCT = u'*' DIFFERENCE = u'-' -UNION = u'ᑌ' -INTERSECTION = u'ᑎ' +UNION = u'∪' +INTERSECTION = u'∩' DIVISION = u'÷' -JOIN = u'ᐅᐊ' -JOIN_LEFT = u'ᐅLEFTᐊ' -JOIN_RIGHT = u'ᐅRIGHTᐊ' -JOIN_FULL = u'ᐅFULLᐊ' +JOIN = u'⋈' +JOIN_LEFT = u'⧑' +JOIN_RIGHT = u'⧒' +JOIN_FULL = u'⧓' PROJECTION = u'π' SELECTION = u'σ' RENAME = u'ρ' @@ -330,7 +330,7 @@ def tokenize(expression): # Removes the entire parentesis and content from the expression expression = expression[end + 1:].strip() - elif expression.startswith((u"σ", u"π", u"ρ")): # Unary 2 bytes + elif expression.startswith((SELECTION, RENAME, PROJECTION)): # Unary 2 bytes items.append(expression[0:1]) # Adding operator in the top of the list expression = expression[ @@ -346,17 +346,10 @@ def tokenize(expression): # Inserting parameter of the operator expression = expression[ par:].strip() # Removing parameter from the expression - elif expression.startswith((u"÷", u"ᑎ", u"ᑌ", u"*", u"-")): + elif expression.startswith((DIVISION, INTERSECTION, UNION, PRODUCT, DIFFERENCE, JOIN, JOIN_LEFT, JOIN_RIGHT, JOIN_FULL)): items.append(expression[0]) expression = expression[1:].strip() # 1 char from the expression state = 4 - elif expression.startswith(u"ᐅ"): # Binary long - i = expression.find(u"ᐊ") - if i == -1: - raise TokenizerException(u"Expected ᐊ in %s" % (expression,)) - items.append(expression[:i + 1]) - expression = expression[i + 1:].strip() - state = 4 elif re.match(r'[_0-9A-Za-z]', expression[0]) == None: # At this point we only have relation names, so we raise errors for anything else raise TokenizerException( "Unexpected '%c' in '%s'" % (expression[0], expression)) diff --git a/test/c_programmers.query b/test/c_programmers.query index 7459738..15ae78c 100644 --- a/test/c_programmers.query +++ b/test/c_programmers.query @@ -1 +1 @@ -σ skill=='C'(people ᐅᐊ skills) +σ skill=='C'(people ⋈ skills) diff --git a/test/fixed_len_name.query b/test/fixed_len_name.query index babdcce..14720d1 100644 --- a/test/fixed_len_name.query +++ b/test/fixed_len_name.query @@ -1 +1 @@ -σ (len(name)==4)(peopleᐅᐊ skills) +σ (len(name)==4)(people ⋈ skills) diff --git a/test/intersection1.query b/test/intersection1.query index aa82516..1909fe3 100644 --- a/test/intersection1.query +++ b/test/intersection1.query @@ -1 +1 @@ -σ name=='eve' (people) ᑎ people +σ name=='eve' (people) ∩ people diff --git a/test/intersection2.query b/test/intersection2.query index 216f4e4..ad5ccfb 100644 --- a/test/intersection2.query +++ b/test/intersection2.query @@ -1 +1 @@ -people ᑎ σ name=='eve' (people) +people ∩ σ name=='eve' (people) diff --git a/test/max_rating_in_age_range.query b/test/max_rating_in_age_range.query index 9a53737..ea33f54 100644 --- a/test/max_rating_in_age_range.query +++ b/test/max_rating_in_age_range.query @@ -1 +1 @@ -(σ age<25(people) ᑌ σ age>30(people)) ᐅᐊ ratings-πid,name,chief,age,rating(σ rating30(people)) ᐅᐊ ratings))) * (σ age<25(people) ᑌ σ age>30(people)) ᐅᐊ ratings)) \ No newline at end of file +(σ age<25(people) ∪ σ age>30(people)) ⋈ ratings-πid,name,chief,age,rating(σ rating30(people)) ⋈ ratings))) * (σ age<25(people) ∪ σ age>30(people)) ⋈ ratings)) diff --git a/test/people_join_select_args_on_both_tables.query b/test/people_join_select_args_on_both_tables.query index 2a10884..1b83572 100644 --- a/test/people_join_select_args_on_both_tables.query +++ b/test/people_join_select_args_on_both_tables.query @@ -1 +1 @@ -σ skill=='C' and age<25 and skill!=name(people ᐅᐊ skills) +σ skill=='C' and age<25 and skill!=name(people ⋈ skills) diff --git a/test/phones_of_people_with_personal_room.query b/test/phones_of_people_with_personal_room.query index bc344f2..5a85df9 100644 --- a/test/phones_of_people_with_personal_room.query +++ b/test/phones_of_people_with_personal_room.query @@ -1 +1 @@ -πname,phone(((πname,id(people)- π name,id(πid(σ i!=id and room==r(ρ id➡i,room➡r(person_room)*person_room)) ᐅᐊ people)) ᐅᐊ person_room) ᐅᐊ rooms) +πname,phone(((πname,id(people)- π name,id(πid(σ i!=id and room==r(ρ id➡i,room➡r(person_room)*person_room)) ⋈ people)) ⋈ person_room) ⋈ rooms) diff --git a/test/php.query b/test/php.query index 19e0d80..3210c91 100644 --- a/test/php.query +++ b/test/php.query @@ -1 +1 @@ -σ age<30 and skill=='PHP' (people ᐅᐊ skills) +σ age<30 and skill=='PHP' (people ⋈ skills) diff --git a/test/redoundant_union_select.query b/test/redoundant_union_select.query index c2d5963..b31ebb4 100644 --- a/test/redoundant_union_select.query +++ b/test/redoundant_union_select.query @@ -1 +1 @@ -σ (id==2) (σ age>5 (people ᑌ people)) +σ (id==2) (σ age>5 (people ∪ people)) diff --git a/test/select_join_opt.query b/test/select_join_opt.query index 384b709..3779e09 100644 --- a/test/select_join_opt.query +++ b/test/select_join_opt.query @@ -1 +1 @@ -σ skill=='C' and chief==0 ((σ age<30 (people) ᑌ σ age>40(people)) ᐅᐊ skills) +σ skill=='C' and chief==0 ((σ age<30 (people) ∪ σ age>40(people)) ⋈ skills) diff --git a/test/skill_of_best_person.query b/test/skill_of_best_person.query index 8eeb69e..03a7636 100644 --- a/test/skill_of_best_person.query +++ b/test/skill_of_best_person.query @@ -1 +1 @@ -πname,age,skill((ratings-πid,rating(σ r>rating (ρrating➡r(πrating(ratings )) * ratings)) ᐅᐊ people) ᐅᐊ skills) +πname,age,skill((ratings-πid,rating(σ r>rating (ρrating➡r(πrating(ratings )) * ratings)) ⋈ people) ⋈ skills) diff --git a/test/union1.query b/test/union1.query index 200d663..19f64ce 100644 --- a/test/union1.query +++ b/test/union1.query @@ -1 +1 @@ -σ age<30 (σ (id%2==0) (people) ᑌ σ age>22(people)) +σ age<30 (σ (id%2==0) (people) ∪ σ age>22(people)) diff --git a/test/union2.query b/test/union2.query index 61a3569..4beb977 100644 --- a/test/union2.query +++ b/test/union2.query @@ -1 +1 @@ -people ᑌ σ name=='eve' (people) +people ∪ σ name=='eve' (people) diff --git a/test/union3.query b/test/union3.query index 1643a1d..282dd23 100644 --- a/test/union3.query +++ b/test/union3.query @@ -1 +1 @@ -σ name=='eve' (people) ᑌ people +σ name=='eve' (people) ∪ people diff --git a/test/union4.query b/test/union4.query index e67c0f5..95e4975 100644 --- a/test/union4.query +++ b/test/union4.query @@ -1 +1 @@ -people ᑌ people ᑎ people +people ∪ people ∩ people diff --git a/test/union_and_select.query b/test/union_and_select.query index 4749312..ee70e1a 100644 --- a/test/union_and_select.query +++ b/test/union_and_select.query @@ -1 +1 @@ -σ skill=='C'(skills) ᑎ σ id%2==0 (skills) +σ skill=='C'(skills) ∩ σ id%2==0 (skills) diff --git a/test/union_or_select.query b/test/union_or_select.query index 39a67dd..508a3e7 100644 --- a/test/union_or_select.query +++ b/test/union_or_select.query @@ -1 +1 @@ -σ age<21 (people) ᑌ σage >30(people) +σ age<21 (people) ∪ σage >30(people)