|
|
@ -24,7 +24,7 @@
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# Language definition here:
|
|
|
|
# Language definition here:
|
|
|
|
# http://ltworf.github.io/relational/grammar.html
|
|
|
|
# http://ltworf.github.io/relational/grammar.html
|
|
|
|
from typing import Optional, Union, List, Any, Dict
|
|
|
|
from typing import Optional, Union, List, Any, Dict, Literal
|
|
|
|
from dataclasses import dataclass
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
|
|
|
|
|
|
|
from relational import rtypes
|
|
|
|
from relational import rtypes
|
|
|
@ -43,6 +43,11 @@ SELECTION = 'σ'
|
|
|
|
RENAME = 'ρ'
|
|
|
|
RENAME = 'ρ'
|
|
|
|
ARROW = '➡'
|
|
|
|
ARROW = '➡'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BINARY_LITERALS_T = Literal['*', '-', '∪', '∩', '÷', '⋈', '⧑', '⧒', '⧓']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UNARY_LITERALS_T = Literal['π', 'σ', 'ρ']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
b_operators = (PRODUCT, DIFFERENCE, UNION, INTERSECTION, DIVISION,
|
|
|
|
b_operators = (PRODUCT, DIFFERENCE, UNION, INTERSECTION, DIVISION,
|
|
|
|
JOIN, JOIN_LEFT, JOIN_RIGHT, JOIN_FULL) # List of binary operators
|
|
|
|
JOIN, JOIN_LEFT, JOIN_RIGHT, JOIN_FULL) # List of binary operators
|
|
|
|
u_operators = (PROJECTION, SELECTION, RENAME) # List of unary operators
|
|
|
|
u_operators = (PROJECTION, SELECTION, RENAME) # List of unary operators
|
|
|
@ -194,6 +199,7 @@ class Variable(Node):
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
@dataclass
|
|
|
|
class Binary(Node):
|
|
|
|
class Binary(Node):
|
|
|
|
|
|
|
|
name: BINARY_LITERALS_T
|
|
|
|
left: Node
|
|
|
|
left: Node
|
|
|
|
right: Node
|
|
|
|
right: Node
|
|
|
|
|
|
|
|
|
|
|
@ -214,6 +220,7 @@ class Binary(Node):
|
|
|
|
|
|
|
|
|
|
|
|
@dataclass
|
|
|
|
@dataclass
|
|
|
|
class Unary(Node):
|
|
|
|
class Unary(Node):
|
|
|
|
|
|
|
|
name: UNARY_LITERALS_T
|
|
|
|
prop: str
|
|
|
|
prop: str
|
|
|
|
child: Node
|
|
|
|
child: Node
|
|
|
|
|
|
|
|
|
|
|
|